tvplanit: Some cleanup in TVpCanvasUtils. Fix Calendar font size being frozen at 8pt.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4893 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-07-02 09:43:47 +00:00
parent c4646eacb5
commit 5cd2174610
6 changed files with 30 additions and 45 deletions

View File

@ -58,6 +58,7 @@ object MainForm: TMainForm
KBNavigation = True
DateLabelFormat = 'mmmm yyyy'
DayHeadAttributes.Color = clBtnFace
DayHeadAttributes.Font.Height = -13
DayNameStyle = dsShort
DrawingStyle = dsFlat
EventDayStyle = [fsItalic]
@ -244,7 +245,6 @@ object MainForm: TMainForm
DayHeadAttributes.Color = clBtnFace
DayHeadAttributes.DateFormat = 'dddd mmmm, dd'
DayHeadAttributes.Font.Height = -13
DayHeadAttributes.Font.Name = 'Tahoma'
DayHeadAttributes.Bordered = True
DrawingStyle = dsFlat
HeadAttributes.Color = clBtnFace

View File

@ -8,7 +8,8 @@ uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
StdCtrls, ComCtrls, LCLTranslator, Menus,
VpBaseDS, VpDayView, VpWeekView, VpTaskList, VpAbout,
VpContactGrid, VpMonthView, VpResEditDlg, VpContactButtons, VpBufDS, VpNavBar;
VpContactGrid, VpMonthView, VpResEditDlg, VpContactButtons, VpBufDS, VpNavBar,
VpData;
type
@ -125,8 +126,8 @@ uses
{$IFDEF WINDOWS}
Windows,
{$ENDIF}
LResources, LazUTF8, LazFileUtils, StrUtils, Translations, IniFiles, Math,
VpMisc, VpBase, VpData;
LResources, LazFileUtils, LazUTF8, StrUtils, Translations, IniFiles, Math,
VpMisc, VpBase;
const
LANGUAGE_DIR = '..\..\languages\';

View File

@ -208,11 +208,7 @@ var
I: Integer;
S: string;
DrawRect: TRect;
fontsize: Integer;
begin
{Store the font size}
fontsize := RenderCanvas.Font.Size;
{draw the day name column labels}
RenderCanvas.Font.Color := DayNameColor;
I := 0;
@ -240,10 +236,6 @@ begin
S := SysToUTF8(S);
{$ENDIF}
{restore the font size - this is not needed normally, but may solve the
issue with growing fonts along this row in MacOSX }
RenderCanvas.Font.Size := fontsize;
{draw the day name above each column}
DrawRect := TVpCalendarOpener(FCalendar).clRowCol[1, I];
OffsetRect(DrawRect, RealLeft, Realtop);

View File

@ -721,7 +721,6 @@ var
OldFont: TFont;
RealPoint: TPoint;
OldBrushStyle: TBrushStyle;
// savedFontHeight: Integer;
begin
if not Assigned(FCanvas) then
raise EVpCanvasError.Create(RSNoCanvas);
@ -756,13 +755,12 @@ begin
else LF.lfPitchAndFamily := DEFAULT_PITCH;
end;
// Create new font to use
OldFont := FCanvas.Font;
// Store currently used font
OldFont := TFont.Create;
try
OldFont.Assign(FCanvas.Font);
// savedFontHeight := FCanvas.Font.Height;
FCanvas.Font.Handle:= CreateFontIndirect(LF);
// Create new font to use.
FCanvas.Font.Handle := CreateFontIndirect(LF);
// Output the text
if Rotate then
@ -777,9 +775,8 @@ begin
FCanvas.Brush.Style := OldBrushStyle;
end;
finally
// Restore previously used font.
FCanvas.Font.Assign(OldFont);
// FCanvas.Font := OldFont;
// FCanvas.Font.Height := savedFontHeight;
end;
end;

View File

