tvplanit: Improving LCL scaling.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8438 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2022-09-02 17:38:26 +00:00
parent f60702ccb7
commit 30acf7208e
30 changed files with 448 additions and 163 deletions

View File

@ -9,6 +9,7 @@
</Flags> </Flags>
<SessionStorage Value="InProjectDir"/> <SessionStorage Value="InProjectDir"/>
<Title Value="demo"/> <Title Value="demo"/>
<Scaled Value="True"/>
<ResourceType Value="res"/> <ResourceType Value="res"/>
<UseXPManifest Value="True"/> <UseXPManifest Value="True"/>
<XPManifest> <XPManifest>

View File

@ -14,6 +14,7 @@ uses
begin begin
RequireDerivedFormResource := True; RequireDerivedFormResource := True;
Application.Scaled:=True;
Application.Initialize; Application.Initialize;
Application.CreateForm(TDemoDM, DemoDM); Application.CreateForm(TDemoDM, DemoDM);
Application.CreateForm(TMainForm, MainForm); Application.CreateForm(TMainForm, MainForm);

View File

@ -4,13 +4,12 @@ object MainForm: TMainForm
Top = 134 Top = 134
Width = 959 Width = 959
Caption = 'Turbo Power VisualPlanIt Demo' Caption = 'Turbo Power VisualPlanIt Demo'
ClientHeight = 576 ClientHeight = 596
ClientWidth = 959 ClientWidth = 959
Menu = MainMenu1 Menu = MainMenu1
OnCloseQuery = FormCloseQuery OnCloseQuery = FormCloseQuery
OnCreate = FormCreate OnCreate = FormCreate
OnDestroy = FormDestroy OnDestroy = FormDestroy
LCLVersion = '2.3.0.0'
object Panel1: TPanel object Panel1: TPanel
Left = 125 Left = 125
Height = 596 Height = 596
@ -81,6 +80,7 @@ object MainForm: TMainForm
Top = 351 Top = 351
Width = 357 Width = 357
ShowHint = True ShowHint = True
PopupMenu = VpMonthView1.default
ControlLink = VpControlLink1 ControlLink = VpControlLink1
ParentShowHint = False ParentShowHint = False
Align = alBottom Align = alBottom
@ -88,7 +88,7 @@ object MainForm: TMainForm
DayHeadAttributes.Color = clBtnFace DayHeadAttributes.Color = clBtnFace
DrawingStyle = dsFlat DrawingStyle = dsFlat
EventDayStyle = [fsItalic] EventDayStyle = [fsItalic]
HeadAttributes.Font.Height = -13 HeadAttributes.Font.Height = -16
HeadAttributes.Font.Style = [fsItalic] HeadAttributes.Font.Style = [fsItalic]
HeadAttributes.Color = clBtnFace HeadAttributes.Color = clBtnFace
HolidayAttributes.Font.Color = clBlack HolidayAttributes.Font.Color = clBlack
@ -114,6 +114,7 @@ object MainForm: TMainForm
Top = 34 Top = 34
Width = 357 Width = 357
ShowHint = True ShowHint = True
PopupMenu = VpDayView1.default
ControlLink = VpControlLink1 ControlLink = VpControlLink1
Font.Height = -12 Font.Height = -12
ParentFont = False ParentFont = False
@ -129,7 +130,7 @@ object MainForm: TMainForm
TimeSlotColors.Active = clWhite TimeSlotColors.Active = clWhite
TimeSlotColors.ActiveRange.RangeBegin = h_00 TimeSlotColors.ActiveRange.RangeBegin = h_00
TimeSlotColors.ActiveRange.RangeEnd = h_00 TimeSlotColors.ActiveRange.RangeEnd = h_00
HeadAttributes.Font.Height = -13 HeadAttributes.Font.Height = -16
HeadAttributes.Font.Style = [fsItalic] HeadAttributes.Font.Style = [fsItalic]
HeadAttributes.Color = clBtnFace HeadAttributes.Color = clBtnFace
RowHeadAttributes.HourFont.Height = -24 RowHeadAttributes.HourFont.Height = -24
@ -288,6 +289,7 @@ object MainForm: TMainForm
Top = 0 Top = 0
Width = 472 Width = 472
ShowHint = True ShowHint = True
PopupMenu = VpWeekView1.default
ControlLink = VpControlLink1 ControlLink = VpControlLink1
Font.Height = -12 Font.Height = -12
ParentFont = False ParentFont = False
@ -302,7 +304,7 @@ object MainForm: TMainForm
DayHeadAttributes.Font.Height = -13 DayHeadAttributes.Font.Height = -13
DrawingStyle = dsFlat DrawingStyle = dsFlat
EventFont.Height = -12 EventFont.Height = -12
HeadAttributes.Font.Height = -13 HeadAttributes.Font.Height = -16
HeadAttributes.Font.Style = [fsItalic] HeadAttributes.Font.Style = [fsItalic]
HeadAttributes.Color = clBtnFace HeadAttributes.Color = clBtnFace
LineColor = clGray LineColor = clGray
@ -360,6 +362,7 @@ object MainForm: TMainForm
Height = 501 Height = 501
Top = 27 Top = 27
Width = 834 Width = 834
PopupMenu = VpTaskList1.default
ControlLink = VpControlLink1 ControlLink = VpControlLink1
ParentFont = False ParentFont = False
Align = alClient Align = alClient
@ -400,6 +403,7 @@ object MainForm: TMainForm
Height = 528 Height = 528
Top = 0 Top = 0
Width = 794 Width = 794
PopupMenu = VpContactGrid1.default
ControlLink = VpControlLink1 ControlLink = VpControlLink1
ParentFont = False ParentFont = False
Align = alClient Align = alClient

View File

@ -10,7 +10,7 @@ uses
{$ENDIF} {$ENDIF}
Classes, fgl, SysUtils, FileUtil, Classes, fgl, SysUtils, FileUtil,
PrintersDlgs, Forms, Controls, Graphics, Dialogs, PrintersDlgs, Forms, Controls, Graphics, Dialogs,
ExtCtrls, StdCtrls, ComCtrls, LCLTranslator, Menus, Types, LCLVersion, Contnrs, ExtCtrls, StdCtrls, ComCtrls, LCLTranslator, Menus, Types, LCLVersion,
CheckLst, VpBaseDS, VpDayView, VpWeekView, VpTaskList, VpAbout, VpContactGrid, CheckLst, VpBaseDS, VpDayView, VpWeekView, VpTaskList, VpAbout, VpContactGrid,
VpMonthView, VpResEditDlg, VpContactButtons, VpNavBar, VpData, VpPrtPrvDlg, VpMonthView, VpResEditDlg, VpContactButtons, VpNavBar, VpData, VpPrtPrvDlg,
VpPrtFmtDlg, VpBase; VpPrtFmtDlg, VpBase;

View File

@ -575,6 +575,10 @@ msgstr "Stunden"
msgid "iCalendar files (*.ical;*.ics)|*.ical;*.ics" msgid "iCalendar files (*.ical;*.ics)|*.ical;*.ics"
msgstr "iCalendar Dateien ('*.ical;*.ics)|*.ical;*.ics" msgstr "iCalendar Dateien ('*.ical;*.ics)|*.ical;*.ics"
#: vpsr.rsimportcheckeditems
msgid "Import checked items"
msgstr "Markierte Einträge importieren"
#: vpsr.rsimporticalevent #: vpsr.rsimporticalevent
msgid "Import ICalendar Event" msgid "Import ICalendar Event"
msgstr "iCalendar-Termin importieren" msgstr "iCalendar-Termin importieren"

View File

@ -569,6 +569,10 @@ msgstr "Hours"
msgid "iCalendar files (*.ical;*.ics)|*.ical;*.ics" msgid "iCalendar files (*.ical;*.ics)|*.ical;*.ics"
msgstr "iCalendar files (*.ical;*.ics)|*.ical;*.ics" msgstr "iCalendar files (*.ical;*.ics)|*.ical;*.ics"
#: vpsr.rsimportcheckeditems
msgid "Import checked items"
msgstr "Import checked items"
#: vpsr.rsimporticalevent #: vpsr.rsimporticalevent
msgid "Import ICalendar Event" msgid "Import ICalendar Event"
msgstr "Import ICalendar Event" msgstr "Import ICalendar Event"

View File

@ -566,6 +566,10 @@ msgstr "Tunnit"
msgid "iCalendar files (*.ical;*.ics)|*.ical;*.ics" msgid "iCalendar files (*.ical;*.ics)|*.ical;*.ics"
msgstr "" msgstr ""
#: vpsr.rsimportcheckeditems
msgid "Import checked items"
msgstr ""
#: vpsr.rsimporticalevent #: vpsr.rsimporticalevent
msgid "Import ICalendar Event" msgid "Import ICalendar Event"
msgstr "" msgstr ""

View File

@ -581,6 +581,10 @@ msgstr "Heures"
msgid "iCalendar files (*.ical;*.ics)|*.ical;*.ics" msgid "iCalendar files (*.ical;*.ics)|*.ical;*.ics"
msgstr "" msgstr ""
#: vpsr.rsimportcheckeditems
msgid "Import checked items"
msgstr ""
#: vpsr.rsimporticalevent #: vpsr.rsimporticalevent
msgid "Import ICalendar Event" msgid "Import ICalendar Event"
msgstr "" msgstr ""

View File

@ -575,6 +575,10 @@ msgstr "Uren"
msgid "iCalendar files (*.ical;*.ics)|*.ical;*.ics" msgid "iCalendar files (*.ical;*.ics)|*.ical;*.ics"
msgstr "" msgstr ""
#: vpsr.rsimportcheckeditems
msgid "Import checked items"
msgstr ""
#: vpsr.rsimporticalevent #: vpsr.rsimporticalevent
msgid "Import ICalendar Event" msgid "Import ICalendar Event"
msgstr "" msgstr ""

View File

@ -575,6 +575,10 @@ msgstr "Godziny"
msgid "iCalendar files (*.ical;*.ics)|*.ical;*.ics" msgid "iCalendar files (*.ical;*.ics)|*.ical;*.ics"
msgstr "Pliki iCalendar (*.ical;*.ics)|*.ical;*.ics" msgstr "Pliki iCalendar (*.ical;*.ics)|*.ical;*.ics"
#: vpsr.rsimportcheckeditems
msgid "Import checked items"
msgstr ""
#: vpsr.rsimporticalevent #: vpsr.rsimporticalevent
msgid "Import ICalendar Event" msgid "Import ICalendar Event"
msgstr "" msgstr ""

View File

@ -559,6 +559,10 @@ msgstr ""
msgid "iCalendar files (*.ical;*.ics)|*.ical;*.ics" msgid "iCalendar files (*.ical;*.ics)|*.ical;*.ics"
msgstr "" msgstr ""
#: vpsr.rsimportcheckeditems
msgid "Import checked items"
msgstr ""
#: vpsr.rsimporticalevent #: vpsr.rsimporticalevent
msgid "Import ICalendar Event" msgid "Import ICalendar Event"
msgstr "" msgstr ""

View File

@ -575,6 +575,10 @@ msgstr "Часы"
msgid "iCalendar files (*.ical;*.ics)|*.ical;*.ics" msgid "iCalendar files (*.ical;*.ics)|*.ical;*.ics"
msgstr "" msgstr ""
#: vpsr.rsimportcheckeditems
msgid "Import checked items"
msgstr ""
#: vpsr.rsimporticalevent #: vpsr.rsimporticalevent
msgid "Import ICalendar Event" msgid "Import ICalendar Event"
msgstr "" msgstr ""

View File

@ -200,6 +200,7 @@ resourcestring
RSNoContactsFoundInVCARD = 'No contact items found in "%s".'; RSNoContactsFoundInVCARD = 'No contact items found in "%s".';
RSAssignedCategory = 'Assigned category'; RSAssignedCategory = 'Assigned category';
RSEventItems = 'Event items'; RSEventItems = 'Event items';
RSImportCheckedItems = 'Import checked items';
{Task Specific} {Task Specific}
RSConfirmDeleteTask = 'Delete this task from your list?'; RSConfirmDeleteTask = 'Delete this task from your list?';

View File

@ -75,7 +75,7 @@ const
MaxDateLen = 40; { maximum length of date picture strings } MaxDateLen = 40; { maximum length of date picture strings }
MaxMonthName = 15; { maximum length for month names } MaxMonthName = 15; { maximum length for month names }
MaxDayName = 15; { maximum length for day names } MaxDayName = 15; { maximum length for day names }
TextMargin = 5; { amount of space around text } TEXT_MARGIN = 5; { amount of space around text }
MaxVisibleEvents = 1024; { maximum number of events that can be } MaxVisibleEvents = 1024; { maximum number of events that can be }
{ visible at any one time } { visible at any one time }
MaxEventDepth = 50; { the maximum number of side by side } MaxEventDepth = 50; { the maximum number of side by side }

View File

