diff --git a/components/tvplanit/examples/fulldemo/demomain.lfm b/components/tvplanit/examples/fulldemo/demomain.lfm index ebeefe3fb..f56f708db 100644 --- a/components/tvplanit/examples/fulldemo/demomain.lfm +++ b/components/tvplanit/examples/fulldemo/demomain.lfm @@ -52,20 +52,15 @@ object MainForm: TMainForm DataStore = VpBufDSDataStore1 ControlLink = VpControlLink1 Color = clWindow - Font.Height = -12 - ParentFont = False Align = alBottom TabStop = True TabOrder = 0 KBNavigation = True DateLabelFormat = 'mmmm yyyy' DayHeadAttributes.Color = clBtnFace - DayHeadAttributes.Font.Height = -13 DayNameStyle = dsShort - DayNumberFont.Height = -12 DrawingStyle = dsFlat EventDayStyle = [fsItalic] - EventFont.Height = -12 LineColor = clGray TimeFormat = tf12Hour OffDayColor = clSilver @@ -91,8 +86,6 @@ object MainForm: TMainForm DataStore = VpBufDSDataStore1 ControlLink = VpControlLink1 Color = clWindow - Font.Height = -12 - ParentFont = False ParentShowHint = False Align = alClient ReadOnly = False @@ -111,10 +104,8 @@ object MainForm: TMainForm TimeSlotColors.Weekend = 14737632 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 IconAttributes.AlarmBitmap.Data = { 76020000424D760200000000000036000000280000000C0000000C0000000100 @@ -245,8 +236,6 @@ object MainForm: TMainForm DataStore = VpBufDSDataStore1 ControlLink = VpControlLink1 Color = clWindow - Font.Height = -12 - ParentFont = False AllDayEventAttributes.BackgroundColor = clWindow AllDayEventAttributes.EventBorderColor = clGray AllDayEventAttributes.EventBackgroundColor = clBtnFace @@ -254,11 +243,8 @@ object MainForm: TMainForm DateLabelFormat = 'dddd, mmmm dd, yyyy' DayHeadAttributes.Color = clBtnFace DayHeadAttributes.DateFormat = 'dddd mmmm, dd' - DayHeadAttributes.Font.Height = -13 DayHeadAttributes.Bordered = True DrawingStyle = dsFlat - EventFont.Height = -12 - HeadAttributes.Font.Height = -12 HeadAttributes.Color = clBtnFace LineColor = clGray TimeFormat = tf12Hour @@ -313,8 +299,6 @@ object MainForm: TMainForm DataStore = VpBufDSDataStore1 ControlLink = VpControlLink1 Color = clWindow - Font.Height = -12 - ParentFont = False Align = alClient TabStop = True TabOrder = 1 @@ -332,7 +316,6 @@ object MainForm: TMainForm LineColor = clGray MaxVisibleTasks = 250 TaskHeadAttributes.Color = clSilver - TaskHeadAttributes.Font.Height = -12 DrawingStyle = ds3d ShowResourceName = True end diff --git a/components/tvplanit/source/vpcalendarpainter.pas b/components/tvplanit/source/vpcalendarpainter.pas index c890d7b8f..8123565b0 100644 --- a/components/tvplanit/source/vpcalendarpainter.pas +++ b/components/tvplanit/source/vpcalendarpainter.pas @@ -39,6 +39,7 @@ type procedure DrawDayNames; procedure DrawFocusBox; procedure DrawLine; + procedure FixFontHeights; procedure InitColors; procedure SetMeasurements; override; @@ -248,6 +249,14 @@ begin until DOW = FCalendar.WeekStarts; end; +procedure TVpCalendarPainter.FixFontHeights; +begin + with TVpCalendarOpener(FCalendar) do begin + Font.Height := GetRealFontHeight(Font); + calRebuildCalArray(RenderDate); + end; +end; + procedure TVpCalendarPainter.InitColors; begin if DisplayOnly then begin @@ -364,11 +373,7 @@ begin InitColors; SavePenBrush; InitPenBrush; - - with TVpCalendarOpener(FCalendar) do begin - Font.Height := GetRealFontHeight(Font); - calRebuildCalArray(RenderDate); - end; + if ADisplayOnly then FixFontHeights; RenderCanvas.Lock; try diff --git a/components/tvplanit/source/vpcontactgrid.pas b/components/tvplanit/source/vpcontactgrid.pas index 82425eddb..78937e24f 100644 --- a/components/tvplanit/source/vpcontactgrid.pas +++ b/components/tvplanit/source/vpcontactgrid.pas @@ -91,19 +91,19 @@ type TVpContactHeadAttr = class(TPersistent) protected{private} FGrid: TVpContactGrid; - FFont: TFont; + FFont: TVpFont; FColor: TColor; FBordered: Boolean; - procedure SetColor (Value: TColor); - procedure SetFont (Value: TFont); - procedure SetBordered (Value: Boolean); + procedure SetColor(Value: TColor); + procedure SetFont(Value: TVpFont); + procedure SetBordered(Value: Boolean); public constructor Create(AOwner: TVpContactGrid); destructor Destroy; override; property Grid: TVpContactGrid read FGrid; published property Color: TColor read FColor write SetColor; - property Font: TFont read FFont write SetFont; + property Font: TVpFont read FFont write SetFont; property Bordered: Boolean read FBordered write SetBordered; end; @@ -274,11 +274,11 @@ uses constructor TVpContactHeadAttr.Create(AOwner: TVpContactGrid); begin inherited Create; - FGrid := AOwner; - FFont := TFont.Create; + FGrid := AOwner; + FFont := TVpFont.Create(AOwner); FFont.Assign(FGrid.Font); - FColor := clSilver; - FBordered := true; + FColor := clSilver; + FBordered := true; end; {=====} @@ -306,7 +306,7 @@ begin end; {=====} -procedure TVpContactHeadAttr.SetFont(Value: TFont); +procedure TVpContactHeadAttr.SetFont(Value: TVpFont); begin if Value <> FFont then begin FFont.Assign(Value); @@ -661,17 +661,17 @@ var SaveFont: TFont; Temp: Integer; begin - { Calculates row height based on the largest of the RowHead's Minute } - { font, the standard client font, and a sample character string. } + { Calculates row height based on the largest of the RowHead's Minute font, + the standard client font, and a sample character string. } SaveFont := Canvas.Font; - Canvas.Font := FContactHeadAttr.Font; + Canvas.Font.Assign(FContactHeadAttr.Font); cgRowHeight := Canvas.TextHeight(TallShortChars); Canvas.Font.Assign(SaveFont); Temp := Canvas.TextHeight(TallShortChars); if Temp > cgRowHeight then cgRowHeight := Temp; cgRowHeight := cgRowHeight + TextMargin * 2; - Canvas.Font := SaveFont; + Canvas.Font.Assign(SaveFont); end; {=====} diff --git a/components/tvplanit/source/vpcontactgridpainter.pas b/components/tvplanit/source/vpcontactgridpainter.pas index 9df4a3f88..f0b3d266f 100644 --- a/components/tvplanit/source/vpcontactgridpainter.pas +++ b/components/tvplanit/source/vpcontactgridpainter.pas @@ -33,6 +33,7 @@ type var AWholeRect, ATextRect: TRect); procedure DrawContacts; procedure DrawVerticalBars; + procedure FixFontHeights; procedure InitColors; public @@ -1741,6 +1742,14 @@ begin end; end; +procedure TVpContactGridPainter.FixFontHeights; +begin + with FContactGrid do begin + ContactHeadAttributes.Font.Height := GetRealFontHeight(ContactHeadAttributes.Font); + Font.Height := GetRealFontHeight(Font); + end; +end; + procedure TVpContactGridPainter.InitColors; begin if DisplayOnly then begin @@ -1775,11 +1784,7 @@ begin InitColors; SavePenBrush; InitPenBrush; - - with FContactGrid do begin - ContactHeadAttributes.Font.Height := GetRealFontHeight(ContactHeadAttributes.Font); - Font.Height := GetRealFontHeight(Font); - end; + if ADisplayOnly then FixFontHeights; Rgn := CreateRectRgn(RenderIn.Left, RenderIn.Top, RenderIn.Right, RenderIn.Bottom); try diff --git a/components/tvplanit/source/vpdayviewpainter.pas b/components/tvplanit/source/vpdayviewpainter.pas index cc5eac43d..1d673d408 100644 --- a/components/tvplanit/source/vpdayviewpainter.pas +++ b/components/tvplanit/source/vpdayviewpainter.pas @@ -1718,7 +1718,7 @@ begin SavePenBrush; InitPenBrush; InitializeEventRectangles; - FixFontHeights; + if ADisplayOnly then FixFontHeights; SetMeasurements; diff --git a/components/tvplanit/source/vpmonthview.pas b/components/tvplanit/source/vpmonthview.pas index c93ca21d4..4269926a5 100644 --- a/components/tvplanit/source/vpmonthview.pas +++ b/components/tvplanit/source/vpmonthview.pas @@ -62,17 +62,17 @@ type TVpDayHeadAttr = class(TPersistent) protected{private} FMonthView: TVpMonthView; - FFont: TFont; + FFont: TVpFont; FColor: TColor; - procedure SetColor (Value: TColor); - procedure SetFont (Value: TFont); + procedure SetColor(Value: TColor); + procedure SetFont(Value: TVpFont); public constructor Create(AOwner: TVpMonthView); destructor Destroy; override; property MonthView: TVpMonthView read FMonthView; published property Color: TColor read FColor write SetColor; - property Font: TFont read FFont write SetFont; + property Font: TVpFont read FFont write SetFont; end; { TVpMonthView } @@ -96,8 +96,8 @@ type FShowEventTime : Boolean; FTopLine : Integer; FDayHeadAttributes : TVpDayHeadAttr; - FDayNumberFont : TFont; - FEventFont : TFont; + FDayNumberFont : TVpFont; + FEventFont : TVpFont; FTimeFormat : TVpTimeFormat; FDrawingStyle : TVpDrawingStyle; FDate : TDateTime; @@ -138,8 +138,8 @@ type procedure SetShowEvents(Value: Boolean); procedure SetEventDayStyle(Value: TFontStyles); procedure SetDayNameStyle(Value: TVpMVDayNameStyle); - procedure SetDayNumberFont(Value: TFont); - procedure SetEventFont(Value: TFont); + procedure SetDayNumberFont(Value: TVpFont); + procedure SetEventFont(Value: TVpFont); procedure SetSelectedDayColor(Value: TColor); procedure SetShowEventTime(Value: Boolean); procedure SetTimeFormat(Value: TVpTimeFormat); @@ -148,7 +148,7 @@ type procedure SetWeekStartsOn(Value: TVpDayType); { internal methods } procedure mvHookUp; - procedure mvFontChanged(Sender: TObject); +// procedure mvFontChanged(Sender: TObject); procedure Paint; override; procedure Loaded; override; @@ -229,13 +229,13 @@ type read FDayHeadAttributes write FDayHeadAttributes; property DayNameStyle: TVpMVDayNameStyle read FDayNameStyle write SetDayNameStyle; - property DayNumberFont: TFont + property DayNumberFont: TVpFont read FDayNumberFont write SetDayNumberFont; property DrawingStyle: TVpDrawingStyle read FDrawingStyle write SetDrawingStyle stored True; property EventDayStyle: TFontStyles read FEventDayStyle write SetEventDayStyle; - property EventFont: TFont + property EventFont: TVpFont read FEventFont write SetEventFont; property LineColor: TColor read FLineColor write SetLineColor; @@ -276,7 +276,7 @@ constructor TVpDayHeadAttr.Create(AOwner: TVpMonthView); begin inherited Create; FMonthView := AOwner; - FFont := TFont.Create; + FFont := TVpFont.Create(AOwner); FFont.Assign(FMonthView.Font); FColor := clSilver; end; @@ -285,6 +285,7 @@ end; destructor TVpDayHeadAttr.Destroy; begin FFont.Free; + inherited; end; {=====} @@ -297,7 +298,7 @@ begin end; {=====} -procedure TVpDayHeadAttr.SetFont(Value: TFont); +procedure TVpDayHeadAttr.SetFont(Value: TVpFont); begin if Value <> FFont then begin FFont.Assign(Value); @@ -354,12 +355,12 @@ begin FDayHeadAttributes.Color := clBtnFace; { Assign default font to DayNumberFont and EventFont } - FDayNumberFont := TFont.Create; + FDayNumberFont := TVpFont.Create(AOwner); FDayNumberFont.Assign(Font); - FDayNumberFont.OnChange := mvFontChanged; - FEventFont := TFont.Create; +// FDayNumberFont.OnChange := mvFontChanged; + FEventFont := TVpFont.Create(AOwner); FEventFont.Assign(Font); - FEventFont.OnChange := mvFontChanged; +// FEventFont.OnChange := mvFontChanged; FOffDayFontColor := clGray; SetLength(mvEventArray, MaxVisibleEvents); @@ -433,11 +434,11 @@ begin end; end; {=====} - + { procedure TVpMonthView.mvFontChanged(Sender: TObject); begin Invalidate; -end; +end; } {=====} procedure TVpMonthView.Loaded; @@ -609,14 +610,14 @@ begin end; {=====} -procedure TVpMonthView.SetDayNumberFont(Value: TFont); +procedure TVpMonthView.SetDayNumberFont(Value: TVpFont); begin FDayNumberFont.Assign(Value); Invalidate; end; {=====} -procedure TVpMonthView.SetEventFont(Value: TFont); +procedure TVpMonthView.SetEventFont(Value: TVpFont); begin FEventFont.Assign(Value); Invalidate; diff --git a/components/tvplanit/source/vpmonthviewpainter.pas b/components/tvplanit/source/vpmonthviewpainter.pas index c0eefafdd..f711a17d1 100644 --- a/components/tvplanit/source/vpmonthviewpainter.pas +++ b/components/tvplanit/source/vpmonthviewpainter.pas @@ -33,6 +33,7 @@ type procedure DrawDayHead; procedure DrawDays; procedure DrawHeader; + procedure FixFontHeights; procedure InitColors; procedure SetMeasurements; override; @@ -787,7 +788,16 @@ begin HeadTextRect.Top, // + TextMargin, HeadStr ); +end; +procedure TVpMonthViewPainter.FixFontHeights; +begin + with FMonthView do begin + DayHeadAttributes.Font.Height := GetRealFontHeight(DayHeadAttributes.Font); + DayNumberFont.Height := GetRealFontHeight(DayNumberFont); + EventFont.Height := GetRealFontHeight(EventFont); + Font.Height := GetRealFontHeight(Font); + end; end; procedure TVpMonthViewPainter.InitColors; @@ -827,13 +837,8 @@ begin InitColors; SavePenBrush; InitPenBrush; - - with FMonthView do begin - DayHeadAttributes.Font.Height := GetRealFontHeight(DayHeadAttributes.Font); - DayNumberFont.Height := GetRealFontHeight(DayNumberFont); - EventFont.Height := GetRealFontHeight(EventFont); - Font.Height := GetRealFontHeight(Font); - end; + if ADisplayOnly then + FixFontHeights; Rgn := CreateRectRgn(RenderIn.Left, RenderIn.Top, RenderIn.Right, RenderIn.Bottom); try diff --git a/components/tvplanit/source/vptasklist.pas b/components/tvplanit/source/vptasklist.pas index 9a228d310..d6fe014d1 100644 --- a/components/tvplanit/source/vptasklist.pas +++ b/components/tvplanit/source/vptasklist.pas @@ -106,10 +106,10 @@ type TVpTaskHeadAttr = class(TVpPersistent) protected{private} FTaskList: TVpTaskList; - FFont: TFont; + FFont: TVpFont; FColor: TColor; procedure SetColor(Value: TColor); - procedure SetFont(Value: TFont); + procedure SetFont(Value: TVpFont); public constructor Create(AOwner: TVpTaskList); destructor Destroy; override; @@ -118,7 +118,7 @@ type property TaskList: TVpTaskList read FTaskList; published property Color: TColor read FColor write SetColor; - property Font: TFont read FFont write SetFont; + property Font: TVpFont read FFont write SetFont; end; { Task List } @@ -403,7 +403,7 @@ begin end; {=====} -procedure TVpTaskHeadAttr.SetFont(Value: TFont); +procedure TVpTaskHeadAttr.SetFont(Value: TVpFont); begin if Value <> FFont then begin FFont.Assign(Value); @@ -669,14 +669,14 @@ begin { Calculates row height based on the largest of the RowHead's Minute } { font, the standard client font, and a sample character string. } SaveFont := Canvas.Font; - Canvas.Font := FTaskHeadAttr.Font; + Canvas.Font.Assign(FTaskHeadAttr.Font); tlRowHeight := Canvas.TextHeight(TallShortChars); Canvas.Font.Assign(SaveFont); Temp := Canvas.TextHeight(TallShortChars); if Temp > tlRowHeight then tlRowHeight := Temp; tlRowHeight := tlRowHeight + TextMargin * 2; - Canvas.Font := SaveFont; + Canvas.Font.Assign(SaveFont); end; {=====} diff --git a/components/tvplanit/source/vptasklistpainter.pas b/components/tvplanit/source/vptasklistpainter.pas index 590624de3..5cac99afb 100644 --- a/components/tvplanit/source/vptasklistpainter.pas +++ b/components/tvplanit/source/vptasklistpainter.pas @@ -44,6 +44,7 @@ type procedure DrawHeader; procedure DrawLines; procedure DrawTasks; + procedure FixFontHeights; procedure InitColors; procedure MeasureRowHeight; @@ -452,6 +453,14 @@ begin end; // with TVpTaskListOpener(FTaskList)... end; +procedure TVpTaskListPainter.FixFontHeights; +begin + with FTaskList do begin + Font.Height := GetRealFontHeight(Font); + TaskHeadAttributes.Font.Height := GetRealFontHeight(TaskHeadAttributes.Font); + end; +end; + procedure TVpTaskListPainter.InitColors; begin if DisplayOnly then begin @@ -504,11 +513,7 @@ begin InitColors; SavePenBrush; InitPenBrush; - - with FTaskList do begin - Font.Height := GetRealFontHeight(Font); - TaskHeadAttributes.Font.Height := GetRealFontHeight(TaskHeadAttributes.Font); - end; + if ADisplayOnly then FixFontHeights; Rgn := CreateRectRgn(RenderIn.Left, RenderIn.Top, RenderIn.Right, RenderIn.Bottom); try diff --git a/components/tvplanit/source/vpweekview.pas b/components/tvplanit/source/vpweekview.pas index b13d13c21..2adc3587d 100644 --- a/components/tvplanit/source/vpweekview.pas +++ b/components/tvplanit/source/vpweekview.pas @@ -95,12 +95,12 @@ type TVpDayHeadAttr = class(TPersistent) protected{private} FWeekView: TVpWeekView; - FFont: TFont; + FFont: TVpFont; FDateFormat: string; FColor: TColor; FBordered: Boolean; procedure SetColor(Value: TColor); - procedure SetFont(Value: TFont); + procedure SetFont(Value: TVpFont); procedure SetBordered(Value: Boolean); procedure SetDateFormat(Value: string); public @@ -110,7 +110,7 @@ type published property Color: TColor read FColor write SetColor; property DateFormat: string read FDateFormat write SetDateFormat; - property Font: TFont read FFont write SetFont; + property Font: TVpFont read FFont write SetFont; property Bordered: Boolean read FBordered write SetBordered; end; @@ -128,7 +128,7 @@ type FDrawingStyle: TVpDrawingStyle; FaActiveEvent: TVpEvent; FHeadAttr: TVpWvHeadAttributes; - FEventFont: TFont; + FEventFont: TVpFont; // was: TFont FLineColor: TColor; FLineCount: Integer; FTimeFormat: TVpTimeFormat; @@ -166,7 +166,7 @@ type procedure SetColor(Value: TColor); procedure SetLineColor(Value: TColor); procedure SetDateLabelFormat(Value: string); - procedure SetEventFont(Value: TFont); + procedure SetEventFont(Value: TVpFont); procedure SetShowEventTime(Value: Boolean); procedure SetTimeFormat(Value: TVpTimeFormat); procedure SetActiveDate(Value: TDateTime); @@ -240,7 +240,7 @@ type property DateLabelFormat: string read FDateLabelFormat write SetDateLabelFormat; property DayHeadAttributes: TVpDayHeadAttr read FDayHeadAttributes write FDayHeadAttributes; property DrawingStyle: TVpDrawingStyle read FDrawingStyle write SetDrawingStyle stored True; - property EventFont: TFont read FEventFont write SetEventFont; + property EventFont: TVpFont read FEventFont write SetEventFont; property HeadAttributes: TVpWvHeadAttributes read FHeadAttr write FHeadAttr; property LineColor: TColor read FLineColor write SetLineColor; property TimeFormat: TVpTimeFormat read FTimeFormat write SetTimeFormat; @@ -331,9 +331,9 @@ begin inherited Create; FWeekView := AOwner; FDateFormat := 'dddd mmmm, dd'; - FFont := TFont.Create; - FFont.Assign(FWeekView.Font); - FFont.Size := 8; + FFont := TVpFont.Create(AOwner); +// FFont.Assign(FWeekView.Font); +// FFont.Size := 8; FColor := clSilver; FBordered := true; end; @@ -372,7 +372,7 @@ begin end; {=====} -procedure TVpDayHeadAttr.SetFont(Value: TFont); +procedure TVpDayHeadAttr.SetFont(Value: TVpFont); begin if Value <> FFont then begin FFont.Assign(Value); @@ -394,7 +394,7 @@ begin FHeadAttr := TVpWvHeadAttributes.Create(self); FAllDayEventAttr := TVpAllDayEventAttributes.Create(self); - FEventFont := TFont.Create; + FEventFont := TVpFont.Create(self); FEventFont.Assign(Font); FShowEventTime := true; wvInLinkHandler := false; @@ -654,7 +654,7 @@ begin end; {=====} -procedure TVpWeekView.SetEventFont(Value: TFont); +procedure TVpWeekView.SetEventFont(Value: TVpFont); begin FEventFont.Assign(Value); Invalidate; diff --git a/components/tvplanit/source/vpweekviewpainter.pas b/components/tvplanit/source/vpweekviewpainter.pas index b7f816e6f..60a2ebb8c 100644 --- a/components/tvplanit/source/vpweekviewpainter.pas +++ b/components/tvplanit/source/vpweekviewpainter.pas @@ -653,7 +653,7 @@ begin InitColors; SavePenBrush; InitPenBrush; - FixFontHeights; + if ADisplayOnly then FixFontHeights; Rgn := CreateRectRgn(RenderIn.Left, RenderIn.Top, RenderIn.Right, RenderIn.Bottom); try