diff --git a/components/tvplanit/examples/fulldemo/demomain.lfm b/components/tvplanit/examples/fulldemo/demomain.lfm index f395809c1..342c771c0 100644 --- a/components/tvplanit/examples/fulldemo/demomain.lfm +++ b/components/tvplanit/examples/fulldemo/demomain.lfm @@ -4,22 +4,21 @@ object MainForm: TMainForm Top = 135 Width = 959 Caption = 'Turbo Power VisualPlanIt Demo' - ClientHeight = 576 + ClientHeight = 596 ClientWidth = 959 Menu = MainMenu1 OnCloseQuery = FormCloseQuery OnCreate = FormCreate OnDestroy = FormDestroy - LCLVersion = '2.3.0.0' object Panel1: TPanel Left = 125 - Height = 576 + Height = 596 Top = 0 Width = 834 Align = alClient AutoSize = True BevelOuter = bvNone - ClientHeight = 576 + ClientHeight = 596 ClientWidth = 834 TabOrder = 2 object HeaderPanel: TPanel @@ -56,7 +55,7 @@ object MainForm: TMainForm end object Notebook: TNotebook Left = 0 - Height = 528 + Height = 548 Top = 48 Width = 834 PageIndex = 0 @@ -66,18 +65,18 @@ object MainForm: TMainForm object Events: TPage object LeftPanel: TPanel Left = 0 - Height = 528 + Height = 548 Top = 0 Width = 357 Align = alLeft BevelOuter = bvNone - ClientHeight = 528 + ClientHeight = 548 ClientWidth = 357 TabOrder = 0 object VpMonthView1: TVpMonthView Left = 0 Height = 197 - Top = 331 + Top = 351 Width = 357 ShowHint = True PopupMenu = VpMonthView1.default @@ -85,12 +84,10 @@ object MainForm: TMainForm ParentShowHint = False Align = alBottom TabOrder = 0 - DayHeadAttributes.Color = clBtnFace DrawingStyle = dsFlat EventDayStyle = [fsItalic] HeadAttributes.Font.Height = -16 HeadAttributes.Font.Style = [fsItalic] - HeadAttributes.Color = clBtnFace HolidayAttributes.Font.Color = clBlack TodayAttributes.Font.Color = clBlue TodayAttributes.Color = 16761024 @@ -103,14 +100,14 @@ object MainForm: TMainForm Cursor = crVSplit Left = 0 Height = 5 - Top = 326 + Top = 346 Width = 357 Align = alBottom ResizeAnchor = akBottom end object VpDayView1: TVpDayView Left = 0 - Height = 292 + Height = 312 Top = 34 Width = 357 ShowHint = True @@ -121,9 +118,6 @@ object MainForm: TMainForm ParentShowHint = False Align = alClient TabOrder = 2 - AllDayEventAttributes.BackgroundColor = clBtnShadow - AllDayEventAttributes.EventBorderColor = cl3DDkShadow - AllDayEventAttributes.EventBackgroundColor = clBtnFace AllDayEventAttributes.Font.Height = -12 ShowEventTimes = False DrawingStyle = dsFlat @@ -132,10 +126,8 @@ object MainForm: TMainForm TimeSlotColors.ActiveRange.RangeEnd = h_00 HeadAttributes.Font.Height = -16 HeadAttributes.Font.Style = [fsItalic] - HeadAttributes.Color = clBtnFace RowHeadAttributes.HourFont.Height = -24 RowHeadAttributes.MinuteFont.Height = -12 - RowHeadAttributes.Color = clBtnFace IconAttributes.AlarmBitmap.Data = { 76020000424D760200000000000036000000280000000C0000000C0000000100 20000000000040020000C30E0000C30E00000000000000000000FFFFFF00FFFF @@ -278,13 +270,13 @@ object MainForm: TMainForm end object Splitter3: TSplitter Left = 357 - Height = 528 + Height = 548 Top = 0 Width = 5 end object VpWeekView1: TVpWeekView Left = 362 - Height = 528 + Height = 548 Top = 0 Width = 472 ShowHint = True @@ -293,19 +285,14 @@ object MainForm: TMainForm Font.Height = -12 ParentFont = False ParentShowHint = False - AllDayEventAttributes.BackgroundColor = clWindow - AllDayEventAttributes.EventBorderColor = clGray - AllDayEventAttributes.EventBackgroundColor = clBtnFace AllDayEventAttributes.Font.Height = -12 DateLabelFormat = 'dddd, mmmm dd, yyyy' - DayHeadAttributes.Color = clBtnFace DayHeadAttributes.DateFormat = 'ddddd' DayHeadAttributes.Font.Height = -13 DrawingStyle = dsFlat EventFont.Height = -12 HeadAttributes.Font.Height = -16 HeadAttributes.Font.Style = [fsItalic] - HeadAttributes.Color = clBtnFace LineColor = clGray Layout = wvlHorizontal WeekStartsOn = dtMonday @@ -717,7 +704,7 @@ object MainForm: TMainForm end object VpNavBar1: TVpNavBar Left = 0 - Height = 576 + Height = 596 Top = 0 Width = 120 ActiveFolder = 0 @@ -818,7 +805,7 @@ object MainForm: TMainForm end object Splitter1: TSplitter Left = 120 - Height = 576 + Height = 596 Top = 0 Width = 5 end @@ -1333,8 +1320,8 @@ object MainForm: TMainForm end end object PrintDialog1: TPrintDialog - Left = 232 - Top = 368 + Left = 224 + Top = 344 end object VpPrintPreviewDialog1: TVpPrintPreviewDialog Version = 'v1.12' diff --git a/components/tvplanit/examples/fulldemo/demomain.pas b/components/tvplanit/examples/fulldemo/demomain.pas index 753673c47..843d628ac 100644 --- a/components/tvplanit/examples/fulldemo/demomain.pas +++ b/components/tvplanit/examples/fulldemo/demomain.pas @@ -628,7 +628,6 @@ begin VpControlLink1.Datastore.OnDateChanged := @DateChangedHandler; with VpControlLink1.Datastore do begin - // These properties could be set also in Object Inspector. // But we do it here at runtime because the mORMot datastore is // created at runtime, and we want both versions to behave the same. diff --git a/components/tvplanit/source/vpbase.pas b/components/tvplanit/source/vpbase.pas index 1e0cc0299..01a45cacd 100644 --- a/components/tvplanit/source/vpbase.pas +++ b/components/tvplanit/source/vpbase.pas @@ -420,6 +420,33 @@ type property ActiveRange: TVpTimeRange read FActiveRange write FActiveRange; end; + TVpAllDayEventAttributes = class(TPersistent) + private + FOwner: TWinControl; + FBackgroundColor: TColor; + FEventBackgroundColor: TColor; + FEventBorderColor: TColor; + FFont: TVpFont; + protected + procedure UpdateOwner; + public + constructor Create(AOwner: TWinControl); + destructor Destroy; override; + procedure SetBackGroundColor(Value: TColor); + procedure SetEventBackgroundColor(Value: TColor); + procedure SetFont(Value: TVpFont); + procedure SetEventBorderColor(Value: TColor); + published + property BackgroundColor: TColor + read FBackgroundColor write SetBackGroundColor default clBtnShadow; + property EventBackgroundColor: TColor + read FEventBackgroundColor write SetEventBackgroundColor default clBtnFace; + property EventBorderColor: TColor + read FEventBorderColor write SetEventBorderColor default cl3dDkShadow; + property Font: TVpFont + read FFont write SetFont; + end; + TVpHintWindow = class(THintWindow) public function CalcHintRect({%H-}MaxWidth: Integer; const AHint: String; @@ -1019,6 +1046,54 @@ begin end; +{ TVpAllDayEventAttributes } + +constructor TVpAllDayEventAttributes.Create(AOwner: TWinControl); +begin + FOwner:= AOwner; + FFont := TVpFont.Create(AOwner); + FBackgroundColor := clBtnShadow; + FEventBackgroundColor := clBtnFace; + FEventBorderColor := cl3dDkShadow; +end; + +destructor TVpAllDayEventAttributes.Destroy; +begin + inherited; + FFont.Free; +end; + +procedure TVpAllDayEventAttributes.SetBackGroundColor(Value: TColor); +begin + FBackgroundColor := Value; + UpdateOwner; +end; + +procedure TVpAllDayEventAttributes.SetEventBackgroundColor(Value: TColor); +begin + FEventBackgroundColor := Value; + UpdateOwner; +end; + +procedure TVpAllDayEventAttributes.SetEventBorderColor(Value: TColor); +begin + FEventBorderColor := Value; + UpdateOwner; +end; + +procedure TVpAllDayEventAttributes.SetFont(Value: TVpFont); +begin + FFont.Assign(Value); + FFont.Owner := FOwner; +end; + +procedure TVpAllDayEventAttributes.UpdateOwner; +begin + if Assigned(FOwner) then + FOwner.Invalidate; +end; + + { TVpHintWindow } function TVpHintWindow.CalcHintRect(MaxWidth: Integer; const AHint: String; diff --git a/components/tvplanit/source/vpconst.pas b/components/tvplanit/source/vpconst.pas index 09f0e0164..34d63a52f 100644 --- a/components/tvplanit/source/vpconst.pas +++ b/components/tvplanit/source/vpconst.pas @@ -101,6 +101,9 @@ const strTRUE = 'true'; strFALSE = 'false'; + DEFAULT_COLOR = clWindow; + DEFAULT_LINECOLOR = clSilver; + DEFAULT_HEADERCOLOR = clBtnFace; WEEKDAY_COLOR = $FFFFFF; WEEKEND_COLOR = $D0D0D0; HOLIDAY_COLOR = $8080FF; @@ -265,9 +268,6 @@ const CONDITIONAL_INCLUDE = 0; CONDITIONAL_IGNORE = 1; - DEFAULT_COLOR = clWindow; - DEFAULT_LINECOLOR = clSilver; - { Version numbers } VpXSLImplementation = 0.0; VpXMLSpecification = '1.0'; diff --git a/components/tvplanit/source/vpcontactgrid.pas b/components/tvplanit/source/vpcontactgrid.pas index dc37877fb..0736b6b21 100644 --- a/components/tvplanit/source/vpcontactgrid.pas +++ b/components/tvplanit/source/vpcontactgrid.pas @@ -89,7 +89,7 @@ type end; TVpContactHeadAttr = class(TPersistent) - protected{private} + private FGrid: TVpContactGrid; FFont: TVpFont; FColor: TColor; @@ -97,14 +97,16 @@ type procedure SetColor(Value: TColor); procedure SetFont(Value: TVpFont); procedure SetBordered(Value: Boolean); + protected + procedure UpdateContactGrid; public constructor Create(AOwner: TVpContactGrid); destructor Destroy; override; property Grid: TVpContactGrid read FGrid; published - property Color: TColor read FColor write SetColor; + property Bordered: Boolean read FBordered write SetBordered default true; + property Color: TColor read FColor write SetColor default clSilver; property Font: TVpFont read FFont write SetFont; - property Bordered: Boolean read FBordered write SetBordered; end; { Contact Grid } @@ -352,7 +354,7 @@ procedure TVpContactHeadAttr.SetBordered(Value: Boolean); begin if Value <> FBordered then begin FBordered := Value; - Grid.Invalidate; + UpdateContactGrid; end; end; @@ -360,7 +362,7 @@ procedure TVpContactHeadAttr.SetColor(Value: TColor); begin if Value <> FColor then begin FColor := Value; - Grid.Invalidate; + UpdateContactGrid; end; end; @@ -368,10 +370,17 @@ procedure TVpContactHeadAttr.SetFont(Value: TVpFont); begin if Value <> FFont then begin FFont.Assign(Value); - Grid.Invalidate; + FFont.Owner := FGrid; + UpdateContactGrid; end; end; +procedure TVpContactHeadAttr.UpdateContactGrid; +begin + if Assigned(FGrid) then + FGrid.Invalidate; +end; + (*****************************************************************************) { TVpCGInPlaceEdit } diff --git a/components/tvplanit/source/vpdayview.pas b/components/tvplanit/source/vpdayview.pas index 8ff49d507..80cdf2c40 100644 --- a/components/tvplanit/source/vpdayview.pas +++ b/components/tvplanit/source/vpdayview.pas @@ -138,6 +138,7 @@ type procedure SetHourFont(Value: TVpFont); procedure SetMinuteFont(Value: TVpFont); protected + procedure UpdateDayView; public constructor Create(AOwner: TVpDayView); destructor Destroy; override; @@ -145,33 +146,7 @@ type published property HourFont: TVpFont read FHourFont write SetHourFont; property MinuteFont: TVpFont read FMinuteFont write SetMinuteFont; - property Color: TColor read FColor write SetColor; - end; - - TVpAllDayEventAttributes = class(TPersistent) - private - FBackgroundColor: TColor; - FEventBackgroundColor: TColor; - FEventBorderColor: TColor; - FFont: TVpFont; - protected - FOwner: TWinControl; - public - constructor Create(AOwner: TWinControl); - destructor Destroy; override; - procedure SetBackGroundColor(Value: TColor); - procedure SetEventBackgroundColor(Value: TColor); - procedure SetFont(Value: TVpFont); - procedure SetEventBorderColor(Value: TColor); - published - property BackgroundColor: TColor - read FBackgroundColor write SetBackGroundColor; - property EventBorderColor: TColor - read FEventBorderColor write SetEventBorderColor; - property EventBackgroundColor: TColor - read FEventBackgroundColor write SetEventBackgroundColor; - property Font: TVpFont - read FFont write SetFont; + property Color: TColor read FColor write SetColor default DEFAULT_HEADERCOLOR; end; TVpCHAttributes = class(TPersistent) @@ -182,13 +157,14 @@ type procedure SetColor(const Value: TColor); procedure SetFont(Value: TVpFont); protected + procedure UpdateDateView; public constructor Create(AOwner: TVpDayView); destructor Destroy; override; property Owner: TVpDayView read FOwner; published property Font: TVpFont read FFont write SetFont; - property Color: TColor read FColor write SetColor; + property Color: TColor read FColor write SetColor default DEFAULT_HEADERCOLOR; end; TVpDayViewIconAttributes = class(TPersistent) @@ -635,52 +611,8 @@ begin end; -(*****************************************************************************) -{ TVpAllDayEventAttributes } - -constructor TVpAllDayEventAttributes.Create(AOwner: TWinControl); -begin - FOwner:= AOwner; - FFont := TVpFont.Create(AOwner); - FBackgroundColor := clBtnShadow; - FEventBackgroundColor := clBtnFace; - FEventBorderColor := cl3dDkShadow; -end; - -destructor TVpAllDayEventAttributes.Destroy; -begin - inherited; - FFont.Free; -end; - -procedure TVpAllDayEventAttributes.SetBackGroundColor(Value: TColor); -begin - FBackgroundColor := Value; - FOwner.Invalidate; -end; - -procedure TVpAllDayEventAttributes.SetEventBackgroundColor(Value: TColor); -begin - FEventBackgroundColor := Value; - FOwner.Invalidate; -end; - -procedure TVpAllDayEventAttributes.SetEventBorderColor(Value: TColor); -begin - FEventBorderColor := Value; - FOwner.Invalidate; -end; - -procedure TVpAllDayEventAttributes.SetFont(Value: TVpFont); -begin - FFont.Assign(Value); - FFont.Owner := FOwner; -end; - - (*****************************************************************************) { TVpDayViewIconAttributes } - constructor TVpDayViewIconAttributes.Create(AOwner: TVpLinkableControl); begin inherited Create; @@ -873,13 +805,11 @@ begin { set up fonts and colors } FHeadAttr.Font.Size := 10; FHeadAttr.Font.Style := []; - FHeadAttr.Color := clBtnFace; FRowHeadAttr.FHourFont.Size := 18; FRowHeadAttr.FHourFont.Style := []; FRowHeadAttr.FMinuteFont.Size := 9; FRowHeadAttr.FMinuteFont.Style := []; - FRowHeadAttr.Color := clBtnFace; {$IFNDEF LCL} FHeadAttr.Font.Name := 'Tahoma'; FRowHeadAttr.FHourFont.Name := 'Tahoma'; @@ -2835,6 +2765,7 @@ begin inherited Create; FOwner := AOwner; FFont := TVpFont.Create(AOwner); + FColor := DEFAULT_HEADERCOLOR; end; destructor TVpCHAttributes.Destroy; @@ -2847,7 +2778,7 @@ procedure TVpCHAttributes.SetColor(const Value: TColor); begin if FColor <> Value then begin FColor := Value; - FOwner.Invalidate; + UpdateDateView; end; end; @@ -2856,6 +2787,12 @@ begin FFont.Assign(Value); end; +procedure TVpCHAttributes.UpdateDateView; +begin + if Assigned(FOwner) then + FOwner.Invalidate; +end; + (*****************************************************************************) { TVpRHAttributes } @@ -2866,10 +2803,7 @@ begin FOwner := AOwner; FHourFont := TVpFont.Create(AOwner); FMinuteFont := TVpFont.Create(AOwner); - {$IFNDEF LCL} - FHourFont.Name := 'Tahoma'; - FMinuteFont.Name := 'Tahoma'; - {$ENDIF} + FColor := DEFAULT_HEADERCOLOR; end; destructor TVpRHAttributes.Destroy; @@ -2883,7 +2817,7 @@ procedure TVpRHAttributes.SetColor(const Value: TColor); begin if FColor <> Value then begin FColor := Value; - FOwner.Invalidate; + UpdateDayView; end; end; @@ -2891,7 +2825,7 @@ procedure TVpRHAttributes.SetHourFont(Value: TVpFont); begin if Value <> FHourFont then begin FHourFont.Assign(Value); - FOwner.Invalidate; + UpdateDayView; end; end; @@ -2899,8 +2833,14 @@ procedure TVpRHAttributes.SetMinuteFont(Value: TVpFont); begin if Value <> FMinuteFont then begin FMinuteFont.Assign(Value); - FOwner.Invalidate; + UpdateDayView; end; end; +procedure TVpRHAttributes.UpdateDayView; +begin + if FOwner <> nil then + FOwner.Invalidate; +end; + end. diff --git a/components/tvplanit/source/vpganttview.pas b/components/tvplanit/source/vpganttview.pas index fa068b359..45c1a0207 100644 --- a/components/tvplanit/source/vpganttview.pas +++ b/components/tvplanit/source/vpganttview.pas @@ -48,38 +48,37 @@ type FColor: TColor; procedure SetColor(AValue: TColor); protected - procedure FontChanged(Sender: TObject); procedure UpdateGanttView; public constructor Create(AOwner: TVpGanttView); virtual; published - property Color: TColor read FColor write SetColor default clBtnFace; + property Color: TColor read FColor write SetColor default DEFAULT_HEADERCOLOR; end; TVpGanttRowHeaderAttributes = class(TVpGanttHeaderAttributes) private - FEventFont: TFont; - procedure SetEventFont(AValue: TFont); + FEventFont: TVpFont; + procedure SetEventFont(AValue: TVpFont); protected public constructor Create(AOwner: TVpGanttView); override; destructor Destroy; override; published - property EventFont: TFont read FEventFont write SetEventFont; + property EventFont: TVpFont read FEventFont write SetEventFont; end; TVpGanttColHeaderAttributes = class(TVpGanttHeaderAttributes) private - FDayFont: TFont; - FMonthFont: TFont; - procedure SetDayFont(AValue: TFont); - procedure SetMonthFont(AValue: TFont); + FDayFont: TVpFont; + FMonthFont: TVpFont; + procedure SetDayFont(AValue: TVpFont); + procedure SetMonthFont(AValue: TVpFont); public constructor Create(AOwner: TVpGanttView); override; destructor Destroy; override; published - property DayFont: TFont read FDayFont write SetDayFont; - property MonthFont: TFont read FMonthFont write SetMonthFont; + property DayFont: TVpFont read FDayFont write SetDayFont; + property MonthFont: TVpFont read FMonthFont write SetMonthFont; end; TVpGanttView = class(TVpLinkableControl) @@ -343,12 +342,7 @@ constructor TVpGanttHeaderAttributes.Create(AOwner: TVpGanttView); begin inherited Create; FGanttView := AOwner; - FColor := clBtnFace; -end; - -procedure TVpGanttHeaderAttributes.FontChanged(Sender: TObject); -begin - UpdateGanttView; + FColor := DEFAULT_HEADERCOLOR; end; procedure TVpGanttHeaderAttributes.SetColor(AValue: TColor); @@ -373,8 +367,7 @@ end; constructor TVpGanttRowHeaderAttributes.Create(AOwner: TVpGanttView); begin inherited Create(AOwner); - FEventFont := TFont.Create; - FEventFont.OnChange := @FontChanged; + FEventFont := TVpFont.Create(AOwner); end; destructor TVpGanttRowHeaderAttributes.Destroy; @@ -383,11 +376,12 @@ begin inherited; end; -procedure TVpGanttRowHeaderAttributes.SetEventFont(AValue: TFont); +procedure TVpGanttRowHeaderAttributes.SetEventFont(AValue: TVpFont); begin if FEventFont <> AValue then begin FEventFont := AValue; + FEventFont.Owner := FGanttView; UpdateGanttView; end; end; @@ -399,10 +393,8 @@ end; constructor TVpGanttColHeaderAttributes.Create(AOwner: TVpGanttView); begin inherited Create(AOwner); - FDayFont := TFont.Create; - FDayFont.OnChange := @FontChanged; - FMonthFont := TFont.Create; - FMonthFont.OnChange := @FontChanged; + FDayFont := TVpFont.Create(AOwner); + FMonthFont := TVpFont.Create(AOwner); end; destructor TVpGanttColHeaderAttributes.Destroy; @@ -412,20 +404,22 @@ begin inherited; end; -procedure TVpGanttColHeaderAttributes.SetDayFont(AValue: TFont); +procedure TVpGanttColHeaderAttributes.SetDayFont(AValue: TVpFont); begin if FDayFont <> AValue then begin FDayFont := AValue; + FDayFont.Owner := FGanttView; UpdateGanttView; end; end; -procedure TVpGanttColHeaderAttributes.SetMonthFont(AValue: TFont); +procedure TVpGanttColHeaderAttributes.SetMonthFont(AValue: TVpFont); begin if FMonthFont <> AValue then begin FMonthFont := AValue; + FMonthFont.Owner := FGanttView; UpdateGanttView; end; end; diff --git a/components/tvplanit/source/vpmonthview.pas b/components/tvplanit/source/vpmonthview.pas index 7dd162eb4..8965c865c 100644 --- a/components/tvplanit/source/vpmonthview.pas +++ b/components/tvplanit/source/vpmonthview.pas @@ -69,13 +69,15 @@ type FFont: TVpFont; procedure SetColor(AValue: TColor); procedure SetFont(AValue: TVpFont); + protected + procedure UpdateMonthView; public constructor Create(AOwner: TVpMonthView); destructor Destroy; override; property MonthView: TVpMonthView read FMonthVIew; published property Font: TVpFont read FFont write SetFont; - property Color: TColor read FColor write SetColor; + property Color: TColor read FColor write SetColor default DEFAULT_HEADERCOLOR; end; TVpMvHolidayAttr = class(TVpMonthViewAttr) @@ -390,7 +392,7 @@ constructor TVpMonthViewAttr.Create(AOwner: TVpMonthView); begin inherited Create; FMonthView := AOwner; - FColor := clBtnFace; + FColor := DEFAULT_HEADERCOLOR; FFont := TVpFont.Create(AOwner); end; @@ -404,13 +406,21 @@ procedure TVpMonthViewAttr.SetColor(AValue: TColor); begin if FColor <> AValue then begin FColor := AValue; - FMonthView.Invalidate; + UpdateMonthView; end; end; procedure TVpMonthViewAttr.SetFont(AValue: TVpFont); begin FFont.Assign(AValue); + FFont.Owner := FMonthView; + UpdateMonthView; +end; + +procedure TVpMonthViewAttr.UpdateMonthView; +begin + if Assigned(FMonthView) then + FMonthView.Invalidate; end; diff --git a/components/tvplanit/source/vpmonthviewpainter.pas b/components/tvplanit/source/vpmonthviewpainter.pas index 83d09b1d4..b10c8d952 100644 --- a/components/tvplanit/source/vpmonthviewpainter.pas +++ b/components/tvplanit/source/vpmonthviewpainter.pas @@ -272,8 +272,6 @@ begin dhRect.Right := RealRight; dhRect.Bottom := dhRect.Top + FDayHeadHeight; if FMonthView.DrawingStyle = ds3d then begin - //OffsetRect(dhRect, 0, 2); - inc(dhRect.Left, 2); inc(dhRect.Top, 2); dec(dhRect.Right, 2); diff --git a/components/tvplanit/source/vptasklist.pas b/components/tvplanit/source/vptasklist.pas index 590a56b23..5e3b8e6db 100644 --- a/components/tvplanit/source/vptasklist.pas +++ b/components/tvplanit/source/vptasklist.pas @@ -78,9 +78,9 @@ type procedure SetOverdueColor(Value: TColor); procedure SetNormalColor(Value: TColor); procedure SetCompletedColor(Value: TColor); + procedure UpdateTaskList; public - constructor Create(Owner: TVpTaskList); - destructor Destroy; override; + constructor Create(AOwner: TVpTaskList); published property CheckBGColor: TColor read FCheckBGColor write SetCheckBGColor default clWindow; property CheckColor: TColor read FCheckColor write SetCheckColor default cl3DDkShadow; @@ -104,7 +104,7 @@ type // procedure Move(const Loc: TRect; Redraw: Boolean); end; - TVpTaskHeadAttr = class(TVpPersistent) + TVpTaskHeadAttr = class(TPersistent) private FTaskList: TVpTaskList; FFont: TVpFont; @@ -114,12 +114,10 @@ type procedure SetFont(Value: TVpFont); procedure SetGlyphDist(Value: Integer); protected - + procedure UpdateTaskList; public constructor Create(AOwner: TVpTaskList); destructor Destroy; override; - procedure Invalidate; override; - { The Invalidate method is used as a bridge between FFont & FTaskList. } property TaskList: TVpTaskList read FTaskList; published property Color: TColor read FColor write SetColor default clBtnFace; @@ -294,10 +292,10 @@ uses (*****************************************************************************) { TVpTaskDisplayOptions } (*****************************************************************************) -constructor TVpTaskDisplayOptions.Create(Owner: TVpTaskList); +constructor TVpTaskDisplayOptions.Create(AOwner: TVpTaskList); begin inherited Create; - FTaskList := Owner; + FTaskList := AOwner; FDueDateFormat := DefaultFormatSettings.ShortDateFormat; FShowDueDate := true; FCheckColor := cl3DDkShadow; @@ -308,11 +306,6 @@ begin FNormalColor := clWindowText; end; -destructor TVpTaskDisplayOptions.Destroy; -begin - inherited; -end; - function TVpTaskDisplayOptions.IsStoredDueDateFormat: Boolean; begin Result := FDueDateFormat <> DefaultFormatSettings.ShortDateFormat; @@ -322,7 +315,7 @@ procedure TVpTaskDisplayOptions.SetOverdueColor(Value : TColor); begin if FOverdueColor <> Value then begin FOverdueColor := Value; - FTaskList.Invalidate; + UpdateTaskList; end; end; @@ -330,7 +323,7 @@ procedure TVpTaskDisplayOptions.SetNormalColor(Value: TColor); begin if FNormalColor <> Value then begin FNormalColor := Value; - FTaskList.Invalidate; + UpdateTaskList; end; end; @@ -338,7 +331,7 @@ procedure TVpTaskDisplayOptions.SetCompletedColor(Value: TColor); begin if FCompletedColor <> Value then begin FCompletedColor := Value; - FTaskList.Invalidate; + UpdateTaskList; end; end; @@ -346,7 +339,7 @@ procedure TVpTaskDisplayOptions.SetCheckColor(Value: TColor); begin if FCheckColor <> Value then begin FCheckColor := Value; - FTaskList.Invalidate; + UpdateTaskList; end; end; @@ -354,7 +347,7 @@ procedure TVpTaskDisplayOptions.SetCheckBGColor(Value: TColor); begin if FCheckBGColor <> Value then begin FCheckBGColor := Value; - FTaskList.Invalidate; + UpdateTaskList; end; end; @@ -362,7 +355,7 @@ procedure TVpTaskDisplayOptions.SetCheckStyle(Value: TVpCheckStyle); begin if Value <> FCheckStyle then begin FCheckStyle := Value; - FTaskList.Invalidate; + UpdateTaskList; end; end; @@ -370,7 +363,7 @@ procedure TVpTaskDisplayOptions.SetDueDateFormat(Value: string); begin if FDueDateFormat <> Value then begin FDueDateFormat := Value; - FTaskList.Invalidate; + UpdateTaskList; end; end; @@ -378,7 +371,7 @@ procedure TVpTaskDisplayOptions.SetShowCompleted(Value : Boolean); begin if FShowCompleted <> Value then begin FShowCompleted := Value; - FTaskList.Invalidate; + UpdateTaskList; end; end; @@ -386,7 +379,7 @@ procedure TVpTaskDisplayOptions.SetShowDueDate(Value: Boolean); begin if FShowDueDate <> Value then begin FShowDueDate := Value; - FTaskList.Invalidate; + UpdateTaskList; end; end; @@ -394,10 +387,16 @@ procedure TVpTaskDisplayOptions.SetShowAll(Value: Boolean); begin if FShowAll <> Value then begin FShowAll := Value; - FTaskList.Invalidate; + UpdateTaskList; end; end; +procedure TVpTaskDisplayOptions.UpdateTaskList; +begin + if FTaskList <> nil then + FTaskList.Invalidate; +end; + (******************************************************************************) { TVpTaskHeadAttr } @@ -406,7 +405,7 @@ constructor TVpTaskHeadAttr.Create(AOwner: TVpTaskList); begin inherited Create; FTaskList := AOwner; - FFont := TVpFont.Create(self); + FFont := TVpFont.Create(AOwner); FFont.Assign(FTaskList.Font); FColor := clBtnFace; FGlyphDist := 10; @@ -417,17 +416,11 @@ begin FFont.Free; end; -procedure TVpTaskHeadAttr.Invalidate; -begin - if Assigned(FTaskList) then - FTaskList.Invalidate; -end; - procedure TVpTaskHeadAttr.SetColor(Value: TColor); begin if Value <> FColor then begin FColor := Value; - Invalidate; + UpdateTaskList; end; end; @@ -435,7 +428,8 @@ procedure TVpTaskHeadAttr.SetFont(Value: TVpFont); begin if Value <> FFont then begin FFont.Assign(Value); - Invalidate; + FFont.Owner := FTaskList; + UpdateTaskList; end; end; @@ -444,10 +438,16 @@ begin if Value <> FGlyphDist then begin FGlyphDist := Value; - Invalidate; + UpdateTaskList; end; end; +procedure TVpTaskHeadAttr.UpdateTaskList; +begin + if Assigned(FTaskList) then + FTaskList.Invalidate; +end; + (******************************************************************************) { TVpCGInPlaceEdit } diff --git a/components/tvplanit/source/vpweekview.pas b/components/tvplanit/source/vpweekview.pas index 8b5216775..cdde859f1 100644 --- a/components/tvplanit/source/vpweekview.pas +++ b/components/tvplanit/source/vpweekview.pas @@ -84,26 +84,33 @@ type constructor Create(AOwner: TComponent); override; end; - TVpWvHeadAttributes = class(TPersistent) + TVpWvAttributes = class(TPersistent) private FOwner: TVpWeekView; + protected + procedure UpdateWeekView; + public + constructor Create(AOwner: TVpWeekView); virtual; + property Owner: TVpWeekView read FOwner; + end; + + TVpWvHeadAttributes = class(TVpWvAttributes) + private FColor: TColor; FFont: TVpFont; procedure SetColor(const Value: TColor); procedure SetFont(Value: TVpFont); protected public - constructor Create(AOwner: TVpWeekView); + constructor Create(AOwner: TVpWeekView); override; destructor Destroy; override; - property Owner: TVpWeekView read FOwner; published property Font: TVpFont read FFont write SetFont; - property Color: TColor read FColor write SetColor; + property Color: TColor read FColor write SetColor default DEFAULT_HEADERCOLOR; end; - TVpDayHeadAttr = class(TPersistent) + TVpWvDayHeadAttr = class(TVpWvAttributes) private - FWeekView: TVpWeekView; FFont: TVpFont; FDateFormat: string; FColor: TColor; @@ -117,13 +124,12 @@ type procedure SetFont(Value: TVpFont); protected public - constructor Create(AOwner: TVpWeekView); + constructor Create(AOwner: TVpWeekView); override; destructor Destroy; override; - property WeekView: TVpWeekView read FWeekView; published property Alignment: TAlignment read FAlignment write SetAlignment default taRightJustify; property Bordered: Boolean read FBordered write SetBordered default true; - property Color: TColor read FColor write SetColor default DEFAULT_COLOR; + property Color: TColor read FColor write SetColor default DEFAULT_HEADERCOLOR; property DateFormat: string read FDateFormat write SetDateFormat stored IsStoredDateFormat; property Font: TVpFont read FFont write SetFont; end; @@ -141,7 +147,7 @@ type FColor: TColor; FComponentHint: TTranslateString; FDateLabelFormat: string; - FDayHeadAttributes: TVpDayHeadAttr; + FDayHeadAttributes: TVpWvDayHeadAttr; FDefaultPopup: TPopupMenu; FDragDropTransparent: Boolean; FDrawingStyle: TVpDrawingStyle; @@ -336,7 +342,7 @@ type property ApplyCategoryInfos: Boolean read FApplyCategoryInfos write SetApplyCategoryInfos default false; property Color: TColor read FColor write SetColor default DEFAULT_COLOR; property DateLabelFormat: string read FDateLabelFormat write SetDateLabelFormat stored IsStoredDateLabelFormat; - property DayHeadAttributes: TVpDayHeadAttr read FDayHeadAttributes write FDayHeadAttributes; + property DayHeadAttributes: TVpWvDayHeadAttr read FDayHeadAttributes write FDayHeadAttributes; property DragDropTransparent: Boolean read FDragDropTransparent write FDragDropTransparent default false; property DrawingStyle: TVpDrawingStyle read FDrawingStyle write SetDrawingStyle default ds3d; property EventFont: TVpFont read FEventFont write SetEventFont; @@ -440,68 +446,85 @@ end; (*****************************************************************************) -{ TVpContactHeadAttr } +{ TVpWvAttributes } (*****************************************************************************) - -constructor TVpDayHeadAttr.Create(AOwner: TVpWeekView); +constructor TVpWvAttributes.Create(AOwner: TVpWeekView); begin inherited Create; - FWeekView := AOwner; + FOwner := AOwner; +end; + +procedure TVpWvAttributes.UpdateWeekView; +begin + if FOwner <> nil then + FOwner.Invalidate; +end; + + +(*****************************************************************************) +{ TVpWvDayHeadAttr } +(*****************************************************************************) + +constructor TVpWvDayHeadAttr.Create(AOwner: TVpWeekView); +begin + inherited Create(AOwner); FDateFormat := 'ddddd'; FFont := TVpFont.Create(AOwner); - FColor := DEFAULT_COLOR; + FColor := DEFAULT_HEADERCOLOR; FBordered := true; FAlignment := taRightJustify; end; -destructor TVpDayHeadAttr.Destroy; +destructor TVpWvDayHeadAttr.Destroy; begin FFont.Free; + inherited; end; -function TVpDayHeadAttr.IsStoredDateFormat: Boolean; +function TVpWvDayHeadAttr.IsStoredDateFormat: Boolean; begin Result := FDateFormat = 'ddddd'; end; -procedure TVpDayHeadAttr.SetAlignment(Value: TAlignment); +procedure TVpWvDayHeadAttr.SetAlignment(Value: TAlignment); begin if Value <> FAlignment then begin FAlignment := Value; - WeekView.Invalidate; + UpdateWeekView; end; end; -procedure TVpDayHeadAttr.SetBordered(Value: Boolean); +procedure TVpWvDayHeadAttr.SetBordered(Value: Boolean); begin if Value <> FBordered then begin FBordered := Value; - WeekView.Invalidate; + UpdateWeekView; end; end; -procedure TVpDayHeadAttr.SetDateFormat(Value: string); +procedure TVpWvDayHeadAttr.SetDateFormat(Value: string); begin if Value <> FDateFormat then begin FDateFormat := Value; - WeekView.Invalidate; + UpdateWeekView; end; end; -procedure TVpDayHeadAttr.SetColor(Value: TColor); +procedure TVpWvDayHeadAttr.SetColor(Value: TColor); begin if Value <> FColor then begin FColor := Value; - WeekView.Invalidate; + UpdateWeekView; end; end; -procedure TVpDayHeadAttr.SetFont(Value: TVpFont); +procedure TVpWvDayHeadAttr.SetFont(Value: TVpFont); begin if Value <> FFont then begin FFont.Assign(Value); - WeekView.Invalidate; + FFont.Owner := FOwner; + UpdateWeekView; end; end; @@ -509,12 +532,10 @@ end; (*****************************************************************************) { TVpWvHeadAttributes } (*****************************************************************************) - constructor TVpWvHeadAttributes.Create(AOwner: TVpWeekView); begin - inherited Create; - FOwner := AOwner; - FColor := clBtnFace; + inherited Create(AOwner); + FColor := DEFAULT_HEADERCOLOR; FFont := TVpFont.Create(AOwner); end; @@ -528,13 +549,15 @@ procedure TVpWvHeadAttributes.SetColor(const Value: TColor); begin if FColor <> Value then begin FColor := Value; - FOwner.Invalidate; + UpdateWeekView; end; end; procedure TVpWvHeadAttributes.SetFont(Value: TVpFont); begin FFont.Assign(Value); + FFont.Owner := FOwner; + UpdateWeekView; end; @@ -549,7 +572,7 @@ begin HintWindowClass := TVpHintWindow; { Create internal classes and stuff } - FDayHeadAttributes := TVpDayHeadAttr.Create(self); + FDayHeadAttributes := TVpWvDayHeadAttr.Create(self); FHeadAttr := TVpWvHeadAttributes.Create(self); FAllDayEventAttr := TVpAllDayEventAttributes.Create(self); @@ -615,8 +638,8 @@ begin { set up fonts and colors } FDayHeadAttributes.Font.Size := 10; FDayHeadAttributes.Font.Style := []; - FDayHeadAttributes.Color := clBtnFace; FDayHeadAttributes.Bordered := true; + FAllDayEventAttr.Font.Assign (Font); SetLength(wvEventArray, MaxVisibleEvents); SetLength(wvWeekdayArray, 7); @@ -630,11 +653,6 @@ begin InitializeDefaultPopup; Self.PopupMenu := FDefaultPopup; - FAllDayEventAttr.BackgroundColor := Color; - FAllDayEventAttr.EventBackgroundColor := clBtnFace; - FAllDayEventAttr.EventBorderColor := LineColor; - FAllDayEventAttr.Font.Assign (Font); - LoadLanguage; wvHookUp; diff --git a/components/tvplanit/source/vpweekviewpainter.pas b/components/tvplanit/source/vpweekviewpainter.pas index 508106d9e..1528d7655 100644 --- a/components/tvplanit/source/vpweekviewpainter.pas +++ b/components/tvplanit/source/vpweekviewpainter.pas @@ -166,7 +166,8 @@ begin totalHeight := numADEvents * ADTextHeight + txtDist * 2; ADEventsRect.Bottom := Min(ADEventsRect.Top + totalHeight, DayRect.Bottom); - // Clear the AllDayEvents area + // Clear the AllDayEvents area using its background color + RenderCanvas.Brush.Color := ADBackgroundColor; TpsFillRect(RenderCanvas, Angle, RenderIn, ADEventsRect); startsBeforeRange := false;