@ -115,8 +115,10 @@ type
FExternalPopup: TPopupMenu; FExternalPopup: TPopupMenu;
FHintMode: TVpHintMode; FHintMode: TVpHintMode;
FPendingDatastore: TVpCustomDatastore; FPendingDatastore: TVpCustomDatastore;
FTextMargin: Integer;
procedure InternalSetDatastore(const Value: TVpCustomDatastore); procedure InternalSetDatastore(const Value: TVpCustomDatastore);
procedure SetPopupMenu(AValue: TPopupMenu); procedure SetPopupMenu(AValue: TPopupMenu);
procedure SetTextMargin(AValue: Integer);
protected{ private } protected{ private }
FColumnWidth : Integer; FColumnWidth : Integer;
FColor : TColor; FColor : TColor;
@ -259,6 +261,11 @@ type
{ - Added to support the buttonbar component. } { - Added to support the buttonbar component. }
function SelectContactByName(const Name: String): Boolean; function SelectContactByName(const Name: String): Boolean;
{ LCL scaling }
{$IF VP_LCL_SCALING <> 0}
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: Double); override;
{$IFEND}
{$IF VP_LCL_SCALING = 2} {$IF VP_LCL_SCALING = 2}
procedure FixDesignFontsPPI(const ADesignTimePPI: Integer); override; procedure FixDesignFontsPPI(const ADesignTimePPI: Integer); override;
procedure ScaleFontsPPI(const AToPPI: Integer; const AProportion: Double); override; procedure ScaleFontsPPI(const AToPPI: Integer; const AProportion: Double); override;
@ -299,6 +306,8 @@ type
read FPrintNumColumns write SetPrintNumColumns default 3; read FPrintNumColumns write SetPrintNumColumns default 3;
property SortBy: TVpContactSort property SortBy: TVpContactSort
read FSortBy write SetSortBy default csLastFirst; read FSortBy write SetSortBy default csLastFirst;
property TextMargin: Integer
read FTextMargin write SetTextMargin default TEXT_MARGIN;
{ events } { events }
property BeforeEdit: TVpEditContactEvent property BeforeEdit: TVpEditContactEvent
@ -481,6 +490,7 @@ begin
cgCreatingEditor := false; cgCreatingEditor := false;
FDrawingStyle := ds3d; FDrawingStyle := ds3d;
cgPainting := false; cgPainting := false;
FTextMargin := TEXT_MARGIN;
FColor := DEFAULT_COLOR; FColor := DEFAULT_COLOR;
FBarColor := DEFAULT_LINECOLOR; FBarColor := DEFAULT_LINECOLOR;
BarWidth := 3; BarWidth := 3;
@ -488,7 +498,7 @@ begin
FContactIndex := -1; FContactIndex := -1;
FPrintNumColumns := 3; FPrintNumColumns := 3;
{ initialize the bar arrays. } // Initialize the bar arrays.
SetLength(cgBarArray, MaxColumns); SetLength(cgBarArray, MaxColumns);
for I := 0 to pred(Length(cgBarArray)) do begin for I := 0 to pred(Length(cgBarArray)) do begin
cgBarArray[I].Rec := Rect(-1, -1, -1, -1); cgBarArray[I].Rec := Rect(-1, -1, -1, -1);
@ -517,7 +527,6 @@ begin
cgHookUp; cgHookUp;
end; end;
{=====}
destructor TVpContactGrid.Destroy; destructor TVpContactGrid.Destroy;
begin begin
@ -1865,7 +1874,15 @@ begin
Invalidate; Invalidate;
end; end;
end; end;
{=====}
procedure TVpContactGrid.SetTextMargin(AValue: Integer);
begin
if AValue <> FTextMargin then
begin
FTextMargin := AValue;
Invalidate;
end;
end;
function TVpContactGrid.GetContactIndexByCoord(Pnt: TPoint): Integer; function TVpContactGrid.GetContactIndexByCoord(Pnt: TPoint): Integer;
var var
@ -1933,6 +1950,19 @@ begin
AContact.EMail3 := AEMail; AContact.EMail3 := AEMail;
end; end;
{$IF VP_LCL_SCALING <> 0}
procedure TVpContactGrid.DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: Double);
begin
inherited;
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
begin
FBarWidth := round(FBarWidth * AXProportion);
FTextMargin := round(FTextMargin * AXProportion);
end;
end;
{$IFEND}
{$IF VP_LCL_SCALING = 2} {$IF VP_LCL_SCALING = 2}
procedure TVpContactGrid.FixDesignFontsPPI(const ADesignTimePPI: Integer); procedure TVpContactGrid.FixDesignFontsPPI(const ADesignTimePPI: Integer);
begin begin

View File