@ -278,7 +278,6 @@ begin
FMonthView := AOwner;
FFont := TFont.Create;
FFont.Assign(FMonthView.Font);
FFont.Size := 8;
FColor := clSilver;
end;
{=====}

View File

@ -13,7 +13,7 @@ type
private
FMonthView: TVpMonthView;
// local parameters of the old TVpMonthView method
HeadRect: TRect;
// HeadRect: TRect;
DisplayDate: TDateTime;
RealColor: TColor;
BevelHighlight: TColor;
@ -699,49 +699,45 @@ end;
procedure TVpMonthViewPainter.DrawHeader;
var
HeadRect: TRect;
HeadTextRect: TRect;
HeadStr: string;
HeadStrLen : Integer;
dayHeadHeight: Integer;
R: TRect;
begin
RenderCanvas.Brush.Color := DayHeadAttrColor;
dayHeadHeight := TVpMonthViewOpener(FMonthView).mvDayHeadHeight;
HeadRect := Rect(RealLeft + 1, RealTop + 1, RealRight - 1, RealTop + dayHeadHeight);
{ draw the header cell and borders }
if FMonthView.DrawingStyle = dsFlat then begin
{ draw an outer and inner bevel }
{
HeadRect.Left := RealLeft + 1;
HeadRect.Top := RealTop + 1;
HeadRect.Right := RealRight - 1;
HeadRect.Bottom := RealTop + dayHeadHeight;
}
TPSFillRect(RenderCanvas, Angle, RenderIn, HeadRect);
DrawBevelRect(
RenderCanvas,
TPSRotateRectangle(Angle, RenderIn, HeadRect),
BevelHighlight,
BevelShadow
);
R := TPSRotateRectangle(Angle, RenderIn, HeadRect);
DrawBevelRect(RenderCanvas, R, BevelShadow, BevelShadow);
end else
if FMonthView.DrawingStyle = ds3d then begin
{ draw a 3d bevel }
HeadRect.Left := RealLeft + 2;
HeadRect.Top := RealTop + 2;
HeadRect.Right := RealRight - 3;
HeadRect.Bottom := RealTop + dayHeadHeight;
InflateRect(HeadRect, -1, -1);
HeadRect.Bottom := HeadRect.Top + dayHeadHeight;
{
AHeadRect.Left := RealLeft + 2;
AHeadRect.Top := RealTop + 2;
AHeadRect.Right := RealRight - 3;
AHeadRect.Bottom := RealTop + dayHeadHeight;
}
TPSFillRect(RenderCanvas, Angle, RenderIn, HeadRect);
DrawBevelRect(
RenderCanvas,
TPSRotateRectangle(Angle, RenderIn, HeadRect),
BevelHighlight,
BevelDarkShadow
);
end
else begin
HeadRect.Left := RealLeft + 1;
HeadRect.Top := RealTop + 1;
HeadRect.Right := RealRight - 1;
HeadRect.Bottom := RealTop + dayHeadHeight;
R := TPSRotateRectangle(Angle, RenderIn, HeadRect);
DrawBevelRect(RenderCanvas, R, BevelHighlight, BevelDarkShadow);
end;
{ Acquire startdate and end date }
@ -751,7 +747,7 @@ begin
{$ENDIF}
{ draw the text }
if DisplayOnly and (RenderCanvas.TextWidth (HeadStr) >= RealWidth) then
if DisplayOnly and (RenderCanvas.TextWidth(HeadStr) >= RealWidth) then
HeadTextRect.TopLeft:= Point(
RealLeft + TextMargin * 2,
HeadRect.Top
@ -759,7 +755,7 @@ begin
else
if DisplayOnly then
HeadTextRect.TopLeft := Point(
RealLeft + (RealWidth - RenderCanvas.TextWidth (HeadStr)) div 2,
RealLeft + (RealWidth - RenderCanvas.TextWidth(HeadStr)) div 2,
HeadRect.Top
)
else