@ -126,71 +126,73 @@ procedure TVpContactGridPainter.DrawContactLine(ABitmap: TBitmap;
var var
txtheight: Integer; txtheight: Integer;
txtColWidth: Integer; txtColWidth: Integer;
txtMargin: Integer;
begin begin
if AText = '' then begin if AText = '' then begin
ATextRect := Rect(0, 0, 0, 0); ATextRect := Rect(0, 0, 0, 0);
exit; exit;
end; end;
txtMargin := FContactGrid.TextMargin;
txtHeight := ABitmap.Canvas.TextHeight(VpProductName); txtHeight := ABitmap.Canvas.TextHeight(VpProductName);
case Angle of case Angle of
ra0: ra0:
begin begin
ATextRect.Left := TextMargin; ATextRect.Left := txtMargin;
ATextRect.Top := AWholeRect.Bottom + TextMargin div 2; ATextRect.Top := AWholeRect.Bottom + txtMargin div 2;
ATextRect.Right := ABitmap.Width; ATextRect.Right := ABitmap.Width;
ATextRect.Bottom := ATextRect.Top + txtHeight + TextMargin div 2; ATextRect.Bottom := ATextRect.Top + txtHeight + txtMargin div 2;
AWholeRect.Bottom := ATextRect.Bottom; AWholeRect.Bottom := ATextRect.Bottom;
txtColWidth := ABitmap.Width; txtColWidth := ABitmap.Width;
end; end;
ra90: ra90:
begin begin
ATextRect.Left := AWholeRect.Left - txtHeight + TextMargin div 2; ATextRect.Left := AWholeRect.Left - txtHeight + txtMargin div 2;
ATextRect.Top := TextMargin; ATextRect.Top := txtMargin;
ATextRect.Right := AWholeRect.Left - TextMargin div 2; ATextRect.Right := AWholeRect.Left - txtMargin div 2;
ATextRect.Bottom := AWholeRect.Bottom + TextMargin div 2; ATextRect.Bottom := AWholeRect.Bottom + txtMargin div 2;
AWholeRect.Left := ATextRect.Left; AWholeRect.Left := ATextRect.Left;
txtColWidth := ABitmap.Height; txtColWidth := ABitmap.Height;
end; end;
ra180: ra180:
begin begin
ATextRect.Left := AWholeRect.Right - TextMargin * 2; // Shouldn't this be "div 2" ? ATextRect.Left := AWholeRect.Right - txtMargin * 2; // Shouldn't this be "div 2" ?
ATextRect.Top := AWholeRect.Top - txtHeight - TextMargin; ATextRect.Top := AWholeRect.Top - txtHeight - txtMargin;
ATextRect.Right := AWholeRect.Left + TextMargin; ATextRect.Right := AWholeRect.Left + txtMargin;
ATextRect.Bottom := AWholeRect.Top - TextMargin div 2; ATextRect.Bottom := AWholeRect.Top - txtMargin div 2;
AWholeRect.Top := ATextRect.Top; AWholeRect.Top := ATextRect.Top;
txtColWidth := ABitmap.Width; txtColWidth := ABitmap.Width;
end; end;
ra270: ra270:
begin begin
ATextRect.Left := AWholeRect.Right; ATextRect.Left := AWholeRect.Right;
ATextRect.Top := AWholeRect.Bottom - TextMargin; ATextRect.Top := AWholeRect.Bottom - txtMargin;
ATextRect.Right := AWholeRect.Right + txtHeight + TextMargin div 2; ATextRect.Right := AWholeRect.Right + txtHeight + txtMargin div 2;
ATextRect.Bottom := AWholeRect.Top + TextMargin div 2; ATextRect.Bottom := AWholeRect.Top + txtMargin div 2;
AWholeRect.Right := ATextRect.Right; AWholeRect.Right := ATextRect.Right;
txtColWidth := ABitmap.Height; txtColWidth := ABitmap.Height;
end; end;
end; // case Angle... end; // case Angle...
AText := GetDisplayString(ABitmap.Canvas, AText, 2, txtColWidth - TextMargin * 2); AText := GetDisplayString(ABitmap.Canvas, AText, 2, txtColWidth - txtMargin * 2);
if ALabel <> '' then begin if ALabel <> '' then begin
TPSTextOutAtPoint( TPSTextOutAtPoint(
ABitmap.Canvas, ABitmap.Canvas,
Angle, Angle,
Rect(0, 0, ABitmap.Width, ABitmap.Height), Rect(0, 0, ABitmap.Width, ABitmap.Height),
ATextRect.Left + TextMargin, ATextRect.Left + txtMargin,
ATextRect.Top + TextMargin div 2, ATextRect.Top + txtMargin div 2,
ALabel ALabel
); );
with ATextRect do with ATextRect do
case Angle of case Angle of
ra0 : TopLeft := Point(Left + PhoneLblWidth, Top + TextMargin div 2); ra0 : TopLeft := Point(Left + PhoneLblWidth, Top + txtMargin div 2);
ra90 : TopLeft := Point(Top + PhoneLblWidth, Left + TextMargin); ra90 : TopLeft := Point(Top + PhoneLblWidth, Left + txtMargin);
ra180 : TopLeft := Point(Left - PhoneLblWidth, top + TextMargin div 2); ra180 : TopLeft := Point(Left - PhoneLblWidth, top + txtMargin div 2);
ra270 : TopLeft := Point(Left + TextMargin div 2, Top - PhoneLblWidth); ra270 : TopLeft := Point(Left + txtMargin div 2, Top - PhoneLblWidth);
end; end;
TPSTextOutAtPoint( TPSTextOutAtPoint(
ABitmap.Canvas, ABitmap.Canvas,
@ -205,8 +207,8 @@ begin
ABitmap.Canvas, ABitmap.Canvas,
Angle, Angle,
Rect(0, 0, ABitmap.Width, ABitmap.Height), Rect(0, 0, ABitmap.Width, ABitmap.Height),
ATextRect.Left + TextMargin, ATextRect.Left + txtMargin,
ATextRect.Top + TextMargin div 2, ATextRect.Top + txtMargin div 2,
AText AText
); );
end; end;
@ -239,6 +241,7 @@ var
contactCount: Integer; contactCount: Integer;
baseTextHeight: Integer; baseTextHeight: Integer;
maxTextWidth: Integer; maxTextWidth: Integer;
txtMargin: Integer;
begin begin
{ if the component is sufficiently small then no sense in painting it } { if the component is sufficiently small then no sense in painting it }
if (FContactGrid.Height < 20) then exit; if (FContactGrid.Height < 20) then exit;
@ -258,16 +261,18 @@ begin
TextXOffset := 0; TextXOffset := 0;
TextYOffset := 0; TextYOffset := 0;
txtMargin := FContactGrid.TextMargin;
{ create a temporary bitmap for painting the items } { create a temporary bitmap for painting the items }
TmpBmp := TBitmap.Create; TmpBmp := TBitmap.Create;
try try
if (Angle = ra0) or (Angle = ra180) then begin if (Angle = ra0) or (Angle = ra180) then begin
TmpBmp.Width := RealColumnWidth - TextMargin * 4 + 4; // wp:+4 TmpBmp.Width := RealColumnWidth - txtMargin * 4 + 4; // wp:+4
TmpBmp.Height := RealHeight - TextMargin * 2; TmpBmp.Height := RealHeight - txtMargin * 2;
TextColWidth := TmpBmp.Width; TextColWidth := TmpBmp.Width;
end else begin end else begin
TmpBmp.Height := RealColumnWidth - TextMargin * 4 + 4; // wp: +4 TmpBmp.Height := RealColumnWidth - txtMargin * 4 + 4; // wp: +4
TmpBmp.Width := RealHeight - TextMargin * 2; TmpBmp.Width := RealHeight - txtMargin * 2;
TextColWidth := TmpBmp.Height; TextColWidth := TmpBmp.Height;
end; end;
TmpBmpRect := Rect(0, 0, TmpBmp.Width, TmpBmp.Height); TmpBmpRect := Rect(0, 0, TmpBmp.Width, TmpBmp.Height);
@ -297,18 +302,18 @@ begin
{ Set the anchor starting point } { Set the anchor starting point }
case Angle of case Angle of
ra0: ra0:
Anchor := Point(2 + TextMargin * 2, 2 + TextMargin * 2); Anchor := Point(2 + txtMargin * 2, 2 + txtMargin * 2);
ra90: ra90:
Anchor := Point(2 + TextMargin * 2, 2 + TextMargin * 2); Anchor := Point(2 + txtMargin * 2, 2 + txtMargin * 2);
ra180: ra180:
Anchor := Point( Anchor := Point(
RenderIn.Right - RenderIn.Left - TmpBmp.Width - 2 - TextMargin * 2, RenderIn.Right - RenderIn.Left - TmpBmp.Width - 2 - txtMargin * 2,
TmpBmp.Height - 2 - TextMargin * 2 TmpBmp.Height - 2 - txtMargin * 2
); );
ra270: ra270:
Anchor := Point( Anchor := Point(
2 + TextMargin * 2, 2 + txtMargin * 2,
RenderIn.Bottom - RenderIn.Top - TmpBmp.Height - 2 - TextMargin * 2 RenderIn.Bottom - RenderIn.Top - TmpBmp.Height - 2 - txtMargin * 2
); );
end; end;
RecsInCol := 0; RecsInCol := 0;
@ -340,14 +345,14 @@ begin
HeadRect.TopLeft := Point(0, 0); HeadRect.TopLeft := Point(0, 0);
HeadRect.BottomRight := Point( HeadRect.BottomRight := Point(
TmpBmp.Width, TmpBmp.Width,
HeadRect.Top + baseTextHeight + TextMargin div 2 HeadRect.Top + baseTextHeight + txtMargin div 2
); );
WholeRect.BottomRight := HeadRect.BottomRight; WholeRect.BottomRight := HeadRect.BottomRight;
end; end;
ra90: // TO DO: CHECK CORRECT USAGE OF TextMargin HERE !!!!!!!!! ra90: // TO DO: CHECK CORRECT USAGE OF TextMargin HERE !!!!!!!!!
begin begin
HeadRect.TopLeft := Point( HeadRect.TopLeft := Point(
TmpBmpRect.Right - TextMargin - baseTextHeight + TextMargin div 2, TmpBmpRect.Right - txtMargin - baseTextHeight + txtMargin div 2,
0 0
); );
HeadRect.BottomRight := Point(TmpBmpRect.Right, TmpBmp.Height); HeadRect.BottomRight := Point(TmpBmpRect.Right, TmpBmp.Height);
@ -358,21 +363,21 @@ begin
begin begin
WholeRect.BottomRight := Point(TmpBmp.Width, TmpBmp.Height); WholeRect.BottomRight := Point(TmpBmp.Width, TmpBmp.Height);
HeadRect.TopLeft := Point( HeadRect.TopLeft := Point(
TextMargin, txtMargin,
TmpBmpRect.Bottom - baseTextHeight - TextMargin TmpBmpRect.Bottom - baseTextHeight - txtMargin
); );
HeadRect.BottomRight := Point( HeadRect.BottomRight := Point(
TmpBmp.Width, TmpBmp.Width,
TmpBmp.Height - TextMargin div 2 TmpBmp.Height - txtMargin div 2
); );
WholeRect.TopLeft := HeadRect.TopLeft; WholeRect.TopLeft := HeadRect.TopLeft;
end; end;
ra270: ra270:
begin begin
WholeRect.TopLeft := Point(0, 0); WholeRect.TopLeft := Point(0, 0);
HeadRect.TopLeft := Point(0, TextMargin); HeadRect.TopLeft := Point(0, txtMargin);
HeadRect.BottomRight := Point( HeadRect.BottomRight := Point(
TextMargin + baseTextHeight + TextMargin div 2, txtMargin + baseTextHeight + txtMargin div 2,
TmpBmp.Height TmpBmp.Height
); );
WholeRect.BottomRight := HeadRect.BottomRight; WholeRect.BottomRight := HeadRect.BottomRight;
@ -394,18 +399,18 @@ begin
case Angle of case Angle of
ra90: ra90:
begin begin
TextXOffset := WidthOf(HeadRect) - TextMargin div 2; TextXOffset := WidthOf(HeadRect) - txtMargin div 2;
TextYOffset := TextMargin div 3; TextYOffset := txtMargin div 3;
end; end;
ra180: ra180:
begin begin
TextXOffset := WidthOf(HeadRect) - TextMargin; TextXOffset := WidthOf(HeadRect) - txtMargin;
TextYOffset := HeightOf(HeadRect) - TextMargin div 3; TextYOffset := HeightOf(HeadRect) - txtMargin div 3;
end; end;
ra270: ra270:
begin begin
TextXOffset := TextMargin div 2; TextXOffset := txtMargin div 2;
TextYOffset := HeightOf(HeadRect) - TextMargin div 3; TextYOffset := HeightOf(HeadRect) - txtMargin div 3;
end; end;
end; end;
@ -415,14 +420,14 @@ begin
else else
maxTextWidth := HeightOf(HeadRect); maxTextWidth := HeightOf(HeadRect);
Str := AssembleName(TmpCon); Str := AssembleName(TmpCon);
Str := GetDisplayString(TmpBmp.Canvas, Str, 2, maxTextWidth - TextMargin); Str := GetDisplayString(TmpBmp.Canvas, Str, 2, maxTextWidth - txtMargin);
TPSTextOutAtPoint( TPSTextOutAtPoint(
TmpBmp.Canvas, TmpBmp.Canvas,
Angle, Angle,
TmpBmpRect, TmpBmpRect,
HeadRect.Left + TextMargin div 2 + TextXOffset, HeadRect.Left + txtMargin div 2 + TextXOffset,
HeadRect.Top + TextMargin div 3 + TextYOffset, HeadRect.Top + txtMargin div 3 + TextYOffset,
Str Str
); );
@ -474,11 +479,11 @@ begin
if RecsInCol > 0 then if RecsInCol > 0 then
case Angle of case Angle of
ra0: ra0:
if (RenderIn.Top + Anchor.y + WholeRect.Bottom >= RenderIn.Bottom - TextMargin * 3) then if (RenderIn.Top + Anchor.y + WholeRect.Bottom >= RenderIn.Bottom - txtMargin * 3) then
begin begin
Anchor := Point( Anchor := Point(
Anchor.x + WholeRect.Right + FContactGrid.BarWidth + 1 + TextMargin * 3, Anchor.x + WholeRect.Right + FContactGrid.BarWidth + 1 + txtMargin * 3,
2 + TextMargin * 2 2 + txtMargin * 2
); );
if Col = 1 then if Col = 1 then
TVpContactGridOpener(FContactGrid).cgCol1RecCount := RecsInCol; TVpContactGridOpener(FContactGrid).cgCol1RecCount := RecsInCol;
@ -488,10 +493,10 @@ begin
Exit; Exit;
end; end;
ra90 : ra90 :
if (Anchor.x + RenderIn.Left + WholeRect.Right - WholeRect.Left > RenderIn.Right - TextMargin * 3) then if (Anchor.x + RenderIn.Left + WholeRect.Right - WholeRect.Left > RenderIn.Right - txtMargin * 3) then
begin begin
Anchor.x := 2 + TextMargin * 2; Anchor.x := 2 + txtMargin * 2;
Anchor.y := Anchor.y + WholeRect.Bottom + FContactGrid.BarWidth + 1 + TextMargin * 3; Anchor.y := Anchor.y + WholeRect.Bottom + FContactGrid.BarWidth + 1 + txtMargin * 3;
if Col = 1 then if Col = 1 then
TVpContactGridOpener(FContactGrid).cgCol1RecCount := RecsInCol; TVpContactGridOpener(FContactGrid).cgCol1RecCount := RecsInCol;
Inc(Col); Inc(Col);
@ -500,10 +505,10 @@ begin
Exit; Exit;
end; end;
ra180 : ra180 :
if (Anchor.y + RenderIn.Top - WholeRect.Bottom - WholeRect.Top <= RenderIn.Top + TextMargin * 3) then if (Anchor.y + RenderIn.Top - WholeRect.Bottom - WholeRect.Top <= RenderIn.Top + txtMargin * 3) then
begin begin
Anchor.x := Anchor.x - (WholeRect.Right + FContactGrid.BarWidth + 1 + TextMargin * 3); Anchor.x := Anchor.x - (WholeRect.Right + FContactGrid.BarWidth + 1 + txtMargin * 3);
Anchor.y := TmpBmp.Height - 2 - TextMargin * 2; Anchor.y := TmpBmp.Height - 2 - txtMargin * 2;
if Col = 1 then if Col = 1 then
TVpContactGridOpener(FContactGrid).cgCol1RecCount := RecsInCol; TVpContactGridOpener(FContactGrid).cgCol1RecCount := RecsInCol;
Inc(Col); Inc(Col);
@ -512,10 +517,10 @@ begin
Exit; Exit;
end; end;
ra270 : ra270 :
if (Anchor.x + RenderIn.Left + (WholeRect.Right - WholeRect.Left) >= RenderIn.Right - TextMargin * 3) then if (Anchor.x + RenderIn.Left + (WholeRect.Right - WholeRect.Left) >= RenderIn.Right - txtMargin * 3) then
begin begin
Anchor.x := 2 + TextMargin * 2; Anchor.x := 2 + txtMargin * 2;
Anchor.y := Anchor.y - (WholeRect.Bottom + FContactGrid.BarWidth + 1 + TextMargin * 3); Anchor.y := Anchor.y - (WholeRect.Bottom + FContactGrid.BarWidth + 1 + txtMargin * 3);
if Col = 1 then if Col = 1 then
TVpContactGridOpener(FContactGrid).cgCol1RecCount := RecsInCol; TVpContactGridOpener(FContactGrid).cgCol1RecCount := RecsInCol;
Inc(Col); Inc(Col);
@ -527,10 +532,10 @@ begin
{ add a little spacing between records } { add a little spacing between records }
case Angle of case Angle of
ra0 : WholeRect.Bottom := WholeRect.Bottom + TextMargin * 2; ra0 : WholeRect.Bottom := WholeRect.Bottom + txtMargin * 2;
ra90 : WholeRect.Left := WholeRect.Left - TextMargin * 2; ra90 : WholeRect.Left := WholeRect.Left - txtMargin * 2;
ra180 : WholeRect.Top := WholeRect.Top - TextMargin * 2; ra180 : WholeRect.Top := WholeRect.Top - txtMargin * 2;
ra270 : WholeRect.Right := WholeRect.Right + TextMargin * 2; ra270 : WholeRect.Right := WholeRect.Right + txtMargin * 2;
end; end;
{ Update Array Rects } { Update Array Rects }
@ -679,8 +684,8 @@ begin
TVpContactGridOpener(FContactGrid).cgBarArray[BarCount].Index := BarCount; TVpContactGridOpener(FContactGrid).cgBarArray[BarCount].Index := BarCount;
for I := 1 to FContactGrid.BarWidth do begin for I := 1 to FContactGrid.BarWidth do begin
TPSMoveTo(RenderCanvas, Angle, RenderIn, BarPos, RealTop + 2 + TextMargin * 2); TPSMoveTo(RenderCanvas, Angle, RenderIn, BarPos, RealTop + 2 + FContactGrid.TextMargin * 2);
TPSLineTo(RenderCanvas, Angle, RenderIn, BarPos, RealBottom - TextMargin * 2); TPSLineTo(RenderCanvas, Angle, RenderIn, BarPos, RealBottom - FContactGrid.TextMargin * 2);
Inc(BarPos); Inc(BarPos);
end; end;
Inc(BarPos, RealColumnWidth); Inc(BarPos, RealColumnWidth);
@ -714,12 +719,12 @@ begin
TPSMoveTo( TPSMoveTo(
RenderCanvas, Angle, RenderIn, RenderCanvas, Angle, RenderIn,
RealLeft + BarPos, RealLeft + BarPos,
RealTop + 2 + TextMargin * 2 RealTop + 2 + FContactGrid.TextMargin * 2
); );
TPSLineTo( TPSLineTo(
RenderCanvas, Angle, RenderIn, RenderCanvas, Angle, RenderIn,
RealLeft + BarPos, RealLeft + BarPos,
RealBottom - TextMargin * 2 RealBottom - FContactGrid.TextMargin * 2
); );
Inc(BarPos); Inc(BarPos);
end; end;
@ -732,13 +737,16 @@ end;
procedure TVpContactGridPainter.FixFontHeights; procedure TVpContactGridPainter.FixFontHeights;
begin begin
{$IF VP_LCL_SCALING = 0}
with FContactGrid do begin with FContactGrid do begin
{$IF VP_LCL_SCALING = 0}
ContactHeadAttributes.Font.Height := GetRealFontHeight(ContactHeadAttributes.Font); ContactHeadAttributes.Font.Height := GetRealFontHeight(ContactHeadAttributes.Font);
Font.Height := GetRealFontHeight(Font); Font.Height := GetRealFontHeight(Font);
end; {$ELSE}
ContactHeadAttributes.Font.Height := FixFontHeight(ContactHeadAttributes.Font);
Font.Height := FixFontHeight(Font);
{$ENDIF} {$ENDIF}
end; end;
end;
procedure TVpContactGridPainter.InitColors; procedure TVpContactGridPainter.InitColors;
begin begin

View File

@ -275,6 +275,7 @@ type
FShowNavButtons: Boolean; FShowNavButtons: Boolean;
FShowResourceName: Boolean; FShowResourceName: Boolean;
FSimpleRowTime: Boolean; FSimpleRowTime: Boolean;
FTextMargin: Integer;
FTimeFormat: TVpTimeFormat; FTimeFormat: TVpTimeFormat;
FTimeSlotColors: TVpTimeSlotColor; FTimeSlotColors: TVpTimeSlotColor;
FTopHour: TVpHours; FTopHour: TVpHours;
@ -334,6 +335,7 @@ type
procedure SetShowNavButtons(Value: Boolean); procedure SetShowNavButtons(Value: Boolean);
procedure SetShowResourceName(Value: Boolean); procedure SetShowResourceName(Value: Boolean);
procedure SetSimpleRowTime(Value: Boolean); procedure SetSimpleRowTime(Value: Boolean);
procedure SetTextMargin(Value: Integer);
procedure SetTimeFormat(Value: TVpTimeFormat); procedure SetTimeFormat(Value: TVpTimeFormat);
procedure SetTopHour(Value: TVpHours); procedure SetTopHour(Value: TVpHours);
procedure SetTopLine(Value: Integer); procedure SetTopLine(Value: Integer);
@ -424,6 +426,12 @@ type
procedure Notification(AComponent: TComponent; Operation: TOperation); override; procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure Paint; override; procedure Paint; override;
{ LCL scaling }
{$IF VP_LCL_SCALING <> 0}
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: Double); override;
{$IFEND}
{ message handlers } { message handlers }
procedure VpDayViewInit(var Msg: {$IFDEF DELPHI}TMessage{$ELSE}TLMessage{$ENDIF}); message Vp_DayViewInit; procedure VpDayViewInit(var Msg: {$IFDEF DELPHI}TMessage{$ELSE}TLMessage{$ENDIF}); message Vp_DayViewInit;
{$IFNDEF LCL} {$IFNDEF LCL}
@ -533,6 +541,7 @@ type
property RowHeight: Integer read FCustomRowHeight write SetCustomRowHeight default 0; property RowHeight: Integer read FCustomRowHeight write SetCustomRowHeight default 0;
property RowLinesStep: Integer read FRowLinesStep write SetRowLinesStep default 1; property RowLinesStep: Integer read FRowLinesStep write SetRowLinesStep default 1;
property SimpleRowTime: Boolean read FSimpleRowTime write SetSimpleRowTime default false; property SimpleRowTime: Boolean read FSimpleRowTime write SetSimpleRowTime default false;
property TextMargin: Integer read FTextMargin write SetTextMargin default TEXT_MARGIN;
{events} {events}
property AfterEdit: TVpAfterEditEvent read FAfterEdit write FAfterEdit; property AfterEdit: TVpAfterEditEvent read FAfterEdit write FAfterEdit;
property BeforeEdit: TVpBeforeEditEvent read FBeforeEdit write FBeforeEdit; property BeforeEdit: TVpBeforeEditEvent read FBeforeEdit write FBeforeEdit;
@ -846,6 +855,7 @@ begin
FCustomRowHeight := 0; FCustomRowHeight := 0;
FRowLinesStep := 1; FRowLinesStep := 1;
FSimpleRowTime := false; FSimpleRowTime := false;
FTextMargin := TEXT_MARGIN;
TopHour := FDefTopHour; TopHour := FDefTopHour;
FTimeFormat := tf12Hour; FTimeFormat := tf12Hour;
FDateLabelFormat := 'dddddd'; //'dddd, mmmm dd, yyyy'; FDateLabelFormat := 'dddddd'; //'dddd, mmmm dd, yyyy';
@ -1584,7 +1594,9 @@ var
glyphHeights: Integer; glyphHeights: Integer;
begin begin
Canvas.Font.Assign(FHeadAttr.Font); Canvas.Font.Assign(FHeadAttr.Font);
{$IF VP_LCL_SCALING = 0}
Canvas.Font.Size := ScaleY(Canvas.Font.Size, DesignTimeDPI); Canvas.Font.Size := ScaleY(Canvas.Font.Size, DesignTimeDPI);
{$IFEND}
if FShowResourceName and (DataStore <> nil) and (DataStore.Resource <> nil) then if FShowResourceName and (DataStore <> nil) and (DataStore.Resource <> nil) then
TextHeight := Canvas.TextHeight(TallShortChars) * 2 + TextMargin * 3 TextHeight := Canvas.TextHeight(TallShortChars) * 2 + TextMargin * 3
@ -1600,6 +1612,9 @@ begin
dvColHeadHeight := Result; dvColHeadHeight := Result;
end; end;
{ Drag and drop }
procedure TVpDayView.DoStartDrag(var DragObject: TDragObject); procedure TVpDayView.DoStartDrag(var DragObject: TDragObject);
{$IFDEF LCL} {$IFDEF LCL}
var var
@ -1721,7 +1736,9 @@ begin
{ font, the standard client font, and a sample character string. } { font, the standard client font, and a sample character string. }
SaveFont := Canvas.Font; SaveFont := Canvas.Font;
Canvas.Font.Assign(FRowHeadAttr.FMinuteFont); Canvas.Font.Assign(FRowHeadAttr.FMinuteFont);
{$IF VP_LCL_SCALING = 0}
Canvas.Font.Size := ScaleY(Canvas.Font.Size, DesignTimeDPI); Canvas.Font.Size := ScaleY(Canvas.Font.Size, DesignTimeDPI);
{$IFEND}
Canvas.Font.Height := GetRealFontHeight(Canvas.Font); Canvas.Font.Height := GetRealFontHeight(Canvas.Font);
Result := Canvas.TextHeight(TallShortChars); Result := Canvas.TextHeight(TallShortChars);
Canvas.Font.Assign(SaveFont); Canvas.Font.Assign(SaveFont);
@ -2547,6 +2564,15 @@ begin
end; end;
end; end;
procedure TVpDayView.SetTextMargin(Value: Integer);
begin
if Value <> FTextMargin then
begin
FTextMargin := Value;
Invalidate;
end;
end;
procedure TVpDayView.SetNumDays(Value: Integer); procedure TVpDayView.SetNumDays(Value: Integer);
begin begin
if (Value <> FNumDays) and (Value > 0) and (Value < 31) then begin if (Value <> FNumDays) and (Value > 0) and (Value < 31) then begin
@ -2749,6 +2775,22 @@ begin
SetVScrollPos; SetVScrollPos;
end; end;
{ LCL scaling }
{$IF VP_LCL_SCALING <> 0}
procedure TVpDayView.DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: Double);
begin
inherited;
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
begin
FGutterWidth := round(FGutterWidth * AXProportion);
FCustomRowHeight := round(FCustomRowHeight * AYProportion);
FTextMargin := round(FTextMargin * AXProportion);
end;
end;
{$IFEND}
{$IF VP_LCL_SCALING = 2} {$IF VP_LCL_SCALING = 2}
procedure TVpDayView.FixDesignFontsPPI(const ADesignTimePPI: Integer); procedure TVpDayView.FixDesignFontsPPI(const ADesignTimePPI: Integer);
begin begin

View File

@ -309,6 +309,7 @@ var
OldTop: LongInt; OldTop: LongInt;
txtDist: Integer; txtDist: Integer;
cat: TVpCategoryInfo; cat: TVpCategoryInfo;
txtMargin: Integer;
begin begin
// Initialize the rectangle to be used for all-day events // Initialize the rectangle to be used for all-day events
ADEventsRect := InitAllDayEventsRect; ADEventsRect := InitAllDayEventsRect;
@ -320,7 +321,9 @@ begin
// number of all day events for the range of days covered by the control. // number of all day events for the range of days covered by the control.
NumADEvents := 0; NumADEvents := 0;
AllDayWidth := RealWidth - RealRowHeadWidth - TextMargin - ScrollBarOffset; txtMargin := FDayView.TextMargin;
AllDayWidth := RealWidth - RealRowHeadWidth - txtMargin - ScrollBarOffset;
DayWidth := AllDayWidth div FDayView.NumDays; DayWidth := AllDayWidth div FDayView.NumDays;
ADEventsList := TList.Create; ADEventsList := TList.Create;
@ -364,10 +367,10 @@ begin
{$IF VP_LCL_SCALING = 0} {$IF VP_LCL_SCALING = 0}
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI); RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
{$ENDIF} {$ENDIF}
ADTextHeight := RenderCanvas.TextHeight(VpProductName) + TextMargin; ADTextHeight := RenderCanvas.TextHeight(VpProductName) + txtMargin;
// Distance between text and border // Distance between text and border
txtDist := TextMargin div 2; txtDist := txtMargin div 2;
// Store the top of the event's rect // Store the top of the event's rect
OldTop := ADEventsRect.Top; OldTop := ADEventsRect.Top;
@ -417,10 +420,10 @@ begin
); );
EventStr := IfThen(StartsBeforeRange, '>> ', '') + Event.Description; EventStr := IfThen(StartsBeforeRange, '>> ', '') + Event.Description;
EventStr := GetDisplayString(RenderCanvas, EventStr, 0, WidthOf(ADEvRect) - 2*TextMargin); EventStr := GetDisplayString(RenderCanvas, EventStr, 0, WidthOf(ADEvRect) - 2*txtMargin);
TPSTextOut(RenderCanvas,Angle, RenderIn, TPSTextOut(RenderCanvas,Angle, RenderIn,
AdEvRect.Left + TextMargin, AdEvRect.Left + txtMargin,
AdEvRect.Top + txtDist, // AdEvRect.Bottom - ADTextHeight) div 2, //TextMargin, AdEvRect.Top + txtDist, // AdEvRect.Bottom - ADTextHeight) div 2, //TextMargin,
EventStr EventStr
); );
@ -428,7 +431,7 @@ begin
TVpDayViewOpener(FDayView).dvEventArray[EventCount].Rec := Rect( TVpDayViewOpener(FDayView).dvEventArray[EventCount].Rec := Rect(
ADEvRect.Left, ADEvRect.Left,
ADEvRect.Top - 2, ADEvRect.Top - 2,
ADEvRect.Right - TextMargin, ADEvRect.Right - txtMargin,
ADEvRect.Bottom ADEvRect.Bottom
); );
TVpDayViewOpener(FDayView).dvEventArray[EventCount].Event := Event; TVpDayViewOpener(FDayView).dvEventArray[EventCount].Event := Event;
@ -673,15 +676,15 @@ begin
{ center and write the resource name in the first column } { center and write the resource name in the first column }
if (Col = 0) then begin if (Col = 0) then begin
X := TextRect.Left + (TextRect.Right - TextRect.Left) div 2 - ResStrLen div 2; X := TextRect.Left + (TextRect.Right - TextRect.Left) div 2 - ResStrLen div 2;
Y := TextRect.Top + TextMargin; Y := TextRect.Top + FDayView.TextMargin;
TPSTextOut(RenderCanvas, Angle, RenderIn, X, Y, FDayView.DataStore.Resource.Description); TPSTextOut(RenderCanvas, Angle, RenderIn, X, Y, FDayView.DataStore.Resource.Description);
end; end;
{ center the date string } { center the date string }
X := TextRect.Left + (TextRect.Right - TextRect.Left) div 2 - DateStrLen div 2; X := TextRect.Left + (TextRect.Right - TextRect.Left) div 2 - DateStrLen div 2;
Y := TextRect.Top + (TextMargin * 2) + DateStrHt; Y := TextRect.Top + (FDayView.TextMargin * 2) + DateStrHt;
end else begin end else begin
{ center the date string } { center the date string }
Y := TextRect.Top + TextMargin; Y := TextRect.Top + FDayView.TextMargin;
X := TextRect.Left + (TextRect.Right - TextRect.Left) div 2 - DateStrLen div 2; X := TextRect.Left + (TextRect.Right - TextRect.Left) div 2 - DateStrLen div 2;
end; end;
{ Write the date string } { Write the date string }
@ -897,7 +900,7 @@ begin
{ If the string is longer than the availble space then chop off the end { If the string is longer than the availble space then chop off the end
and place those little '...'s at the end } and place those little '...'s at the end }
if FDayView.WrapStyle = wsNone then begin if FDayView.WrapStyle = wsNone then begin
maxW := EventRect.Right - IconRect.Right - FScaledGutterWidth - TextMargin; maxW := EventRect.Right - IconRect.Right - FScaledGutterWidth - FDayView.TextMargin;
if RenderCanvas.TextWidth(EventString) > maxW then if RenderCanvas.TextWidth(EventString) > maxW then
EventString := GetDisplayString(RenderCanvas, EventString, 0, maxW); EventString := GetDisplayString(RenderCanvas, EventString, 0, maxW);
end; end;
@ -1139,16 +1142,16 @@ begin
TPSTextOut(RenderCanvas, // wp: both cases are the same ?! TPSTextOut(RenderCanvas, // wp: both cases are the same ?!
Angle, Angle,
RenderIn, RenderIn,
AIconRect.Right + FDayView.GutterWidth + TextMargin, AIconRect.Right + FDayView.GutterWidth + FDayView.TextMargin,
AEventRect.Top + TextMargin, AEventRect.Top + FDayView.TextMargin,
AText AText
) )
else else
TPSTextOut(RenderCanvas, TPSTextOut(RenderCanvas,
Angle, Angle,
RenderIn, RenderIn,
AIconRect.Right + FDayView.GutterWidth + TextMargin, AIconRect.Right + FDayView.GutterWidth + FDayView.TextMargin,
AEventRect.Top + TextMargin, AEventRect.Top + FDayView.TextMargin,
AText AText
); );
end; end;
@ -1438,7 +1441,7 @@ begin
{$ENDIF} {$ENDIF}
timeStr := Format('%s:%s', [hourStr, minuteStr]); timeStr := Format('%s:%s', [hourStr, minuteStr]);
x := lineRect.Left + FScaledTickDist; x := lineRect.Left + FScaledTickDist;
TPSTextOut(RenderCanvas, Angle, RenderIn, x, y + TextMargin, timeStr); TPSTextOut(RenderCanvas, Angle, RenderIn, x, y + FDayView.TextMargin, timeStr);
end else end else
begin begin
// In all other cases, paint large hour and small minutes (or am/pm) // In all other cases, paint large hour and small minutes (or am/pm)
@ -1448,7 +1451,7 @@ begin
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI); RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
{$ENDIF} {$ENDIF}
x := lineRect.Right - RenderCanvas.TextWidth(MinuteStr) - MINUTES_BORDER; x := lineRect.Right - RenderCanvas.TextWidth(MinuteStr) - MINUTES_BORDER;
TPSTextOut(RenderCanvas, Angle, RenderIn, x, y + TextMargin, minuteStr); TPSTextOut(RenderCanvas, Angle, RenderIn, x, y + FDayView.TextMargin, minuteStr);
// Draw hours // Draw hours
RenderCanvas.Font.Assign(FDayView.RowHeadAttributes.HourFont); RenderCanvas.Font.Assign(FDayView.RowHeadAttributes.HourFont);
@ -1456,7 +1459,7 @@ begin
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI); RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
{$ENDIF} {$ENDIF}
dec(x, RenderCanvas.TextWidth(HourStr) + MINUTES_HOUR_DISTANCE); dec(x, RenderCanvas.TextWidth(HourStr) + MINUTES_HOUR_DISTANCE);
TPSTextOut(RenderCanvas, Angle, RenderIn, x, y + TextMargin{ - 2}, hourStr); TPSTextOut(RenderCanvas, Angle, RenderIn, x, y + FDayView.TextMargin{ - 2}, hourStr);
end; end;
end; end;
@ -1575,11 +1578,19 @@ end;
procedure TVpDayViewPainter.FixFontHeights; procedure TVpDayViewPainter.FixFontHeights;
begin begin
with FDayView do begin with FDayView do begin
{$IF VP_LCL_SCALING = 0}
AllDayEventAttributes.Font.Height := GetRealFontHeight(AllDayEventAttributes.Font); AllDayEventAttributes.Font.Height := GetRealFontHeight(AllDayEventAttributes.Font);
Font.Height := GetRealFontHeight(Font); Font.Height := GetRealFontHeight(Font);
HeadAttributes.Font.Height := GetRealFontHeight(HeadAttributes.Font); HeadAttributes.Font.Height := GetRealFontHeight(HeadAttributes.Font);
RowHeadAttributes.HourFont.Height := GetRealFontHeight(RowHeadAttributes.HourFont); RowHeadAttributes.HourFont.Height := GetRealFontHeight(RowHeadAttributes.HourFont);
RowHeadAttributes.MinuteFont.Height := GetRealFontHeight(RowHeadAttributes.MinuteFont); RowHeadAttributes.MinuteFont.Height := GetRealFontHeight(RowHeadAttributes.MinuteFont);
{$ELSE}
AllDayEventAttributes.Font.Height := FixFontHeight(AllDayEventAttributes.Font);
Font.Height := FixFontHeight(Font);
HeadAttributes.Font.Height := FixFontHeight(HeadAttributes.Font);
RowHeadAttributes.HourFont.Height := FixFontHeight(RowHeadAttributes.HourFont);
RowHeadAttributes.MinuteFont.Height := FixFontHeight(RowHeadAttributes.MinuteFont);
{$IFEND}
end; end;
end; end;

View File

@ -693,6 +693,7 @@ begin
end; end;
end; end;
{$IF VP_LCL_SCALING <> 0}
procedure TVpGanttView.DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy; procedure TVpGanttView.DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: Double); const AXProportion, AYProportion: Double);
begin begin
@ -701,8 +702,10 @@ begin
begin begin
ColWidth := round(ColWidth * AXProportion); ColWidth := round(ColWidth * AXProportion);
FixedColWidth := round(FixedColWidth * AXProportion); FixedColWidth := round(FixedColWidth * AXProportion);
TextMargin := round(TextMargin * AXProportion);
end; end;
end; end;
{$IFEND}
function TVpGanttView.DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint): Boolean; function TVpGanttView.DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint): Boolean;
begin begin

View File

@ -6,7 +6,7 @@ object VpImportPreviewForm: TVpImportPreviewForm
Caption = 'VpImportPreviewForm' Caption = 'VpImportPreviewForm'
ClientHeight = 295 ClientHeight = 295
ClientWidth = 634 ClientWidth = 634
LCLVersion = '2.3.0.0' OnShow = FormShow
object ButtonPanel: TPanel object ButtonPanel: TPanel
Left = 6 Left = 6
Height = 25 Height = 25
@ -22,12 +22,13 @@ object VpImportPreviewForm: TVpImportPreviewForm
object btnExecute: TButton object btnExecute: TButton
AnchorSideTop.Control = ButtonPanel AnchorSideTop.Control = ButtonPanel
AnchorSideRight.Control = btnCancel AnchorSideRight.Control = btnCancel
Left = 406 Left = 400
Height = 25 Height = 25
Top = 0 Top = 0
Width = 141 Width = 141
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
AutoSize = True AutoSize = True
BorderSpacing.Right = 6
Caption = 'Import checked items' Caption = 'Import checked items'
ModalResult = 1 ModalResult = 1
TabOrder = 0 TabOrder = 0

View File

@ -26,6 +26,7 @@ type
btnExecute: TButton; btnExecute: TButton;
btnCancel: TButton; btnCancel: TButton;
ButtonPanel: TPanel; ButtonPanel: TPanel;
procedure FormShow(Sender: TObject);
procedure GridDrawCell(Sender: TObject; aCol, aRow: Integer; aRect: TRect; procedure GridDrawCell(Sender: TObject; aCol, aRow: Integer; aRect: TRect;
{%H-}aState: TGridDrawState); {%H-}aState: TGridDrawState);
procedure GridGetCheckboxState(Sender: TObject; {%H-}ACol, ARow: Integer; procedure GridGetCheckboxState(Sender: TObject; {%H-}ACol, ARow: Integer;
@ -66,7 +67,8 @@ implementation
{$R *.lfm} {$R *.lfm}
uses uses
LCLIntf, LCLType, Themes; LCLIntf, LCLType, Themes,
VpSR;
{ TVpImportGrid } { TVpImportGrid }
@ -158,15 +160,17 @@ begin
FixedCols := 0; FixedCols := 0;
Options := [goEditing, goRowSelect, goThumbTracking, Options := [goEditing, goRowSelect, goThumbTracking,
goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine,
goRangeSelect, goColSizing, goSmoothScroll]; goRangeSelect, goSmoothScroll];
OnDrawCell := @GridDrawCell; OnDrawCell := @GridDrawCell;
OnGetCheckboxState := @GridGetCheckboxState; OnGetCheckboxState := @GridGetCheckboxState;
OnPrepareCanvas := @GridPrepareCanvas; OnPrepareCanvas := @GridPrepareCanvas;
OnSetCheckboxState := @GridSetCheckboxState; OnSetCheckboxState := @GridSetCheckboxState;
//Parent := self;
end; end;
FItems := TFPList.Create; FItems := TFPList.Create;
btnExecute.Caption := RSImportCheckedItems;
btnCancel.Caption := RSCancelBtn;
end; end;
destructor TVpImportPreviewForm.Destroy; destructor TVpImportPreviewForm.Destroy;
@ -256,6 +260,14 @@ begin
end; end;
end; end;
procedure TVpImportPreviewForm.FormShow(Sender: TObject);
var
col: TGridColumn;
begin
col := Grid.Columns[Grid.Columns.Count-1];
col.Width := Grid.Canvas.TextWidth(col.Title.Caption) + 4*varCellPadding;
end;
procedure TVpImportPreviewForm.GridGetCheckboxState(Sender: TObject; ACol, procedure TVpImportPreviewForm.GridGetCheckboxState(Sender: TObject; ACol,
ARow: Integer; var Value: TCheckboxState); ARow: Integer; var Value: TCheckboxState);
begin begin

View File

@ -9,10 +9,12 @@ inherited VpImportPreviewICalEventForm: TVpImportPreviewICalEventForm
Width = 655 Width = 655
ClientWidth = 655 ClientWidth = 655
inherited btnExecute: TButton inherited btnExecute: TButton
Left = 439 Left = 446
end end
inherited btnCancel: TButton inherited btnCancel: TButton
Left = 580 Left = 593
Width = 62
AutoSize = True
end end
end end
end end

View File

@ -9,10 +9,12 @@ inherited VpImportPreviewVCardForm: TVpImportPreviewVCardForm
Width = 655 Width = 655
ClientWidth = 655 ClientWidth = 655
inherited btnExecute: TButton inherited btnExecute: TButton
Left = 439 Left = 452
end end
inherited btnCancel: TButton inherited btnCancel: TButton
Left = 580 Left = 593
Width = 62
AutoSize = True
end end
end end
end end

View File

@ -179,6 +179,7 @@ function GetCanvasTextHeight(ACanvas: TCanvas; AFont: TFont; AText: String = '')
function GetCanvasTextWidth(ACanvas: TCanvas; AFont: TFont; AText: String): Integer; function GetCanvasTextWidth(ACanvas: TCanvas; AFont: TFont; AText: String): Integer;
function GetLabelWidth(ALabel: TLabel): Integer; function GetLabelWidth(ALabel: TLabel): Integer;
function GetRealFontHeight(AFont: TFont): Integer; function GetRealFontHeight(AFont: TFont): Integer;
function FixFontHeight(AFont: TFont): Integer;
function DecodeLineEndings(const AText: String): String; function DecodeLineEndings(const AText: String): String;
function EncodeLineEndings(const AText: String): String; function EncodeLineEndings(const AText: String): String;
@ -978,6 +979,11 @@ begin
canvas.Free; canvas.Free;
end; end;
function FixFontHeight(AFont: TFont): Integer;
begin
Result := GetFontData(AFont.Handle).Height;
end;
function GetRealFontHeight(AFont: TFont): Integer; function GetRealFontHeight(AFont: TFont): Integer;
begin begin
if AFont.Size = 0 then if AFont.Size = 0 then

View File

@ -145,7 +145,7 @@ type
FAllowDragAndDrop: Boolean; FAllowDragAndDrop: Boolean;
FApplyCategoryInfos: Boolean; FApplyCategoryInfos: Boolean;
FColor: TColor; FColor: TColor;
FColumnWidth: Integer; // FColumnWidth: Integer;
FComponentHint: TTranslateString; FComponentHint: TTranslateString;
FDate: TDateTime; FDate: TDateTime;
FDateLabelFormat: string; FDateLabelFormat: string;
@ -170,6 +170,7 @@ type
FSelectedDayColor: TColor; FSelectedDayColor: TColor;
FShowEvents: Boolean; FShowEvents: Boolean;
FShowEventTime: Boolean; FShowEventTime: Boolean;
FTextMargin: Integer;
FTimeFormat: TVpTimeFormat; FTimeFormat: TVpTimeFormat;
FTodayAttr: TVpMvTodayAttr; FTodayAttr: TVpMvTodayAttr;
FWeekendAttr: TVpMvWeekendAttr; FWeekendAttr: TVpMvWeekendAttr;
@ -211,6 +212,7 @@ type
procedure SetSelectedDayColor(Value: TColor); procedure SetSelectedDayColor(Value: TColor);
procedure SetShowEvents(Value: Boolean); procedure SetShowEvents(Value: Boolean);
procedure SetShowEventTime(Value: Boolean); procedure SetShowEventTime(Value: Boolean);
procedure SetTextMargin(Value: Integer);
procedure SetTimeFormat(Value: TVpTimeFormat); procedure SetTimeFormat(Value: TVpTimeFormat);
procedure SetWeekStartsOn(Value: TVpDayType); procedure SetWeekStartsOn(Value: TVpDayType);
@ -304,6 +306,11 @@ type
StartLine, StopLine: Integer; UseGran: TVpGranularity; StartLine, StopLine: Integer; UseGran: TVpGranularity;
DisplayOnly: Boolean); override; DisplayOnly: Boolean); override;
{ LCL scaling }
{$IF VP_LCL_SCALING <> 0}
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: Double); override;
{$IFEND}
{$IF VP_LCL_SCALING = 2} {$IF VP_LCL_SCALING = 2}
procedure FixDesignFontsPPI(const ADesignTimePPI: Integer); override; procedure FixDesignFontsPPI(const ADesignTimePPI: Integer); override;
procedure ScaleFontsPPI(const AToPPI: Integer; const AProportion: Double); override; procedure ScaleFontsPPI(const AToPPI: Integer; const AProportion: Double); override;
@ -334,7 +341,6 @@ type
property DrawingStyle: TVpDrawingStyle read FDrawingStyle write SetDrawingStyle default ds3d; property DrawingStyle: TVpDrawingStyle read FDrawingStyle write SetDrawingStyle default ds3d;
property EventDayStyle: TFontStyles read FEventDayStyle write SetEventDayStyle default []; property EventDayStyle: TFontStyles read FEventDayStyle write SetEventDayStyle default [];
property EventFont: TVpFont read FEventFont write SetEventFont; property EventFont: TVpFont read FEventFont write SetEventFont;
// property HeadAttributes: TVpMvHeadAttr read FHeadAttr write FHeadAttr;
property HeadAttributes: TVpMonthViewAttr read FHeadAttr write FHeadAttr; property HeadAttributes: TVpMonthViewAttr read FHeadAttr write FHeadAttr;
property HolidayAttributes: TVpMvHolidayAttr read FHolidayAttr write FHolidayAttr; property HolidayAttributes: TVpMvHolidayAttr read FHolidayAttr write FHolidayAttr;
property HintMode: TVpHintMode read FHintMode write FHintMode default hmPlannerHint; property HintMode: TVpHintMode read FHintMode write FHintMode default hmPlannerHint;
@ -348,6 +354,7 @@ type
property SelectedDayColor: TColor read FSelectedDayColor write SetSelectedDayColor default clRed; property SelectedDayColor: TColor read FSelectedDayColor write SetSelectedDayColor default clRed;
property ShowEvents: Boolean read FShowEvents write SetShowEvents default true; property ShowEvents: Boolean read FShowEvents write SetShowEvents default true;
property ShowEventTime: Boolean read FShowEventTime write SetShowEventTime default false; property ShowEventTime: Boolean read FShowEventTime write SetShowEventTime default false;
property TextMargin: Integer read FTextMargin write SetTextMargin default TEXT_MARGIN;
property TimeFormat: TVpTimeFormat read FTimeFormat write SetTimeFormat default tf12Hour; property TimeFormat: TVpTimeFormat read FTimeFormat write SetTimeFormat default tf12Hour;
property TodayAttributes: TVpMvTodayAttr read FTodayAttr write FTodayAttr; property TodayAttributes: TVpMvTodayAttr read FTodayAttr write FTodayAttr;
property WeekendAttributes: TVpMvWeekendAttr read FWeekendAttr write FWeekendAttr; property WeekendAttributes: TVpMvWeekendAttr read FWeekendAttr write FWeekendAttr;
@ -515,8 +522,9 @@ begin
FDate := Trunc(Now); FDate := Trunc(Now);
FTimeFormat := tf12Hour; FTimeFormat := tf12Hour;
FDateLabelFormat := 'mmmm yyyy'; FDateLabelFormat := 'mmmm yyyy';
FColumnWidth := 200; // FColumnWidth := 200;
FRightClickChangeDate := vpDefWVRClickChangeDate; FRightClickChangeDate := vpDefWVRClickChangeDate;
FTextMargin := TEXT_MARGIN;
// mvVisibleEvents := 0; // mvVisibleEvents := 0;
{ set up fonts and colors } { set up fonts and colors }
@ -885,6 +893,15 @@ begin
end; end;
end; end;
procedure TVpMonthView.SetTextMargin(Value: Integer);
begin
if Value <> FTextMargin then
begin
FTextMargin := Value;
Invalidate;
end;
end;
procedure TVpMonthView.SetTimeFormat(Value: TVpTimeFormat); procedure TVpMonthView.SetTimeFormat(Value: TVpTimeFormat);
begin begin
if Value <> FTimeFormat then begin if Value <> FTimeFormat then begin
@ -1582,11 +1599,24 @@ begin
end; end;
end; end;
{$IF VP_LCL_SCALING <> 0}
procedure TVpMonthView.DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: Double);
begin
inherited;
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
begin
FTextMargin := round(FTextMargin * AXProportion);
end;
end;
{$IFEND}
{$IF VP_LCL_SCALING = 2} {$IF VP_LCL_SCALING = 2}
procedure TVpMonthView.FixDesignFontsPPI(const ADesignTimePPI: Integer); procedure TVpMonthView.FixDesignFontsPPI(const ADesignTimePPI: Integer);
begin begin
inherited; inherited;
DoFixDesignFontPPI(DayHeadAttributes.Font, ADesignTimePPI); DoFixDesignFontPPI(DayHeadAttributes.Font, ADesignTimePPI);
DoFixDesignFontPPI(DayNumberFont, ADesignTimePPI);
DoFixDesignFontPPI(EventFont, ADesignTimePPI); DoFixDesignFontPPI(EventFont, ADesignTimePPI);
DoFixDesignFontPPI(HeadAttributes.Font, ADesignTimePPI); DoFixDesignFontPPI(HeadAttributes.Font, ADesignTimePPI);
DoFixDesignFontPPI(HolidayAttributes.Font, ADesignTimePPI); DoFixDesignFontPPI(HolidayAttributes.Font, ADesignTimePPI);
@ -1599,6 +1629,7 @@ procedure TVpMonthView.ScaleFontsPPI(const AToPPI: Integer;
begin begin
inherited; inherited;
DoScaleFontPPI(DayHeadAttributes.Font, AToPPI, AProportion); DoScaleFontPPI(DayHeadAttributes.Font, AToPPI, AProportion);
DoScaleFontPPI(DayNumberFont, AToPPI, AProportion);
DoScaleFontPPI(EventFont, AToPPI, AProportion); DoScaleFontPPI(EventFont, AToPPI, AProportion);
DoScaleFontPPI(HeadAttributes.Font, AToPPI, AProportion); DoScaleFontPPI(HeadAttributes.Font, AToPPI, AProportion);
DoScaleFontPPI(HolidayAttributes.Font, AToPPI, AProportion); DoScaleFontPPI(HolidayAttributes.Font, AToPPI, AProportion);
@ -1610,6 +1641,7 @@ procedure TVpMonthView.ScaleFontsPPI(const AProportion: Double);
begin begin
inherited; inherited;
DoScaleFontPPI(DayHeadAttributes.Font, AProportion); DoScaleFontPPI(DayHeadAttributes.Font, AProportion);
DoScaleFontPPI(DayNumberFont, AProportion);
DoScaleFontPPI(EventFont, Aproportion); DoScaleFontPPI(EventFont, Aproportion);
DoScaleFontPPI(HeadAttributes.Font, AProportion); DoScaleFontPPI(HeadAttributes.Font, AProportion);
DoScaleFontPPI(HolidayAttributes.Font, AProportion); DoScaleFontPPI(HolidayAttributes.Font, AProportion);

View File

@ -220,12 +220,12 @@ begin
{ Calculate size of rect for the day number at the top of the TextRect. } { Calculate size of rect for the day number at the top of the TextRect. }
if ACol = 6 then if ACol = 6 then
tmpRect.Left := ATextRect.Left + mvColWidth - TextAdjust - TextMargin tmpRect.Left := ATextRect.Left + mvColWidth - TextAdjust - FMonthView.TextMargin
else else
tmpRect.Left := ATextRect.Right - TextAdjust - TextMargin + 2; tmpRect.Left := ATextRect.Right - TextAdjust - FMonthView.TextMargin + 2;
if fsItalic in RenderCanvas.Font.Style then if fsItalic in RenderCanvas.Font.Style then
dec(tmpRect.Left, 2); dec(tmpRect.Left, 2);
tmpRect.Top := ATextRect.Top + TextMargin div 2; tmpRect.Top := ATextRect.Top + FMonthView.TextMargin div 2;
tmpRect.Right := tmpRect.Left + textAdjust; tmpRect.Right := tmpRect.Left + textAdjust;
tmpRect.Bottom := tmpRect.Top + textHeight; tmpRect.Bottom := tmpRect.Top + textHeight;
@ -372,12 +372,12 @@ begin
{ Fix header string } { Fix header string }
StrLen := RenderCanvas.TextWidth(Str); StrLen := RenderCanvas.TextWidth(Str);
if (StrLen > mvColWidth - TextMargin * 2) then if (StrLen > mvColWidth - FMonthView.TextMargin * 2) then
Str := GetDisplayString(RenderCanvas, Str, 0, mvColWidth - TextMargin * 2); Str := GetDisplayString(RenderCanvas, Str, 0, mvColWidth - FMonthView.TextMargin * 2);
StrLen := RenderCanvas.TextWidth(Str); StrLen := RenderCanvas.TextWidth(Str);
{ Draw header text } { Draw header text }
P := Point((dhRect.Left + dhRect.Right - StrLen) div 2, dhRect.Top + TextMargin - 1); P := Point((dhRect.Left + dhRect.Right - StrLen) div 2, dhRect.Top + FMonthView.TextMargin - 1);
TPSTextOut(RenderCanvas, Angle, RenderIn, P.X, P.Y, Str); TPSTextOut(RenderCanvas, Angle, RenderIn, P.X, P.Y, Str);
DayTAG := (DayTAG + 1) mod 7; DayTAG := (DayTAG + 1) mod 7;
@ -496,6 +496,7 @@ var
eventCat: TVpCategoryInfo; eventCat: TVpCategoryInfo;
dayRect: TRect; dayRect: TRect;
TextRect: TRect; TextRect: TRect;
txtMargin: Integer;
tmpRect: TRect; tmpRect: TRect;
Str: String; Str: String;
StrLen: Integer; StrLen: Integer;
@ -507,6 +508,8 @@ begin
RenderCanvas.Pen.Style := psSolid; RenderCanvas.Pen.Style := psSolid;
RenderCanvas.Brush.Color := RealColor; RenderCanvas.Brush.Color := RealColor;
txtMargin := FMonthView.TextMargin;
{ write the events } { write the events }
if (FMonthView.DataStore <> nil) and FMonthView.ShowEvents and if (FMonthView.DataStore <> nil) and FMonthView.ShowEvents and
(FMonthView.DataStore.Resource <> nil) and (FMonthView.DataStore.Resource <> nil) and
@ -527,7 +530,7 @@ begin
TextRect.TopLeft := Point(dayRect.Left+1, dayRect.Top+1); TextRect.TopLeft := Point(dayRect.Left+1, dayRect.Top+1);
TextRect.BottomRight := Point( TextRect.BottomRight := Point(
TextRect.Left + mvColWidth, TextRect.Left + mvColWidth,
TextRect.Top + mvEventTextHeight + TextMargin// div 2 TextRect.Top + mvEventTextHeight + txtMargin// div 2
); );
{ set canvas color } { set canvas color }
@ -550,9 +553,9 @@ begin
{ shorten events that are next to the day number, in order } { shorten events that are next to the day number, in order }
{ to give the day number enough room } { to give the day number enough room }
if (TextRect.Top < dayRect.Top + mvDayNumberHeight + TextMargin div 2) if (TextRect.Top < dayRect.Top + mvDayNumberHeight + txtMargin div 2)
then then
TextRect.Right := TextRect.Left + mvColWidth - mvDayNumberHeight - TextMargin * 2 TextRect.Right := TextRect.Left + mvColWidth - mvDayNumberHeight - txtMargin * 2
else else
TextRect.Right := TextRect.Left + mvColWidth - 3; TextRect.Right := TextRect.Left + mvColWidth - 3;
@ -582,11 +585,11 @@ begin
RenderCanvas.Font.Color := FMonthView.OffDayFontColor; RenderCanvas.Font.Color := FMonthView.OffDayFontColor;
StrLen := RenderCanvas.TextWidth(Str); StrLen := RenderCanvas.TextWidth(Str);
if StrLen > WidthOf(TextRect) - TextMargin * 2 then if StrLen > WidthOf(TextRect) - txtMargin * 2 then
Str := GetDisplayString(RenderCanvas, Str, 0, WidthOf(TextRect) - TextMargin * 2); Str := GetDisplayString(RenderCanvas, Str, 0, WidthOf(TextRect) - txtMargin * 2);
{ write the event text } { write the event text }
P := Point(TextRect.Left + TextMargin div 2, TextRect.Top + TextMargin div 2); P := Point(TextRect.Left + txtMargin div 2, TextRect.Top + txtMargin div 2);
TPSTextOut(RenderCanvas, Angle, RenderIn, P.X, P.Y, Str); TPSTextOut(RenderCanvas, Angle, RenderIn, P.X, P.Y, Str);
{ Store TextRect and Event in EventArray } { Store TextRect and Event in EventArray }
@ -695,12 +698,12 @@ begin
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI); RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
{$ENDIF} {$ENDIF}
if DisplayOnly and (RenderCanvas.TextWidth(HeadStr) >= RealWidth) then if DisplayOnly and (RenderCanvas.TextWidth(HeadStr) >= RealWidth) then
HeadTextRect.Left := RealLeft + TextMargin * 2 HeadTextRect.Left := RealLeft + FMonthView.TextMargin * 2
else else
if DisplayOnly then if DisplayOnly then
HeadTextRect.Left := RealLeft + (RealWidth - RenderCanvas.TextWidth(HeadStr)) div 2 HeadTextRect.Left := RealLeft + (RealWidth - RenderCanvas.TextWidth(HeadStr)) div 2
else else
HeadTextRect.Left := RealLeft + 30 + TextMargin * 2; HeadTextRect.Left := RealLeft + 30 + FMonthView.TextMargin * 2;
HeadTextRect.Top := (HeadRect.Top + HeadRect.Bottom - RenderCanvas.TextHeight('Tg')) div 2; HeadTextRect.Top := (HeadRect.Top + HeadRect.Bottom - RenderCanvas.TextHeight('Tg')) div 2;
HeadTextRect.BottomRight := HeadRect.BottomRight; HeadTextRect.BottomRight := HeadRect.BottomRight;
@ -712,7 +715,7 @@ begin
RenderCanvas, RenderCanvas,
HeadStr, HeadStr,
0, 0,
HeadTextRect.Right - HeadTextRect.Left - TextMargin HeadTextRect.Right - HeadTextRect.Left - FMonthView.TextMargin
); );
end; end;
@ -734,11 +737,19 @@ end;
procedure TVpMonthViewPainter.FixFontHeights; procedure TVpMonthViewPainter.FixFontHeights;
begin begin
with FMonthView do begin with FMonthView do begin
{$IF VP_LCL_SCALING = 0}
HeadAttributes.Font.Height := GetRealFontHeight(HeadAttributes.Font); HeadAttributes.Font.Height := GetRealFontHeight(HeadAttributes.Font);
DayHeadAttributes.Font.Height := GetRealFontHeight(DayHeadAttributes.Font); DayHeadAttributes.Font.Height := GetRealFontHeight(DayHeadAttributes.Font);
DayNumberFont.Height := GetRealFontHeight(DayNumberFont); DayNumberFont.Height := GetRealFontHeight(DayNumberFont);
EventFont.Height := GetRealFontHeight(EventFont); EventFont.Height := GetRealFontHeight(EventFont);
Font.Height := GetRealFontHeight(Font); Font.Height := GetRealFontHeight(Font);
{$ELSE}
HeadAttributes.Font.Height := FixFontHeight(HeadAttributes.Font);
DayHeadAttributes.Font.Height := FixFontHeight(DayHeadAttributes.Font);
DayNumberFont.Height := FixFontHeight(DayNumberFont);
EventFont.Height := FixFontHeight(EventFont);
Font.Height := FixFontHeight(Font);
{$IFEND}
end; end;
end; end;
@ -823,7 +834,7 @@ begin
DisplayDate := IfThen(RenderDate = 0, Date, RenderDate); DisplayDate := IfThen(RenderDate = 0, Date, RenderDate);
{ we use the VpProductName because is is a good representation of some } { We use the VpProductName because is is a good representation of some }
{ generic text } { generic text }
RenderCanvas.Font.Assign(FMonthView.DayHeadAttributes.Font); RenderCanvas.Font.Assign(FMonthView.DayHeadAttributes.Font);
{$IF VP_LCL_SCALING = 0} {$IF VP_LCL_SCALING = 0}

View File

@ -126,7 +126,9 @@ type
private private
FDefaultPopup: TPopupMenu; FDefaultPopup: TPopupMenu;
FExternalPopup: TPopupMenu; FExternalPopup: TPopupMenu;
FTextMargin: Integer;
procedure SetPopupMenu(AValue: TPopupMenu); procedure SetPopupMenu(AValue: TPopupMenu);
procedure SetTextMargin(AValue: Integer);
protected{ private } protected{ private }
FColor: TColor; FColor: TColor;
FCaption: string; FCaption: string;
@ -232,6 +234,11 @@ type
Angle: TVpRotationAngle; Scale: Extended; RenderDate: TDateTime; Angle: TVpRotationAngle; Scale: Extended; RenderDate: TDateTime;
StartLine, StopLine: Integer; UseGran: TVpGranularity; DisplayOnly: Boolean); override; StartLine, StopLine: Integer; UseGran: TVpGranularity; DisplayOnly: Boolean); override;
{ LCL scaling }
{$IF VP_LCL_SCALING <> 0}
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: Double); override;
{$IFEND}
{$IF VP_LCL_SCALING = 2} {$IF VP_LCL_SCALING = 2}
procedure FixDesignFontsPPI(const ADesignTimePPI: Integer); override; procedure FixDesignFontsPPI(const ADesignTimePPI: Integer); override;
procedure ScaleFontsPPI(const AToPPI: Integer; const AProportion: Double); override; procedure ScaleFontsPPI(const AToPPI: Integer; const AProportion: Double); override;
@ -265,6 +272,7 @@ type
property Color: TColor read FColor write SetColor default DEFAULT_COLOR; property Color: TColor read FColor write SetColor default DEFAULT_COLOR;
property ShowIcon: Boolean read FShowIcon write SetShowIcon default True; property ShowIcon: Boolean read FShowIcon write SetShowIcon default True;
property ShowResourceName: Boolean read FShowResourceName write SetShowResourceName default true; property ShowResourceName: Boolean read FShowResourceName write SetShowResourceName default true;
property TextMargin: Integer read FTextMargin write SetTextMargin default TEXT_MARGIN;
{ events } { events }
property BeforeEdit: TVpBeforeEditTask read FBeforeEdit write FBeforeEdit; property BeforeEdit: TVpBeforeEditTask read FBeforeEdit write FBeforeEdit;
property AfterEdit: TVpAfterEditTask read FAfterEdit write FAfterEdit; property AfterEdit: TVpAfterEditTask read FAfterEdit write FAfterEdit;
@ -530,6 +538,7 @@ begin
FShowResourceName := true; FShowResourceName := true;
FColor := DEFAULT_COLOR; FColor := DEFAULT_COLOR;
FLineColor := DEFAULT_LINECOLOR; FLineColor := DEFAULT_LINECOLOR;
FTextMargin := TEXT_MARGIN;
FScrollBars := ssVertical; FScrollBars := ssVertical;
FTaskIndex := -1; FTaskIndex := -1;
FShowIcon := True; FShowIcon := True;
@ -777,6 +786,15 @@ begin
end; end;
end; end;
procedure TVpTaskList.SetTextMargin(AValue: Integer);
begin
if AValue <> FTextMargin then
begin
FTextMargin := AValue;
Invalidate;
end;
end;
{$IFNDEF LCL} {$IFNDEF LCL}
procedure TVpTaskList.WMSize(var Msg: TWMSize); procedure TVpTaskList.WMSize(var Msg: TWMSize);
{$ELSE} {$ELSE}
@ -1350,6 +1368,18 @@ begin
end; end;
end; end;
{$IF VP_LCL_SCALING <> 0}
procedure TVpTaskList.DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: Double);
begin
inherited;
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
begin
FTextMargin := round(FTextMargin * AXProportion);
end;
end;
{$IFEND}
{$IF VP_LCL_SCALING = 2} {$IF VP_LCL_SCALING = 2}
procedure TVpTaskList.FixDesignFontsPPI(const ADesignTimePPI: Integer); procedure TVpTaskList.FixDesignFontsPPI(const ADesignTimePPI: Integer);
begin begin

View File

@ -92,12 +92,18 @@ var
d2: Integer; // 2*Scale d2: Integer; // 2*Scale
{%H-}d1px, {%H-}d2px, d3px: Integer; {%H-}d1px, {%H-}d2px, d3px: Integer;
begin begin
if Scale > 1 then tm := Round(FTaskList.TextMargin * Scale);
tm := Round(TextMargin * Scale) else
tm := ScaleY(Textmargin, DesigntimeDPI); {$IF VP_LCL_SCALING > 0}
d1px := FTasklist.Scale96ToFont(1);
d2px := FTasklist.Scale96ToFont(2);
d3px := FTasklist.Scale96ToFont(3);
{$ELSE}
tm := ScaleY(FTaskList.Textmargin, DesigntimeDPI);
d1px := ScaleY(1, DesigntimeDPI); d1px := ScaleY(1, DesigntimeDPI);
d2px := ScaleY(2, DesigntimeDPI); d2px := ScaleY(2, DesigntimeDPI);
d3px := ScaleY(3, DesigntimeDPI); d3px := ScaleY(3, DesigntimeDPI);
{$IFEND}
X := Rec.Left + tm; X := Rec.Left + tm;
Y := Rec.Top + tm; Y := Rec.Top + tm;
@ -244,7 +250,7 @@ begin
HeadRect.Left := RealLeft + delta; HeadRect.Left := RealLeft + delta;
HeadRect.Top := RealTop + delta; HeadRect.Top := RealTop + delta;
HeadRect.Right := RealRight - delta; HeadRect.Right := RealRight - delta;
HeadRect.Bottom := RealTop + RenderCanvas.TextHeight('YyGg0') + TextMargin * 2; HeadRect.Bottom := RealTop + RenderCanvas.TextHeight('YyGg0') + FTasklist.TextMargin * 2;
TPSFillRect(RenderCanvas, Angle, RenderIn, HeadRect); TPSFillRect(RenderCanvas, Angle, RenderIn, HeadRect);
{ draw the header cell borders } { draw the header cell borders }
@ -277,13 +283,16 @@ begin
begin begin
w := Round(bmp.Width * Scale); w := Round(bmp.Width * Scale);
h := Round(bmp.Height * Scale); h := Round(bmp.Height * Scale);
GlyphRect.TopLeft := Point(HeadRect.Left + TextMargin, (Headrect.Top + HeadRect.Bottom - h) div 2); GlyphRect.TopLeft := Point(
HeadRect.Left + FTasklist.TextMargin,
(Headrect.Top + HeadRect.Bottom - h) div 2
);
GlyphRect.BottomRight := Point(GlyphRect.Left + w, GlyphRect.Top + h); GlyphRect.BottomRight := Point(GlyphRect.Left + w, GlyphRect.Top + h);
{$IFDEF FPC} {$IFDEF FPC}
RotateBitmap(Bmp, Angle); RotateBitmap(Bmp, Angle);
{$ENDIF} {$ENDIF}
TPSStretchDraw(RenderCanvas, Angle, RenderIn, GlyphRect, Bmp); TPSStretchDraw(RenderCanvas, Angle, RenderIn, GlyphRect, Bmp);
HeadRect.Left := HeadRect.Left + w + TextMargin; HeadRect.Left := HeadRect.Left + w + FTasklist.TextMargin;
end; end;
finally finally
bmp.Free; bmp.Free;
@ -516,7 +525,7 @@ begin
{$IF VP_LCL_SCALING = 0} {$IF VP_LCL_SCALING = 0}
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI); RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
{$ENDIF} {$ENDIF}
RowHeight := RenderCanvas.TextHeight(VpProductName) + TextMargin * 2; RowHeight := RenderCanvas.TextHeight(VpProductName) + FTasklist.TextMargin * 2;
end; end;
procedure TVpTaskListPainter.RenderToCanvas(ARenderIn: TRect; procedure TVpTaskListPainter.RenderToCanvas(ARenderIn: TRect;

View File

@ -136,7 +136,7 @@ type
FAllowDragAndDrop: Boolean; FAllowDragAndDrop: Boolean;
FApplyCategoryInfos: Boolean; FApplyCategoryInfos: Boolean;
FColor: TColor; FColor: TColor;
FColumnWidth: Integer; // FColumnWidth: Integer;
FComponentHint: TTranslateString; FComponentHint: TTranslateString;
FDateLabelFormat: string; FDateLabelFormat: string;
FDayHeadAttributes: TVpDayHeadAttr; FDayHeadAttributes: TVpDayHeadAttr;
@ -151,6 +151,7 @@ type
FMouseEvent: TVpEvent; FMouseEvent: TVpEvent;
FLayout: TVpWeekviewLayout; FLayout: TVpWeekviewLayout;
FShowEventTime: Boolean; FShowEventTime: Boolean;
FTextMargin: Integer;
FTimeFormat: TVpTimeFormat; FTimeFormat: TVpTimeFormat;
FVisibleLines: Integer; FVisibleLines: Integer;
FWeekStartsOn: TVpDayType; FWeekStartsOn: TVpDayType;
@ -189,6 +190,7 @@ type
procedure SetLineColor(Value: TColor); procedure SetLineColor(Value: TColor);
procedure SetPopupMenu(AValue: TPopupMenu); procedure SetPopupMenu(AValue: TPopupMenu);
procedure SetShowEventTime(Value: Boolean); procedure SetShowEventTime(Value: Boolean);
procedure SetTextMargin(Value: Integer);
procedure SetTimeFormat(Value: TVpTimeFormat); procedure SetTimeFormat(Value: TVpTimeFormat);
procedure SetWeekStartsOn(Value: TVpDayType); procedure SetWeekStartsOn(Value: TVpDayType);
@ -300,6 +302,11 @@ type
StartLine: Integer; StopLine: Integer; UseGran: TVpGranularity; StartLine: Integer; StopLine: Integer; UseGran: TVpGranularity;
DisplayOnly: Boolean); override; DisplayOnly: Boolean); override;
{ LCL scaling }
{$IF VP_LCL_SCALING <> 0}
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: Double); override;
{$IFEND}
{$IF VP_LCL_SCALING = 2} {$IF VP_LCL_SCALING = 2}
procedure FixDesignFontsPPI(const ADesignTimePPI: Integer); override; procedure FixDesignFontsPPI(const ADesignTimePPI: Integer); override;
procedure ScaleFontsPPI(const AToPPI: Integer; const AProportion: Double); override; procedure ScaleFontsPPI(const AToPPI: Integer; const AProportion: Double); override;
@ -326,6 +333,7 @@ type
property HintMode: TVpHintMode read FHintMode write FHintMode default hmPlannerHint; property HintMode: TVpHintMode read FHintMode write FHintMode default hmPlannerHint;
property LineColor: TColor read FLineColor write SetLineColor default DEFAULT_LINECOLOR; property LineColor: TColor read FLineColor write SetLineColor default DEFAULT_LINECOLOR;
property Layout: TVpWeekviewLayout read FLayout write SetLayout default wvlVertical; property Layout: TVpWeekviewLayout read FLayout write SetLayout default wvlVertical;
property TextMargin: Integer read FTextMargin write SetTextMargin default TEXT_MARGIN;
property TimeFormat: TVpTimeFormat read FTimeFormat write SetTimeFormat default tf12Hour; property TimeFormat: TVpTimeFormat read FTimeFormat write SetTimeFormat default tf12Hour;
property ShowEventTime: Boolean read FShowEventTime write SetShowEventTime default true; property ShowEventTime: Boolean read FShowEventTime write SetShowEventTime default true;
property WeekStartsOn: TVpDayType read FWeekStartsOn write SetWeekStartsOn default dtSunday; property WeekStartsOn: TVpDayType read FWeekStartsOn write SetWeekStartsOn default dtSunday;
@ -574,10 +582,11 @@ begin
wvPainting := false; wvPainting := false;
FColor := DEFAULT_COLOR; FColor := DEFAULT_COLOR;
FLineColor := DEFAULT_LINECOLOR; FLineColor := DEFAULT_LINECOLOR;
FTextMargin := TEXT_MARGIN;
wvStartDate := trunc(GetStartOfWeek(Now, FWeekStartsOn)); wvStartDate := trunc(GetStartOfWeek(Now, FWeekStartsOn));
FTimeFormat := tf12Hour; FTimeFormat := tf12Hour;
FDateLabelFormat := 'ddddd'; FDateLabelFormat := 'ddddd';
FColumnWidth := 200; // FColumnWidth := 200;
FAllowInplaceEdit := true; FAllowInplaceEdit := true;
{ set up fonts and colors } { set up fonts and colors }
@ -936,6 +945,15 @@ begin
end; end;
end; end;
procedure TVpWeekView.SetTextMargin(Value: Integer);
begin
if Value <> FTextMargin then
begin
FTextMargin := Value;
Invalidate;
end;
end;
procedure TVpWeekView.SetTimeFormat(Value: TVpTimeFormat); procedure TVpWeekView.SetTimeFormat(Value: TVpTimeFormat);
begin begin
if Value <> FTimeFormat then begin if Value <> FTimeFormat then begin
@ -1928,6 +1946,18 @@ begin
end; end;
end; end;
{$IF VP_LCL_SCALING <> 0}
procedure TVpWeekView.DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: Double);
begin
inherited;
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
begin
FTextMargin := round(FTextMargin * AXProportion);
end;
end;
{$IFEND}
{$IF VP_LCL_SCALING = 2} {$IF VP_LCL_SCALING = 2}
procedure TVpWeekView.FixDesignFontsPPI(const ADesignTimePPI: Integer); procedure TVpWeekView.FixDesignFontsPPI(const ADesignTimePPI: Integer);
begin begin

View File

@ -94,6 +94,7 @@ var
ADTextHeight: Integer; ADTextHeight: Integer;
EventStr: string; EventStr: string;
txtDist: Integer; txtDist: Integer;
txtMargin: Integer;
cat: TVpCategoryInfo; cat: TVpCategoryInfo;
savedBrushColor: TColor; savedBrushColor: TColor;
savedPenColor: TColor; savedPenColor: TColor;
@ -110,6 +111,8 @@ begin
{ number of all day events for the range of days covered by the control. } { number of all day events for the range of days covered by the control. }
NumADEvents := 0; NumADEvents := 0;
txtMargin := FWeekView.TextMargin;
savedPenColor := RenderCanvas.Pen.Color; savedPenColor := RenderCanvas.Pen.Color;
savedBrushColor := RenderCanvas.Brush.Color; savedBrushColor := RenderCanvas.Brush.Color;
ADEventsList := TList.Create; ADEventsList := TList.Create;
@ -146,19 +149,19 @@ begin
RenderCanvas.Brush.Color := ADBackgroundColor; RenderCanvas.Brush.Color := ADBackgroundColor;
{ Measure the AllDayEvent TextHeight } { Measure the AllDayEvent TextHeight }
txtDist := TextMargin div 2; txtDist := FWeekView.TextMargin div 2;
RenderCanvas.Font.Assign(FWeekView.AllDayEventAttributes.Font); RenderCanvas.Font.Assign(FWeekView.AllDayEventAttributes.Font);
{$IF VP_LCL_SCALING = 0} {$IF VP_LCL_SCALING = 0}
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI); RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
{$ENDIF} {$ENDIF}
ADTextHeight := RenderCanvas.TextHeight(VpProductName) + TextMargin + txtDist; ADTextHeight := RenderCanvas.TextHeight(VpProductName) + txtMargin + txtDist;
{ Build the AllDayEvent rect based on the value of NumADEvents } { Build the AllDayEvent rect based on the value of NumADEvents }
if AdEventsRect.Top + (NumADEvents * ADTextHeight) + TextMargin * 2 > DayRect.Bottom if AdEventsRect.Top + (NumADEvents * ADTextHeight) + txtMargin * 2 > DayRect.Bottom
then then
ADEventsRect.Bottom := DayRect.Bottom ADEventsRect.Bottom := DayRect.Bottom
else else
ADEventsRect.Bottom := AdEventsRect.Top + NumADEvents * ADTextHeight + TextMargin * 2; ADEventsRect.Bottom := AdEventsRect.Top + NumADEvents * ADTextHeight + txtMargin * 2;
// Clear the AllDayEvents area // Clear the AllDayEvents area
TpsFillRect(RenderCanvas, Angle, RenderIn, ADEventsRect); TpsFillRect(RenderCanvas, Angle, RenderIn, ADEventsRect);
@ -181,7 +184,7 @@ begin
StartsBeforeRange := true; StartsBeforeRange := true;
// Set the event's rect // Set the event's rect
ADEvRect.Top := ADEventsRect.Top + TextMargin + I * ADTextHeight; ADEvRect.Top := ADEventsRect.Top + txtMargin + I * ADTextHeight;
ADEvRect.Bottom := ADEvRect.Top + ADTextHeight; ADEvRect.Bottom := ADEvRect.Top + ADTextHeight;
ADEvRect.Left := AdEventsRect.Left + txtDist; ADEvRect.Left := AdEventsRect.Left + txtDist;
ADEvRect.Right := DayRect.Right; ADEvRect.Right := DayRect.Right;
@ -199,28 +202,28 @@ begin
end; end;
end; end;
TPSRectangle(RenderCanvas, Angle, RenderIn, TPSRectangle(RenderCanvas, Angle, RenderIn,
ADEvRect.Left + TextMargin, ADEvRect.Left + txtMargin,
ADEvRect.Top + txtDist, ADEvRect.Top + txtDist,
ADEvRect.Right - TextMargin, ADEvRect.Right - txtMargin,
ADEvRect.Top + ADTextHeight + txtDist ADEvRect.Top + ADTextHeight + txtDist
); );
// Paint the event string // Paint the event string
EventStr := IfThen(StartsBeforeRange, '>> ', '') + Event.Description; EventStr := IfThen(StartsBeforeRange, '>> ', '') + Event.Description;
EventStr := GetDisplayString(RenderCanvas, EventStr, 0, WidthOf(ADEvRect) - 3*TextMargin); EventStr := GetDisplayString(RenderCanvas, EventStr, 0, WidthOf(ADEvRect) - 3*txtMargin);
TPSTextOut(RenderCanvas,Angle, RenderIn, TPSTextOut(RenderCanvas,Angle, RenderIn,
ADEvRect.Left + TextMargin * 2 + txtDist, ADEvRect.Left + txtMargin * 2 + txtDist,
ADEvRect.Top + TextMargin, ADEvRect.Top + txtMargin,
EventStr EventStr
); );
Result := True; Result := True;
TVpWeekViewOpener(FWeekView).wvEventArray[EAIndex].Rec := Rect( TVpWeekViewOpener(FWeekView).wvEventArray[EAIndex].Rec := Rect(
ADEvRect.Left + TextMargin, ADEvRect.Left + txtMargin,
ADEvRect.Top + TextMargin, ADEvRect.Top + txtMargin,
ADEvRect.Right - TextMargin, ADEvRect.Right - txtMargin,
ADEvRect.Bottom ADEvRect.Bottom
); );
TVpWeekViewOpener(FWeekView).wvEventArray[EAIndex].Event := Event; TVpWeekViewOpener(FWeekView).wvEventArray[EAIndex].Event := Event;
@ -318,7 +321,7 @@ begin
if (FWeekView.DataStore <> nil) and (FWeekView.DataStore.Resource <> nil) and if (FWeekView.DataStore <> nil) and (FWeekView.DataStore.Resource <> nil) and
(FWeekView.DataStore.Resource.Schedule.EventCountByDay(StartDate + ADayIndex) > 0) and (FWeekView.DataStore.Resource.Schedule.EventCountByDay(StartDate + ADayIndex) > 0) and
(HeightOf(DayRect) >= TextMargin * 2 + FDayHeadHeight) (HeightOf(DayRect) >= FWeekView.TextMargin * 2 + FDayHeadHeight)
then begin then begin
// Events exist for this day // Events exist for this day
EventList := TList.Create; EventList := TList.Create;
@ -354,7 +357,7 @@ begin
{ if the TextRect extends below the available space then draw a } { if the TextRect extends below the available space then draw a }
{ dot dot dot to indicate there are more events than can be drawn } { dot dot dot to indicate there are more events than can be drawn }
{ in the available space } { in the available space }
if TextRect.Bottom - TextMargin > DayRect.Bottom then begin if TextRect.Bottom - FWeekView.TextMargin > DayRect.Bottom then begin
{ Draw ". . ." } { Draw ". . ." }
DrawDotDotDot(DayRect, DotDotDotColor); DrawDotDotDot(DayRect, DotDotDotColor);
break; break;
@ -458,11 +461,11 @@ begin
RenderCanvas.Font.Style := RenderCanvas.Font.Style + [fsBold]; RenderCanvas.Font.Style := RenderCanvas.Font.Style + [fsBold];
dayStr := GetDateDisplayString(RenderCanvas, StartDate + ADayIndex, dayStr := GetDateDisplayString(RenderCanvas, StartDate + ADayIndex,
FWeekView.DayHeadAttributes.DateFormat, AHolidayName, WidthOf(TextRect) - TextMargin); FWeekView.DayHeadAttributes.DateFormat, AHolidayName, WidthOf(TextRect) - FWeekView.TextMargin);
strWid := RenderCanvas.TextWidth(dayStr); strWid := RenderCanvas.TextWidth(dayStr);
strH := RenderCanvas.TextHeight(dayStr); strH := RenderCanvas.TextHeight(dayStr);
TextRect.Left := TextRect.Right - strWid - TextMargin; TextRect.Left := TextRect.Right - strWid - FWeekView.TextMargin;
TPSTextOut( TPSTextOut(
RenderCanvas, RenderCanvas,
Angle, Angle,
@ -536,6 +539,7 @@ var
dayStr: String; dayStr: String;
todayStartTime: TDateTime; todayStartTime: TDateTime;
todayEndTime: TDateTime; todayEndTime: TDateTime;
txtMargin: Integer;
strLen: Integer; strLen: Integer;
oldFontColor: TColor; oldFontColor: TColor;
eventCat: TVpCategoryInfo; eventCat: TVpCategoryInfo;
@ -543,6 +547,8 @@ var
begin begin
oldFontColor := RenderCanvas.Font.Color; oldFontColor := RenderCanvas.Font.Color;
txtmargin := FWeekView.TextMargin;
{ format the display text } { format the display text }
todayStartTime := AEvent.StartTime; todayStartTime := AEvent.StartTime;
todayEndTime := AEvent.EndTime; todayEndTime := AEvent.EndTime;
@ -585,12 +591,12 @@ begin
{ Build the event text } { Build the event text }
dayStr := FWeekView.BuildEventString(AEvent, todayStartTime, todayEndTime, false); dayStr := FWeekView.BuildEventString(AEvent, todayStartTime, todayEndTime, false);
strLen := RenderCanvas.TextWidth(dayStr); strLen := RenderCanvas.TextWidth(dayStr);
if (strLen > WidthOf(TextRect) - 2*TextMargin) then if (strLen > WidthOf(TextRect) - txtMargin * 2) then
dayStr := GetDisplayString(RenderCanvas, dayStr, 0, WidthOf(TextRect) - TextMargin * 2); dayStr := GetDisplayString(RenderCanvas, dayStr, 0, WidthOf(TextRect) - txtMargin * 2);
{ Write the event text } { Write the event text }
TPSTextOut(RenderCanvas, Angle, RenderIn, TPSTextOut(RenderCanvas, Angle, RenderIn,
TextRect.Left + TextMargin, TextRect.Top + TextMargin div 2, TextRect.Left + txtMargin, TextRect.Top + txtMargin div 2,
dayStr dayStr
); );
@ -606,6 +612,7 @@ var
weekNo: Integer; weekNo: Integer;
startStr, endStr: String; startStr, endStr: String;
txtStart: Integer; txtStart: Integer;
txtMargin: Integer;
begin begin
RenderCanvas.Brush.Color := RealHeadAttrColor; RenderCanvas.Brush.Color := RealHeadAttrColor;
RenderCanvas.Font.Assign(TFont(FWeekView.HeadAttributes.Font)); RenderCanvas.Font.Assign(TFont(FWeekView.HeadAttributes.Font));
@ -613,6 +620,8 @@ begin
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI); RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
{$ENDIF} {$ENDIF}
txtMargin := FWeekView.TextMargin;
{ draw the header cell and borders } { draw the header cell and borders }
if FWeekView.DrawingStyle = ds3d then begin if FWeekView.DrawingStyle = ds3d then begin
{ draw a 3d bevel } { draw a 3d bevel }
@ -641,7 +650,7 @@ begin
{ draw the text } { draw the text }
if DisplayOnly and (RenderCanvas.TextWidth(HeadStr) >= WidthOf(RenderIn)) then if DisplayOnly and (RenderCanvas.TextWidth(HeadStr) >= WidthOf(RenderIn)) then
HeadTextRect.TopLeft:= Point(RealLeft + TextMargin * 2, HeadRect.Top) HeadTextRect.TopLeft:= Point(RealLeft + txtMargin * 2, HeadRect.Top)
else else
if DisplayOnly then if DisplayOnly then
HeadTextRect.TopLeft := Point( HeadTextRect.TopLeft := Point(
@ -650,17 +659,17 @@ begin
) )
else else
HeadTextRect.TopLeft := Point( HeadTextRect.TopLeft := Point(
RealLeft + Trunc(TVpWeekViewOpener(FWeekView).wvHeaderHeight * 0.8) * 2 + TextMargin * 2, RealLeft + Trunc(TVpWeekViewOpener(FWeekView).wvHeaderHeight * 0.8) * 2 + txtMargin * 2,
HeadRect.Top HeadRect.Top
); );
HeadTextRect.BottomRight := HeadRect.BottomRight; HeadTextRect.BottomRight := HeadRect.BottomRight;
{ Fix Header String } { Fix Header String }
HeadStrLen := RenderCanvas.TextWidth(HeadStr); HeadStrLen := RenderCanvas.TextWidth(HeadStr);
if HeadStrLen > HeadTextRect.Right - HeadTextRect.Left - TextMargin then if HeadStrLen > HeadTextRect.Right - HeadTextRect.Left - txtMargin then
begin begin
HeadStr := GetDisplayString(RenderCanvas, HeadStr, 0, HeadStr := GetDisplayString(RenderCanvas, HeadStr, 0,
HeadTextRect.Right - HeadTextRect.Left - TextMargin ); HeadTextRect.Right - HeadTextRect.Left - txtMargin );
end; end;
{ Position the spinner } { Position the spinner }
@ -698,11 +707,19 @@ end;
procedure TVpWeekViewPainter.FixFontHeights; procedure TVpWeekViewPainter.FixFontHeights;
begin begin
with FWeekView do begin with FWeekView do begin
{$IF VP_LCL_SCALING = 0}
AllDayEventAttributes.Font.Height := GetRealFontHeight(AllDayEventAttributes.Font); AllDayEventAttributes.Font.Height := GetRealFontHeight(AllDayEventAttributes.Font);
DayHeadAttributes.Font.Height := GetRealFontHeight(DayHeadAttributes.Font); DayHeadAttributes.Font.Height := GetRealFontHeight(DayHeadAttributes.Font);
EventFont.Height := GetRealFontHeight(EventFont); EventFont.Height := GetRealFontHeight(EventFont);
Font.Height := GetRealFontHeight(Font); Font.Height := GetRealFontHeight(Font);
HeadAttributes.Font.Height := GetRealFontHeight(HeadAttributes.Font); HeadAttributes.Font.Height := GetRealFontHeight(HeadAttributes.Font);
{$ELSE}
AllDayEventAttributes.Font.Height := FixFontHeight(AllDayEventAttributes.Font);
DayHeadAttributes.Font.Height := FixFontHeight(DayHeadAttributes.Font);
EventFont.Height := FixFontHeight(EventFont);
Font.Height := FixFontHeight(Font);
HeadAttributes.Font.Height := FixFontHeight(HeadAttributes.Font);
{$IFEND}
end; end;
end; end;
@ -789,21 +806,21 @@ begin
{$IF VP_LCL_SCALING = 0} {$IF VP_LCL_SCALING = 0}
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI); RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
{$ENDIF} {$ENDIF}
FDayHeadHeight := RenderCanvas.TextHeight(VpProductName) + TextMargin + 2 ; FDayHeadHeight := RenderCanvas.TextHeight(VpProductName) + FWeekView.TextMargin + 2 ;
RenderCanvas.Font.Assign(FWeekView.EventFont); RenderCanvas.Font.Assign(FWeekView.EventFont);
{$IF VP_LCL_SCALING = 0} {$IF VP_LCL_SCALING = 0}
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI); RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
{$ENDIF} {$ENDIF}
with TVpWeekViewOpener(FWeekView) do with TVpWeekViewOpener(FWeekView) do
wvRowHeight := RenderCanvas.TextHeight(VpProductName) + TextMargin div 2; wvRowHeight := RenderCanvas.TextHeight(VpProductName) + FWeekView.TextMargin div 2;
RenderCanvas.Font.Assign(TFont(FWeekView.HeadAttributes.Font)); RenderCanvas.Font.Assign(TFont(FWeekView.HeadAttributes.Font));
{$IF VP_LCL_SCALING = 0} {$IF VP_LCL_SCALING = 0}
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI); RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
{$ENDIF} {$ENDIF}
with TVpWeekViewOpener(FWeekView) do with TVpWeekViewOpener(FWeekView) do
wvHeaderHeight := RenderCanvas.TextHeight(VpProductName) + TextMargin * 2; wvHeaderHeight := RenderCanvas.TextHeight(VpProductName) + FWeekView.TextMargin * 2;
end; end;
end. end.