From 30acf7208e6db4efbe9c21086f11469b6d98067c Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Fri, 2 Sep 2022 17:38:26 +0000 Subject: [PATCH] tvplanit: Improving LCL scaling. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8438 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../tvplanit/examples/fulldemo/demo.lpi | 1 + .../tvplanit/examples/fulldemo/demo.lpr | 1 + .../tvplanit/examples/fulldemo/demomain.lfm | 14 +- .../tvplanit/examples/fulldemo/demomain.pas | 2 +- components/tvplanit/languages/vpsr.de.po | 4 + components/tvplanit/languages/vpsr.en.po | 4 + components/tvplanit/languages/vpsr.fi.po | 4 + components/tvplanit/languages/vpsr.fr.po | 4 + components/tvplanit/languages/vpsr.nl.po | 4 + components/tvplanit/languages/vpsr.pl.po | 4 + components/tvplanit/languages/vpsr.pot | 4 + components/tvplanit/languages/vpsr.ru.po | 4 + components/tvplanit/source/include/vpsr.inc | 1 + components/tvplanit/source/vpconst.pas | 2 +- components/tvplanit/source/vpcontactgrid.pas | 36 ++++- .../tvplanit/source/vpcontactgridpainter.pas | 150 +++++++++--------- components/tvplanit/source/vpdayview.pas | 42 +++++ .../tvplanit/source/vpdayviewpainter.pas | 45 ++++-- components/tvplanit/source/vpganttview.pas | 3 + .../tvplanit/source/vpimportpreview.lfm | 5 +- .../tvplanit/source/vpimportpreview.pas | 20 ++- .../source/vpimportpreview_icalevent.lfm | 6 +- .../tvplanit/source/vpimportpreview_vcard.lfm | 6 +- components/tvplanit/source/vpmisc.pas | 6 + components/tvplanit/source/vpmonthview.pas | 38 ++++- .../tvplanit/source/vpmonthviewpainter.pas | 43 +++-- components/tvplanit/source/vptasklist.pas | 30 ++++ .../tvplanit/source/vptasklistpainter.pas | 23 ++- components/tvplanit/source/vpweekview.pas | 34 +++- .../tvplanit/source/vpweekviewpainter.pas | 71 +++++---- 30 files changed, 448 insertions(+), 163 deletions(-) diff --git a/components/tvplanit/examples/fulldemo/demo.lpi b/components/tvplanit/examples/fulldemo/demo.lpi index 6728c43de..3bb87dc24 100644 --- a/components/tvplanit/examples/fulldemo/demo.lpi +++ b/components/tvplanit/examples/fulldemo/demo.lpi @@ -9,6 +9,7 @@ + <Scaled Value="True"/> <ResourceType Value="res"/> <UseXPManifest Value="True"/> <XPManifest> diff --git a/components/tvplanit/examples/fulldemo/demo.lpr b/components/tvplanit/examples/fulldemo/demo.lpr index 7ea82f940..5de61a7ad 100644 --- a/components/tvplanit/examples/fulldemo/demo.lpr +++ b/components/tvplanit/examples/fulldemo/demo.lpr @@ -14,6 +14,7 @@ uses begin RequireDerivedFormResource := True; + Application.Scaled:=True; Application.Initialize; Application.CreateForm(TDemoDM, DemoDM); Application.CreateForm(TMainForm, MainForm); diff --git a/components/tvplanit/examples/fulldemo/demomain.lfm b/components/tvplanit/examples/fulldemo/demomain.lfm index 948446ba5..04cfc6d6b 100644 --- a/components/tvplanit/examples/fulldemo/demomain.lfm +++ b/components/tvplanit/examples/fulldemo/demomain.lfm @@ -4,13 +4,12 @@ object MainForm: TMainForm Top = 134 Width = 959 Caption = 'Turbo Power VisualPlanIt Demo' - ClientHeight = 576 + ClientHeight = 596 ClientWidth = 959 Menu = MainMenu1 OnCloseQuery = FormCloseQuery OnCreate = FormCreate OnDestroy = FormDestroy - LCLVersion = '2.3.0.0' object Panel1: TPanel Left = 125 Height = 596 @@ -81,6 +80,7 @@ object MainForm: TMainForm Top = 351 Width = 357 ShowHint = True + PopupMenu = VpMonthView1.default ControlLink = VpControlLink1 ParentShowHint = False Align = alBottom @@ -88,7 +88,7 @@ object MainForm: TMainForm DayHeadAttributes.Color = clBtnFace DrawingStyle = dsFlat EventDayStyle = [fsItalic] - HeadAttributes.Font.Height = -13 + HeadAttributes.Font.Height = -16 HeadAttributes.Font.Style = [fsItalic] HeadAttributes.Color = clBtnFace HolidayAttributes.Font.Color = clBlack @@ -114,6 +114,7 @@ object MainForm: TMainForm Top = 34 Width = 357 ShowHint = True + PopupMenu = VpDayView1.default ControlLink = VpControlLink1 Font.Height = -12 ParentFont = False @@ -129,7 +130,7 @@ object MainForm: TMainForm TimeSlotColors.Active = clWhite TimeSlotColors.ActiveRange.RangeBegin = h_00 TimeSlotColors.ActiveRange.RangeEnd = h_00 - HeadAttributes.Font.Height = -13 + HeadAttributes.Font.Height = -16 HeadAttributes.Font.Style = [fsItalic] HeadAttributes.Color = clBtnFace RowHeadAttributes.HourFont.Height = -24 @@ -288,6 +289,7 @@ object MainForm: TMainForm Top = 0 Width = 472 ShowHint = True + PopupMenu = VpWeekView1.default ControlLink = VpControlLink1 Font.Height = -12 ParentFont = False @@ -302,7 +304,7 @@ object MainForm: TMainForm DayHeadAttributes.Font.Height = -13 DrawingStyle = dsFlat EventFont.Height = -12 - HeadAttributes.Font.Height = -13 + HeadAttributes.Font.Height = -16 HeadAttributes.Font.Style = [fsItalic] HeadAttributes.Color = clBtnFace LineColor = clGray @@ -360,6 +362,7 @@ object MainForm: TMainForm Height = 501 Top = 27 Width = 834 + PopupMenu = VpTaskList1.default ControlLink = VpControlLink1 ParentFont = False Align = alClient @@ -400,6 +403,7 @@ object MainForm: TMainForm Height = 528 Top = 0 Width = 794 + PopupMenu = VpContactGrid1.default ControlLink = VpControlLink1 ParentFont = False Align = alClient diff --git a/components/tvplanit/examples/fulldemo/demomain.pas b/components/tvplanit/examples/fulldemo/demomain.pas index f46a803db..753673c47 100644 --- a/components/tvplanit/examples/fulldemo/demomain.pas +++ b/components/tvplanit/examples/fulldemo/demomain.pas @@ -10,7 +10,7 @@ uses {$ENDIF} Classes, fgl, SysUtils, FileUtil, 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, VpMonthView, VpResEditDlg, VpContactButtons, VpNavBar, VpData, VpPrtPrvDlg, VpPrtFmtDlg, VpBase; diff --git a/components/tvplanit/languages/vpsr.de.po b/components/tvplanit/languages/vpsr.de.po index 10ff5be5b..9ad775439 100644 --- a/components/tvplanit/languages/vpsr.de.po +++ b/components/tvplanit/languages/vpsr.de.po @@ -575,6 +575,10 @@ msgstr "Stunden" msgid "iCalendar files (*.ical;*.ics)|*.ical;*.ics" msgstr "iCalendar Dateien ('*.ical;*.ics)|*.ical;*.ics" +#: vpsr.rsimportcheckeditems +msgid "Import checked items" +msgstr "Markierte Einträge importieren" + #: vpsr.rsimporticalevent msgid "Import ICalendar Event" msgstr "iCalendar-Termin importieren" diff --git a/components/tvplanit/languages/vpsr.en.po b/components/tvplanit/languages/vpsr.en.po index e2816f319..173ba346e 100644 --- a/components/tvplanit/languages/vpsr.en.po +++ b/components/tvplanit/languages/vpsr.en.po @@ -569,6 +569,10 @@ msgstr "Hours" msgid "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 msgid "Import ICalendar Event" msgstr "Import ICalendar Event" diff --git a/components/tvplanit/languages/vpsr.fi.po b/components/tvplanit/languages/vpsr.fi.po index 0cf78c729..366dade4d 100644 --- a/components/tvplanit/languages/vpsr.fi.po +++ b/components/tvplanit/languages/vpsr.fi.po @@ -566,6 +566,10 @@ msgstr "Tunnit" msgid "iCalendar files (*.ical;*.ics)|*.ical;*.ics" msgstr "" +#: vpsr.rsimportcheckeditems +msgid "Import checked items" +msgstr "" + #: vpsr.rsimporticalevent msgid "Import ICalendar Event" msgstr "" diff --git a/components/tvplanit/languages/vpsr.fr.po b/components/tvplanit/languages/vpsr.fr.po index 1cca2902b..f17cf5a48 100644 --- a/components/tvplanit/languages/vpsr.fr.po +++ b/components/tvplanit/languages/vpsr.fr.po @@ -581,6 +581,10 @@ msgstr "Heures" msgid "iCalendar files (*.ical;*.ics)|*.ical;*.ics" msgstr "" +#: vpsr.rsimportcheckeditems +msgid "Import checked items" +msgstr "" + #: vpsr.rsimporticalevent msgid "Import ICalendar Event" msgstr "" diff --git a/components/tvplanit/languages/vpsr.nl.po b/components/tvplanit/languages/vpsr.nl.po index b91c7ef7a..61b26e4f4 100644 --- a/components/tvplanit/languages/vpsr.nl.po +++ b/components/tvplanit/languages/vpsr.nl.po @@ -575,6 +575,10 @@ msgstr "Uren" msgid "iCalendar files (*.ical;*.ics)|*.ical;*.ics" msgstr "" +#: vpsr.rsimportcheckeditems +msgid "Import checked items" +msgstr "" + #: vpsr.rsimporticalevent msgid "Import ICalendar Event" msgstr "" diff --git a/components/tvplanit/languages/vpsr.pl.po b/components/tvplanit/languages/vpsr.pl.po index add33f03c..63db4fabf 100644 --- a/components/tvplanit/languages/vpsr.pl.po +++ b/components/tvplanit/languages/vpsr.pl.po @@ -575,6 +575,10 @@ msgstr "Godziny" msgid "iCalendar files (*.ical;*.ics)|*.ical;*.ics" msgstr "Pliki iCalendar (*.ical;*.ics)|*.ical;*.ics" +#: vpsr.rsimportcheckeditems +msgid "Import checked items" +msgstr "" + #: vpsr.rsimporticalevent msgid "Import ICalendar Event" msgstr "" diff --git a/components/tvplanit/languages/vpsr.pot b/components/tvplanit/languages/vpsr.pot index 109be3929..3cbc8fe49 100644 --- a/components/tvplanit/languages/vpsr.pot +++ b/components/tvplanit/languages/vpsr.pot @@ -559,6 +559,10 @@ msgstr "" msgid "iCalendar files (*.ical;*.ics)|*.ical;*.ics" msgstr "" +#: vpsr.rsimportcheckeditems +msgid "Import checked items" +msgstr "" + #: vpsr.rsimporticalevent msgid "Import ICalendar Event" msgstr "" diff --git a/components/tvplanit/languages/vpsr.ru.po b/components/tvplanit/languages/vpsr.ru.po index 484627e9c..ad713529c 100644 --- a/components/tvplanit/languages/vpsr.ru.po +++ b/components/tvplanit/languages/vpsr.ru.po @@ -575,6 +575,10 @@ msgstr "Часы" msgid "iCalendar files (*.ical;*.ics)|*.ical;*.ics" msgstr "" +#: vpsr.rsimportcheckeditems +msgid "Import checked items" +msgstr "" + #: vpsr.rsimporticalevent msgid "Import ICalendar Event" msgstr "" diff --git a/components/tvplanit/source/include/vpsr.inc b/components/tvplanit/source/include/vpsr.inc index fa5ade1e3..20383a8cf 100644 --- a/components/tvplanit/source/include/vpsr.inc +++ b/components/tvplanit/source/include/vpsr.inc @@ -200,6 +200,7 @@ resourcestring RSNoContactsFoundInVCARD = 'No contact items found in "%s".'; RSAssignedCategory = 'Assigned category'; RSEventItems = 'Event items'; + RSImportCheckedItems = 'Import checked items'; {Task Specific} RSConfirmDeleteTask = 'Delete this task from your list?'; diff --git a/components/tvplanit/source/vpconst.pas b/components/tvplanit/source/vpconst.pas index d2a6c1bbb..09f0e0164 100644 --- a/components/tvplanit/source/vpconst.pas +++ b/components/tvplanit/source/vpconst.pas @@ -75,7 +75,7 @@ const MaxDateLen = 40; { maximum length of date picture strings } MaxMonthName = 15; { maximum length for month 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 } { visible at any one time } MaxEventDepth = 50; { the maximum number of side by side } diff --git a/components/tvplanit/source/vpcontactgrid.pas b/components/tvplanit/source/vpcontactgrid.pas index 48b82149d..dc37877fb 100644 --- a/components/tvplanit/source/vpcontactgrid.pas +++ b/components/tvplanit/source/vpcontactgrid.pas @@ -115,8 +115,10 @@ type FExternalPopup: TPopupMenu; FHintMode: TVpHintMode; FPendingDatastore: TVpCustomDatastore; + FTextMargin: Integer; procedure InternalSetDatastore(const Value: TVpCustomDatastore); procedure SetPopupMenu(AValue: TPopupMenu); + procedure SetTextMargin(AValue: Integer); protected{ private } FColumnWidth : Integer; FColor : TColor; @@ -259,6 +261,11 @@ type { - Added to support the buttonbar component. } 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} procedure FixDesignFontsPPI(const ADesignTimePPI: Integer); override; procedure ScaleFontsPPI(const AToPPI: Integer; const AProportion: Double); override; @@ -299,6 +306,8 @@ type read FPrintNumColumns write SetPrintNumColumns default 3; property SortBy: TVpContactSort read FSortBy write SetSortBy default csLastFirst; + property TextMargin: Integer + read FTextMargin write SetTextMargin default TEXT_MARGIN; { events } property BeforeEdit: TVpEditContactEvent @@ -481,6 +490,7 @@ begin cgCreatingEditor := false; FDrawingStyle := ds3d; cgPainting := false; + FTextMargin := TEXT_MARGIN; FColor := DEFAULT_COLOR; FBarColor := DEFAULT_LINECOLOR; BarWidth := 3; @@ -488,7 +498,7 @@ begin FContactIndex := -1; FPrintNumColumns := 3; - { initialize the bar arrays. } + // Initialize the bar arrays. SetLength(cgBarArray, MaxColumns); for I := 0 to pred(Length(cgBarArray)) do begin cgBarArray[I].Rec := Rect(-1, -1, -1, -1); @@ -517,7 +527,6 @@ begin cgHookUp; end; -{=====} destructor TVpContactGrid.Destroy; begin @@ -1865,7 +1874,15 @@ begin Invalidate; end; end; -{=====} + +procedure TVpContactGrid.SetTextMargin(AValue: Integer); +begin + if AValue <> FTextMargin then + begin + FTextMargin := AValue; + Invalidate; + end; +end; function TVpContactGrid.GetContactIndexByCoord(Pnt: TPoint): Integer; var @@ -1933,6 +1950,19 @@ begin AContact.EMail3 := AEMail; 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} procedure TVpContactGrid.FixDesignFontsPPI(const ADesignTimePPI: Integer); begin diff --git a/components/tvplanit/source/vpcontactgridpainter.pas b/components/tvplanit/source/vpcontactgridpainter.pas index b8207ed52..1444ee926 100644 --- a/components/tvplanit/source/vpcontactgridpainter.pas +++ b/components/tvplanit/source/vpcontactgridpainter.pas @@ -126,71 +126,73 @@ procedure TVpContactGridPainter.DrawContactLine(ABitmap: TBitmap; var txtheight: Integer; txtColWidth: Integer; + txtMargin: Integer; begin if AText = '' then begin ATextRect := Rect(0, 0, 0, 0); exit; end; + txtMargin := FContactGrid.TextMargin; txtHeight := ABitmap.Canvas.TextHeight(VpProductName); case Angle of ra0: begin - ATextRect.Left := TextMargin; - ATextRect.Top := AWholeRect.Bottom + TextMargin div 2; + ATextRect.Left := txtMargin; + ATextRect.Top := AWholeRect.Bottom + txtMargin div 2; ATextRect.Right := ABitmap.Width; - ATextRect.Bottom := ATextRect.Top + txtHeight + TextMargin div 2; + ATextRect.Bottom := ATextRect.Top + txtHeight + txtMargin div 2; AWholeRect.Bottom := ATextRect.Bottom; txtColWidth := ABitmap.Width; end; ra90: begin - ATextRect.Left := AWholeRect.Left - txtHeight + TextMargin div 2; - ATextRect.Top := TextMargin; - ATextRect.Right := AWholeRect.Left - TextMargin div 2; - ATextRect.Bottom := AWholeRect.Bottom + TextMargin div 2; + ATextRect.Left := AWholeRect.Left - txtHeight + txtMargin div 2; + ATextRect.Top := txtMargin; + ATextRect.Right := AWholeRect.Left - txtMargin div 2; + ATextRect.Bottom := AWholeRect.Bottom + txtMargin div 2; AWholeRect.Left := ATextRect.Left; txtColWidth := ABitmap.Height; end; ra180: begin - ATextRect.Left := AWholeRect.Right - TextMargin * 2; // Shouldn't this be "div 2" ? - ATextRect.Top := AWholeRect.Top - txtHeight - TextMargin; - ATextRect.Right := AWholeRect.Left + TextMargin; - ATextRect.Bottom := AWholeRect.Top - TextMargin div 2; + ATextRect.Left := AWholeRect.Right - txtMargin * 2; // Shouldn't this be "div 2" ? + ATextRect.Top := AWholeRect.Top - txtHeight - txtMargin; + ATextRect.Right := AWholeRect.Left + txtMargin; + ATextRect.Bottom := AWholeRect.Top - txtMargin div 2; AWholeRect.Top := ATextRect.Top; txtColWidth := ABitmap.Width; end; ra270: begin ATextRect.Left := AWholeRect.Right; - ATextRect.Top := AWholeRect.Bottom - TextMargin; - ATextRect.Right := AWholeRect.Right + txtHeight + TextMargin div 2; - ATextRect.Bottom := AWholeRect.Top + TextMargin div 2; + ATextRect.Top := AWholeRect.Bottom - txtMargin; + ATextRect.Right := AWholeRect.Right + txtHeight + txtMargin div 2; + ATextRect.Bottom := AWholeRect.Top + txtMargin div 2; AWholeRect.Right := ATextRect.Right; txtColWidth := ABitmap.Height; end; 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 TPSTextOutAtPoint( ABitmap.Canvas, Angle, Rect(0, 0, ABitmap.Width, ABitmap.Height), - ATextRect.Left + TextMargin, - ATextRect.Top + TextMargin div 2, + ATextRect.Left + txtMargin, + ATextRect.Top + txtMargin div 2, ALabel ); with ATextRect do case Angle of - ra0 : TopLeft := Point(Left + PhoneLblWidth, Top + TextMargin div 2); - ra90 : TopLeft := Point(Top + PhoneLblWidth, Left + TextMargin); - ra180 : TopLeft := Point(Left - PhoneLblWidth, top + TextMargin div 2); - ra270 : TopLeft := Point(Left + TextMargin div 2, Top - PhoneLblWidth); + ra0 : TopLeft := Point(Left + PhoneLblWidth, Top + txtMargin div 2); + ra90 : TopLeft := Point(Top + PhoneLblWidth, Left + txtMargin); + ra180 : TopLeft := Point(Left - PhoneLblWidth, top + txtMargin div 2); + ra270 : TopLeft := Point(Left + txtMargin div 2, Top - PhoneLblWidth); end; TPSTextOutAtPoint( ABitmap.Canvas, @@ -205,8 +207,8 @@ begin ABitmap.Canvas, Angle, Rect(0, 0, ABitmap.Width, ABitmap.Height), - ATextRect.Left + TextMargin, - ATextRect.Top + TextMargin div 2, + ATextRect.Left + txtMargin, + ATextRect.Top + txtMargin div 2, AText ); end; @@ -239,6 +241,7 @@ var contactCount: Integer; baseTextHeight: Integer; maxTextWidth: Integer; + txtMargin: Integer; begin { if the component is sufficiently small then no sense in painting it } if (FContactGrid.Height < 20) then exit; @@ -258,16 +261,18 @@ begin TextXOffset := 0; TextYOffset := 0; + txtMargin := FContactGrid.TextMargin; + { create a temporary bitmap for painting the items } TmpBmp := TBitmap.Create; try if (Angle = ra0) or (Angle = ra180) then begin - TmpBmp.Width := RealColumnWidth - TextMargin * 4 + 4; // wp:+4 - TmpBmp.Height := RealHeight - TextMargin * 2; + TmpBmp.Width := RealColumnWidth - txtMargin * 4 + 4; // wp:+4 + TmpBmp.Height := RealHeight - txtMargin * 2; TextColWidth := TmpBmp.Width; end else begin - TmpBmp.Height := RealColumnWidth - TextMargin * 4 + 4; // wp: +4 - TmpBmp.Width := RealHeight - TextMargin * 2; + TmpBmp.Height := RealColumnWidth - txtMargin * 4 + 4; // wp: +4 + TmpBmp.Width := RealHeight - txtMargin * 2; TextColWidth := TmpBmp.Height; end; TmpBmpRect := Rect(0, 0, TmpBmp.Width, TmpBmp.Height); @@ -297,18 +302,18 @@ begin { Set the anchor starting point } case Angle of ra0: - Anchor := Point(2 + TextMargin * 2, 2 + TextMargin * 2); + Anchor := Point(2 + txtMargin * 2, 2 + txtMargin * 2); ra90: - Anchor := Point(2 + TextMargin * 2, 2 + TextMargin * 2); + Anchor := Point(2 + txtMargin * 2, 2 + txtMargin * 2); ra180: Anchor := Point( - RenderIn.Right - RenderIn.Left - TmpBmp.Width - 2 - TextMargin * 2, - TmpBmp.Height - 2 - TextMargin * 2 + RenderIn.Right - RenderIn.Left - TmpBmp.Width - 2 - txtMargin * 2, + TmpBmp.Height - 2 - txtMargin * 2 ); ra270: Anchor := Point( - 2 + TextMargin * 2, - RenderIn.Bottom - RenderIn.Top - TmpBmp.Height - 2 - TextMargin * 2 + 2 + txtMargin * 2, + RenderIn.Bottom - RenderIn.Top - TmpBmp.Height - 2 - txtMargin * 2 ); end; RecsInCol := 0; @@ -340,14 +345,14 @@ begin HeadRect.TopLeft := Point(0, 0); HeadRect.BottomRight := Point( TmpBmp.Width, - HeadRect.Top + baseTextHeight + TextMargin div 2 + HeadRect.Top + baseTextHeight + txtMargin div 2 ); WholeRect.BottomRight := HeadRect.BottomRight; end; ra90: // TO DO: CHECK CORRECT USAGE OF TextMargin HERE !!!!!!!!! begin HeadRect.TopLeft := Point( - TmpBmpRect.Right - TextMargin - baseTextHeight + TextMargin div 2, + TmpBmpRect.Right - txtMargin - baseTextHeight + txtMargin div 2, 0 ); HeadRect.BottomRight := Point(TmpBmpRect.Right, TmpBmp.Height); @@ -358,21 +363,21 @@ begin begin WholeRect.BottomRight := Point(TmpBmp.Width, TmpBmp.Height); HeadRect.TopLeft := Point( - TextMargin, - TmpBmpRect.Bottom - baseTextHeight - TextMargin + txtMargin, + TmpBmpRect.Bottom - baseTextHeight - txtMargin ); HeadRect.BottomRight := Point( TmpBmp.Width, - TmpBmp.Height - TextMargin div 2 + TmpBmp.Height - txtMargin div 2 ); WholeRect.TopLeft := HeadRect.TopLeft; end; ra270: begin WholeRect.TopLeft := Point(0, 0); - HeadRect.TopLeft := Point(0, TextMargin); + HeadRect.TopLeft := Point(0, txtMargin); HeadRect.BottomRight := Point( - TextMargin + baseTextHeight + TextMargin div 2, + txtMargin + baseTextHeight + txtMargin div 2, TmpBmp.Height ); WholeRect.BottomRight := HeadRect.BottomRight; @@ -394,18 +399,18 @@ begin case Angle of ra90: begin - TextXOffset := WidthOf(HeadRect) - TextMargin div 2; - TextYOffset := TextMargin div 3; + TextXOffset := WidthOf(HeadRect) - txtMargin div 2; + TextYOffset := txtMargin div 3; end; ra180: begin - TextXOffset := WidthOf(HeadRect) - TextMargin; - TextYOffset := HeightOf(HeadRect) - TextMargin div 3; + TextXOffset := WidthOf(HeadRect) - txtMargin; + TextYOffset := HeightOf(HeadRect) - txtMargin div 3; end; ra270: begin - TextXOffset := TextMargin div 2; - TextYOffset := HeightOf(HeadRect) - TextMargin div 3; + TextXOffset := txtMargin div 2; + TextYOffset := HeightOf(HeadRect) - txtMargin div 3; end; end; @@ -415,14 +420,14 @@ begin else maxTextWidth := HeightOf(HeadRect); Str := AssembleName(TmpCon); - Str := GetDisplayString(TmpBmp.Canvas, Str, 2, maxTextWidth - TextMargin); + Str := GetDisplayString(TmpBmp.Canvas, Str, 2, maxTextWidth - txtMargin); TPSTextOutAtPoint( TmpBmp.Canvas, Angle, TmpBmpRect, - HeadRect.Left + TextMargin div 2 + TextXOffset, - HeadRect.Top + TextMargin div 3 + TextYOffset, + HeadRect.Left + txtMargin div 2 + TextXOffset, + HeadRect.Top + txtMargin div 3 + TextYOffset, Str ); @@ -474,11 +479,11 @@ begin if RecsInCol > 0 then case Angle of 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 Anchor := Point( - Anchor.x + WholeRect.Right + FContactGrid.BarWidth + 1 + TextMargin * 3, - 2 + TextMargin * 2 + Anchor.x + WholeRect.Right + FContactGrid.BarWidth + 1 + txtMargin * 3, + 2 + txtMargin * 2 ); if Col = 1 then TVpContactGridOpener(FContactGrid).cgCol1RecCount := RecsInCol; @@ -488,10 +493,10 @@ begin Exit; end; 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 - Anchor.x := 2 + TextMargin * 2; - Anchor.y := Anchor.y + WholeRect.Bottom + FContactGrid.BarWidth + 1 + TextMargin * 3; + Anchor.x := 2 + txtMargin * 2; + Anchor.y := Anchor.y + WholeRect.Bottom + FContactGrid.BarWidth + 1 + txtMargin * 3; if Col = 1 then TVpContactGridOpener(FContactGrid).cgCol1RecCount := RecsInCol; Inc(Col); @@ -500,10 +505,10 @@ begin Exit; end; 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 - Anchor.x := Anchor.x - (WholeRect.Right + FContactGrid.BarWidth + 1 + TextMargin * 3); - Anchor.y := TmpBmp.Height - 2 - TextMargin * 2; + Anchor.x := Anchor.x - (WholeRect.Right + FContactGrid.BarWidth + 1 + txtMargin * 3); + Anchor.y := TmpBmp.Height - 2 - txtMargin * 2; if Col = 1 then TVpContactGridOpener(FContactGrid).cgCol1RecCount := RecsInCol; Inc(Col); @@ -512,10 +517,10 @@ begin Exit; end; 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 - Anchor.x := 2 + TextMargin * 2; - Anchor.y := Anchor.y - (WholeRect.Bottom + FContactGrid.BarWidth + 1 + TextMargin * 3); + Anchor.x := 2 + txtMargin * 2; + Anchor.y := Anchor.y - (WholeRect.Bottom + FContactGrid.BarWidth + 1 + txtMargin * 3); if Col = 1 then TVpContactGridOpener(FContactGrid).cgCol1RecCount := RecsInCol; Inc(Col); @@ -527,10 +532,10 @@ begin { add a little spacing between records } case Angle of - ra0 : WholeRect.Bottom := WholeRect.Bottom + TextMargin * 2; - ra90 : WholeRect.Left := WholeRect.Left - TextMargin * 2; - ra180 : WholeRect.Top := WholeRect.Top - TextMargin * 2; - ra270 : WholeRect.Right := WholeRect.Right + TextMargin * 2; + ra0 : WholeRect.Bottom := WholeRect.Bottom + txtMargin * 2; + ra90 : WholeRect.Left := WholeRect.Left - txtMargin * 2; + ra180 : WholeRect.Top := WholeRect.Top - txtMargin * 2; + ra270 : WholeRect.Right := WholeRect.Right + txtMargin * 2; end; { Update Array Rects } @@ -679,8 +684,8 @@ begin TVpContactGridOpener(FContactGrid).cgBarArray[BarCount].Index := BarCount; for I := 1 to FContactGrid.BarWidth do begin - TPSMoveTo(RenderCanvas, Angle, RenderIn, BarPos, RealTop + 2 + TextMargin * 2); - TPSLineTo(RenderCanvas, Angle, RenderIn, BarPos, RealBottom - TextMargin * 2); + TPSMoveTo(RenderCanvas, Angle, RenderIn, BarPos, RealTop + 2 + FContactGrid.TextMargin * 2); + TPSLineTo(RenderCanvas, Angle, RenderIn, BarPos, RealBottom - FContactGrid.TextMargin * 2); Inc(BarPos); end; Inc(BarPos, RealColumnWidth); @@ -714,12 +719,12 @@ begin TPSMoveTo( RenderCanvas, Angle, RenderIn, RealLeft + BarPos, - RealTop + 2 + TextMargin * 2 + RealTop + 2 + FContactGrid.TextMargin * 2 ); TPSLineTo( RenderCanvas, Angle, RenderIn, RealLeft + BarPos, - RealBottom - TextMargin * 2 + RealBottom - FContactGrid.TextMargin * 2 ); Inc(BarPos); end; @@ -732,12 +737,15 @@ end; procedure TVpContactGridPainter.FixFontHeights; begin - {$IF VP_LCL_SCALING = 0} with FContactGrid do begin + {$IF VP_LCL_SCALING = 0} ContactHeadAttributes.Font.Height := GetRealFontHeight(ContactHeadAttributes.Font); Font.Height := GetRealFontHeight(Font); + {$ELSE} + ContactHeadAttributes.Font.Height := FixFontHeight(ContactHeadAttributes.Font); + Font.Height := FixFontHeight(Font); + {$ENDIF} end; - {$ENDIF} end; procedure TVpContactGridPainter.InitColors; diff --git a/components/tvplanit/source/vpdayview.pas b/components/tvplanit/source/vpdayview.pas index f733e138d..e5d9b0063 100644 --- a/components/tvplanit/source/vpdayview.pas +++ b/components/tvplanit/source/vpdayview.pas @@ -275,6 +275,7 @@ type FShowNavButtons: Boolean; FShowResourceName: Boolean; FSimpleRowTime: Boolean; + FTextMargin: Integer; FTimeFormat: TVpTimeFormat; FTimeSlotColors: TVpTimeSlotColor; FTopHour: TVpHours; @@ -334,6 +335,7 @@ type procedure SetShowNavButtons(Value: Boolean); procedure SetShowResourceName(Value: Boolean); procedure SetSimpleRowTime(Value: Boolean); + procedure SetTextMargin(Value: Integer); procedure SetTimeFormat(Value: TVpTimeFormat); procedure SetTopHour(Value: TVpHours); procedure SetTopLine(Value: Integer); @@ -424,6 +426,12 @@ type procedure Notification(AComponent: TComponent; Operation: TOperation); override; procedure Paint; override; + { LCL scaling } + {$IF VP_LCL_SCALING <> 0} + procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy; + const AXProportion, AYProportion: Double); override; + {$IFEND} + { message handlers } procedure VpDayViewInit(var Msg: {$IFDEF DELPHI}TMessage{$ELSE}TLMessage{$ENDIF}); message Vp_DayViewInit; {$IFNDEF LCL} @@ -533,6 +541,7 @@ type property RowHeight: Integer read FCustomRowHeight write SetCustomRowHeight default 0; property RowLinesStep: Integer read FRowLinesStep write SetRowLinesStep default 1; property SimpleRowTime: Boolean read FSimpleRowTime write SetSimpleRowTime default false; + property TextMargin: Integer read FTextMargin write SetTextMargin default TEXT_MARGIN; {events} property AfterEdit: TVpAfterEditEvent read FAfterEdit write FAfterEdit; property BeforeEdit: TVpBeforeEditEvent read FBeforeEdit write FBeforeEdit; @@ -846,6 +855,7 @@ begin FCustomRowHeight := 0; FRowLinesStep := 1; FSimpleRowTime := false; + FTextMargin := TEXT_MARGIN; TopHour := FDefTopHour; FTimeFormat := tf12Hour; FDateLabelFormat := 'dddddd'; //'dddd, mmmm dd, yyyy'; @@ -1584,7 +1594,9 @@ var glyphHeights: Integer; begin Canvas.Font.Assign(FHeadAttr.Font); + {$IF VP_LCL_SCALING = 0} Canvas.Font.Size := ScaleY(Canvas.Font.Size, DesignTimeDPI); + {$IFEND} if FShowResourceName and (DataStore <> nil) and (DataStore.Resource <> nil) then TextHeight := Canvas.TextHeight(TallShortChars) * 2 + TextMargin * 3 @@ -1600,6 +1612,9 @@ begin dvColHeadHeight := Result; end; + +{ Drag and drop } + procedure TVpDayView.DoStartDrag(var DragObject: TDragObject); {$IFDEF LCL} var @@ -1721,7 +1736,9 @@ begin { font, the standard client font, and a sample character string. } SaveFont := Canvas.Font; Canvas.Font.Assign(FRowHeadAttr.FMinuteFont); + {$IF VP_LCL_SCALING = 0} Canvas.Font.Size := ScaleY(Canvas.Font.Size, DesignTimeDPI); + {$IFEND} Canvas.Font.Height := GetRealFontHeight(Canvas.Font); Result := Canvas.TextHeight(TallShortChars); Canvas.Font.Assign(SaveFont); @@ -2547,6 +2564,15 @@ begin end; end; +procedure TVpDayView.SetTextMargin(Value: Integer); +begin + if Value <> FTextMargin then + begin + FTextMargin := Value; + Invalidate; + end; +end; + procedure TVpDayView.SetNumDays(Value: Integer); begin if (Value <> FNumDays) and (Value > 0) and (Value < 31) then begin @@ -2749,6 +2775,22 @@ begin SetVScrollPos; 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} procedure TVpDayView.FixDesignFontsPPI(const ADesignTimePPI: Integer); begin diff --git a/components/tvplanit/source/vpdayviewpainter.pas b/components/tvplanit/source/vpdayviewpainter.pas index 612ab0eeb..e3163e68e 100644 --- a/components/tvplanit/source/vpdayviewpainter.pas +++ b/components/tvplanit/source/vpdayviewpainter.pas @@ -309,6 +309,7 @@ var OldTop: LongInt; txtDist: Integer; cat: TVpCategoryInfo; + txtMargin: Integer; begin // Initialize the rectangle to be used for all-day events ADEventsRect := InitAllDayEventsRect; @@ -320,7 +321,9 @@ begin // number of all day events for the range of days covered by the control. NumADEvents := 0; - AllDayWidth := RealWidth - RealRowHeadWidth - TextMargin - ScrollBarOffset; + txtMargin := FDayView.TextMargin; + + AllDayWidth := RealWidth - RealRowHeadWidth - txtMargin - ScrollBarOffset; DayWidth := AllDayWidth div FDayView.NumDays; ADEventsList := TList.Create; @@ -364,10 +367,10 @@ begin {$IF VP_LCL_SCALING = 0} RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI); {$ENDIF} - ADTextHeight := RenderCanvas.TextHeight(VpProductName) + TextMargin; + ADTextHeight := RenderCanvas.TextHeight(VpProductName) + txtMargin; // Distance between text and border - txtDist := TextMargin div 2; + txtDist := txtMargin div 2; // Store the top of the event's rect OldTop := ADEventsRect.Top; @@ -417,10 +420,10 @@ begin ); 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, - AdEvRect.Left + TextMargin, + AdEvRect.Left + txtMargin, AdEvRect.Top + txtDist, // AdEvRect.Bottom - ADTextHeight) div 2, //TextMargin, EventStr ); @@ -428,7 +431,7 @@ begin TVpDayViewOpener(FDayView).dvEventArray[EventCount].Rec := Rect( ADEvRect.Left, ADEvRect.Top - 2, - ADEvRect.Right - TextMargin, + ADEvRect.Right - txtMargin, ADEvRect.Bottom ); TVpDayViewOpener(FDayView).dvEventArray[EventCount].Event := Event; @@ -673,15 +676,15 @@ begin { center and write the resource name in the first column } if (Col = 0) then begin 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); end; { center the date string } 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 { 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; end; { Write the date string } @@ -897,7 +900,7 @@ begin { If the string is longer than the availble space then chop off the end and place those little '...'s at the end } 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 EventString := GetDisplayString(RenderCanvas, EventString, 0, maxW); end; @@ -1139,16 +1142,16 @@ begin TPSTextOut(RenderCanvas, // wp: both cases are the same ?! Angle, RenderIn, - AIconRect.Right + FDayView.GutterWidth + TextMargin, - AEventRect.Top + TextMargin, + AIconRect.Right + FDayView.GutterWidth + FDayView.TextMargin, + AEventRect.Top + FDayView.TextMargin, AText ) else TPSTextOut(RenderCanvas, Angle, RenderIn, - AIconRect.Right + FDayView.GutterWidth + TextMargin, - AEventRect.Top + TextMargin, + AIconRect.Right + FDayView.GutterWidth + FDayView.TextMargin, + AEventRect.Top + FDayView.TextMargin, AText ); end; @@ -1438,7 +1441,7 @@ begin {$ENDIF} timeStr := Format('%s:%s', [hourStr, minuteStr]); x := lineRect.Left + FScaledTickDist; - TPSTextOut(RenderCanvas, Angle, RenderIn, x, y + TextMargin, timeStr); + TPSTextOut(RenderCanvas, Angle, RenderIn, x, y + FDayView.TextMargin, timeStr); end else begin // 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); {$ENDIF} 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 RenderCanvas.Font.Assign(FDayView.RowHeadAttributes.HourFont); @@ -1456,7 +1459,7 @@ begin RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI); {$ENDIF} 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; @@ -1575,11 +1578,19 @@ end; procedure TVpDayViewPainter.FixFontHeights; begin with FDayView do begin + {$IF VP_LCL_SCALING = 0} AllDayEventAttributes.Font.Height := GetRealFontHeight(AllDayEventAttributes.Font); Font.Height := GetRealFontHeight(Font); HeadAttributes.Font.Height := GetRealFontHeight(HeadAttributes.Font); RowHeadAttributes.HourFont.Height := GetRealFontHeight(RowHeadAttributes.HourFont); 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; diff --git a/components/tvplanit/source/vpganttview.pas b/components/tvplanit/source/vpganttview.pas index 78187860f..cf1aae703 100644 --- a/components/tvplanit/source/vpganttview.pas +++ b/components/tvplanit/source/vpganttview.pas @@ -693,6 +693,7 @@ begin end; end; +{$IF VP_LCL_SCALING <> 0} procedure TVpGanttView.DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy; const AXProportion, AYProportion: Double); begin @@ -701,8 +702,10 @@ begin begin ColWidth := round(ColWidth * AXProportion); FixedColWidth := round(FixedColWidth * AXProportion); + TextMargin := round(TextMargin * AXProportion); end; end; +{$IFEND} function TVpGanttView.DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint): Boolean; begin diff --git a/components/tvplanit/source/vpimportpreview.lfm b/components/tvplanit/source/vpimportpreview.lfm index 633585561..95f852170 100644 --- a/components/tvplanit/source/vpimportpreview.lfm +++ b/components/tvplanit/source/vpimportpreview.lfm @@ -6,7 +6,7 @@ object VpImportPreviewForm: TVpImportPreviewForm Caption = 'VpImportPreviewForm' ClientHeight = 295 ClientWidth = 634 - LCLVersion = '2.3.0.0' + OnShow = FormShow object ButtonPanel: TPanel Left = 6 Height = 25 @@ -22,12 +22,13 @@ object VpImportPreviewForm: TVpImportPreviewForm object btnExecute: TButton AnchorSideTop.Control = ButtonPanel AnchorSideRight.Control = btnCancel - Left = 406 + Left = 400 Height = 25 Top = 0 Width = 141 Anchors = [akTop, akRight] AutoSize = True + BorderSpacing.Right = 6 Caption = 'Import checked items' ModalResult = 1 TabOrder = 0 diff --git a/components/tvplanit/source/vpimportpreview.pas b/components/tvplanit/source/vpimportpreview.pas index f76c7480d..d4f775d8b 100644 --- a/components/tvplanit/source/vpimportpreview.pas +++ b/components/tvplanit/source/vpimportpreview.pas @@ -26,7 +26,8 @@ type btnExecute: TButton; btnCancel: TButton; ButtonPanel: TPanel; - procedure GridDrawCell(Sender: TObject; aCol, aRow: Integer; aRect: TRect; + procedure FormShow(Sender: TObject); + procedure GridDrawCell(Sender: TObject; aCol, aRow: Integer; aRect: TRect; {%H-}aState: TGridDrawState); procedure GridGetCheckboxState(Sender: TObject; {%H-}ACol, ARow: Integer; var Value: TCheckboxState); @@ -66,7 +67,8 @@ implementation {$R *.lfm} uses - LCLIntf, LCLType, Themes; + LCLIntf, LCLType, Themes, + VpSR; { TVpImportGrid } @@ -158,15 +160,17 @@ begin FixedCols := 0; Options := [goEditing, goRowSelect, goThumbTracking, goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, - goRangeSelect, goColSizing, goSmoothScroll]; + goRangeSelect, goSmoothScroll]; OnDrawCell := @GridDrawCell; OnGetCheckboxState := @GridGetCheckboxState; OnPrepareCanvas := @GridPrepareCanvas; OnSetCheckboxState := @GridSetCheckboxState; - //Parent := self; end; FItems := TFPList.Create; + + btnExecute.Caption := RSImportCheckedItems; + btnCancel.Caption := RSCancelBtn; end; destructor TVpImportPreviewForm.Destroy; @@ -256,6 +260,14 @@ begin 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, ARow: Integer; var Value: TCheckboxState); begin diff --git a/components/tvplanit/source/vpimportpreview_icalevent.lfm b/components/tvplanit/source/vpimportpreview_icalevent.lfm index 55301965c..0262845c9 100644 --- a/components/tvplanit/source/vpimportpreview_icalevent.lfm +++ b/components/tvplanit/source/vpimportpreview_icalevent.lfm @@ -9,10 +9,12 @@ inherited VpImportPreviewICalEventForm: TVpImportPreviewICalEventForm Width = 655 ClientWidth = 655 inherited btnExecute: TButton - Left = 439 + Left = 446 end inherited btnCancel: TButton - Left = 580 + Left = 593 + Width = 62 + AutoSize = True end end end diff --git a/components/tvplanit/source/vpimportpreview_vcard.lfm b/components/tvplanit/source/vpimportpreview_vcard.lfm index 2aa2fcb28..5e1273ffd 100644 --- a/components/tvplanit/source/vpimportpreview_vcard.lfm +++ b/components/tvplanit/source/vpimportpreview_vcard.lfm @@ -9,10 +9,12 @@ inherited VpImportPreviewVCardForm: TVpImportPreviewVCardForm Width = 655 ClientWidth = 655 inherited btnExecute: TButton - Left = 439 + Left = 452 end inherited btnCancel: TButton - Left = 580 + Left = 593 + Width = 62 + AutoSize = True end end end diff --git a/components/tvplanit/source/vpmisc.pas b/components/tvplanit/source/vpmisc.pas index 2bfbd91b2..fbd1ae9b8 100644 --- a/components/tvplanit/source/vpmisc.pas +++ b/components/tvplanit/source/vpmisc.pas @@ -179,6 +179,7 @@ function GetCanvasTextHeight(ACanvas: TCanvas; AFont: TFont; AText: String = '') function GetCanvasTextWidth(ACanvas: TCanvas; AFont: TFont; AText: String): Integer; function GetLabelWidth(ALabel: TLabel): Integer; function GetRealFontHeight(AFont: TFont): Integer; +function FixFontHeight(AFont: TFont): Integer; function DecodeLineEndings(const AText: String): String; function EncodeLineEndings(const AText: String): String; @@ -978,6 +979,11 @@ begin canvas.Free; end; +function FixFontHeight(AFont: TFont): Integer; +begin + Result := GetFontData(AFont.Handle).Height; +end; + function GetRealFontHeight(AFont: TFont): Integer; begin if AFont.Size = 0 then diff --git a/components/tvplanit/source/vpmonthview.pas b/components/tvplanit/source/vpmonthview.pas index 9d281459a..3cdbd2132 100644 --- a/components/tvplanit/source/vpmonthview.pas +++ b/components/tvplanit/source/vpmonthview.pas @@ -145,7 +145,7 @@ type FAllowDragAndDrop: Boolean; FApplyCategoryInfos: Boolean; FColor: TColor; - FColumnWidth: Integer; +// FColumnWidth: Integer; FComponentHint: TTranslateString; FDate: TDateTime; FDateLabelFormat: string; @@ -170,6 +170,7 @@ type FSelectedDayColor: TColor; FShowEvents: Boolean; FShowEventTime: Boolean; + FTextMargin: Integer; FTimeFormat: TVpTimeFormat; FTodayAttr: TVpMvTodayAttr; FWeekendAttr: TVpMvWeekendAttr; @@ -211,6 +212,7 @@ type procedure SetSelectedDayColor(Value: TColor); procedure SetShowEvents(Value: Boolean); procedure SetShowEventTime(Value: Boolean); + procedure SetTextMargin(Value: Integer); procedure SetTimeFormat(Value: TVpTimeFormat); procedure SetWeekStartsOn(Value: TVpDayType); @@ -304,6 +306,11 @@ type 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} procedure FixDesignFontsPPI(const ADesignTimePPI: Integer); 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 EventDayStyle: TFontStyles read FEventDayStyle write SetEventDayStyle default []; property EventFont: TVpFont read FEventFont write SetEventFont; -// property HeadAttributes: TVpMvHeadAttr read FHeadAttr write FHeadAttr; property HeadAttributes: TVpMonthViewAttr read FHeadAttr write FHeadAttr; property HolidayAttributes: TVpMvHolidayAttr read FHolidayAttr write FHolidayAttr; property HintMode: TVpHintMode read FHintMode write FHintMode default hmPlannerHint; @@ -348,6 +354,7 @@ type property SelectedDayColor: TColor read FSelectedDayColor write SetSelectedDayColor default clRed; property ShowEvents: Boolean read FShowEvents write SetShowEvents default true; 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 TodayAttributes: TVpMvTodayAttr read FTodayAttr write FTodayAttr; property WeekendAttributes: TVpMvWeekendAttr read FWeekendAttr write FWeekendAttr; @@ -515,8 +522,9 @@ begin FDate := Trunc(Now); FTimeFormat := tf12Hour; FDateLabelFormat := 'mmmm yyyy'; - FColumnWidth := 200; +// FColumnWidth := 200; FRightClickChangeDate := vpDefWVRClickChangeDate; + FTextMargin := TEXT_MARGIN; // mvVisibleEvents := 0; { set up fonts and colors } @@ -885,6 +893,15 @@ begin end; end; +procedure TVpMonthView.SetTextMargin(Value: Integer); +begin + if Value <> FTextMargin then + begin + FTextMargin := Value; + Invalidate; + end; +end; + procedure TVpMonthView.SetTimeFormat(Value: TVpTimeFormat); begin if Value <> FTimeFormat then begin @@ -1582,11 +1599,24 @@ begin 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} procedure TVpMonthView.FixDesignFontsPPI(const ADesignTimePPI: Integer); begin inherited; DoFixDesignFontPPI(DayHeadAttributes.Font, ADesignTimePPI); + DoFixDesignFontPPI(DayNumberFont, ADesignTimePPI); DoFixDesignFontPPI(EventFont, ADesignTimePPI); DoFixDesignFontPPI(HeadAttributes.Font, ADesignTimePPI); DoFixDesignFontPPI(HolidayAttributes.Font, ADesignTimePPI); @@ -1599,6 +1629,7 @@ procedure TVpMonthView.ScaleFontsPPI(const AToPPI: Integer; begin inherited; DoScaleFontPPI(DayHeadAttributes.Font, AToPPI, AProportion); + DoScaleFontPPI(DayNumberFont, AToPPI, AProportion); DoScaleFontPPI(EventFont, AToPPI, AProportion); DoScaleFontPPI(HeadAttributes.Font, AToPPI, AProportion); DoScaleFontPPI(HolidayAttributes.Font, AToPPI, AProportion); @@ -1610,6 +1641,7 @@ procedure TVpMonthView.ScaleFontsPPI(const AProportion: Double); begin inherited; DoScaleFontPPI(DayHeadAttributes.Font, AProportion); + DoScaleFontPPI(DayNumberFont, AProportion); DoScaleFontPPI(EventFont, Aproportion); DoScaleFontPPI(HeadAttributes.Font, AProportion); DoScaleFontPPI(HolidayAttributes.Font, AProportion); diff --git a/components/tvplanit/source/vpmonthviewpainter.pas b/components/tvplanit/source/vpmonthviewpainter.pas index f15257680..3f4bc4a55 100644 --- a/components/tvplanit/source/vpmonthviewpainter.pas +++ b/components/tvplanit/source/vpmonthviewpainter.pas @@ -220,12 +220,12 @@ begin { Calculate size of rect for the day number at the top of the TextRect. } if ACol = 6 then - tmpRect.Left := ATextRect.Left + mvColWidth - TextAdjust - TextMargin + tmpRect.Left := ATextRect.Left + mvColWidth - TextAdjust - FMonthView.TextMargin else - tmpRect.Left := ATextRect.Right - TextAdjust - TextMargin + 2; + tmpRect.Left := ATextRect.Right - TextAdjust - FMonthView.TextMargin + 2; if fsItalic in RenderCanvas.Font.Style then 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.Bottom := tmpRect.Top + textHeight; @@ -372,12 +372,12 @@ begin { Fix header string } StrLen := RenderCanvas.TextWidth(Str); - if (StrLen > mvColWidth - TextMargin * 2) then - Str := GetDisplayString(RenderCanvas, Str, 0, mvColWidth - TextMargin * 2); + if (StrLen > mvColWidth - FMonthView.TextMargin * 2) then + Str := GetDisplayString(RenderCanvas, Str, 0, mvColWidth - FMonthView.TextMargin * 2); StrLen := RenderCanvas.TextWidth(Str); { 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); DayTAG := (DayTAG + 1) mod 7; @@ -496,6 +496,7 @@ var eventCat: TVpCategoryInfo; dayRect: TRect; TextRect: TRect; + txtMargin: Integer; tmpRect: TRect; Str: String; StrLen: Integer; @@ -507,6 +508,8 @@ begin RenderCanvas.Pen.Style := psSolid; RenderCanvas.Brush.Color := RealColor; + txtMargin := FMonthView.TextMargin; + { write the events } if (FMonthView.DataStore <> nil) and FMonthView.ShowEvents and (FMonthView.DataStore.Resource <> nil) and @@ -527,7 +530,7 @@ begin TextRect.TopLeft := Point(dayRect.Left+1, dayRect.Top+1); TextRect.BottomRight := Point( TextRect.Left + mvColWidth, - TextRect.Top + mvEventTextHeight + TextMargin// div 2 + TextRect.Top + mvEventTextHeight + txtMargin// div 2 ); { set canvas color } @@ -550,9 +553,9 @@ begin { shorten events that are next to the day number, in order } { 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 - TextRect.Right := TextRect.Left + mvColWidth - mvDayNumberHeight - TextMargin * 2 + TextRect.Right := TextRect.Left + mvColWidth - mvDayNumberHeight - txtMargin * 2 else TextRect.Right := TextRect.Left + mvColWidth - 3; @@ -582,11 +585,11 @@ begin RenderCanvas.Font.Color := FMonthView.OffDayFontColor; StrLen := RenderCanvas.TextWidth(Str); - if StrLen > WidthOf(TextRect) - TextMargin * 2 then - Str := GetDisplayString(RenderCanvas, Str, 0, WidthOf(TextRect) - TextMargin * 2); + if StrLen > WidthOf(TextRect) - txtMargin * 2 then + Str := GetDisplayString(RenderCanvas, Str, 0, WidthOf(TextRect) - txtMargin * 2); { 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); { Store TextRect and Event in EventArray } @@ -695,12 +698,12 @@ begin RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI); {$ENDIF} if DisplayOnly and (RenderCanvas.TextWidth(HeadStr) >= RealWidth) then - HeadTextRect.Left := RealLeft + TextMargin * 2 + HeadTextRect.Left := RealLeft + FMonthView.TextMargin * 2 else if DisplayOnly then HeadTextRect.Left := RealLeft + (RealWidth - RenderCanvas.TextWidth(HeadStr)) div 2 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.BottomRight := HeadRect.BottomRight; @@ -712,7 +715,7 @@ begin RenderCanvas, HeadStr, 0, - HeadTextRect.Right - HeadTextRect.Left - TextMargin + HeadTextRect.Right - HeadTextRect.Left - FMonthView.TextMargin ); end; @@ -734,11 +737,19 @@ end; procedure TVpMonthViewPainter.FixFontHeights; begin with FMonthView do begin + {$IF VP_LCL_SCALING = 0} HeadAttributes.Font.Height := GetRealFontHeight(HeadAttributes.Font); DayHeadAttributes.Font.Height := GetRealFontHeight(DayHeadAttributes.Font); DayNumberFont.Height := GetRealFontHeight(DayNumberFont); EventFont.Height := GetRealFontHeight(EventFont); 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; @@ -823,7 +834,7 @@ begin 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 } RenderCanvas.Font.Assign(FMonthView.DayHeadAttributes.Font); {$IF VP_LCL_SCALING = 0} diff --git a/components/tvplanit/source/vptasklist.pas b/components/tvplanit/source/vptasklist.pas index 9a55f6bc3..ef9b622ea 100644 --- a/components/tvplanit/source/vptasklist.pas +++ b/components/tvplanit/source/vptasklist.pas @@ -126,7 +126,9 @@ type private FDefaultPopup: TPopupMenu; FExternalPopup: TPopupMenu; + FTextMargin: Integer; procedure SetPopupMenu(AValue: TPopupMenu); + procedure SetTextMargin(AValue: Integer); protected{ private } FColor: TColor; FCaption: string; @@ -232,6 +234,11 @@ type Angle: TVpRotationAngle; Scale: Extended; RenderDate: TDateTime; 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} procedure FixDesignFontsPPI(const ADesignTimePPI: Integer); 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 ShowIcon: Boolean read FShowIcon write SetShowIcon default True; property ShowResourceName: Boolean read FShowResourceName write SetShowResourceName default true; + property TextMargin: Integer read FTextMargin write SetTextMargin default TEXT_MARGIN; { events } property BeforeEdit: TVpBeforeEditTask read FBeforeEdit write FBeforeEdit; property AfterEdit: TVpAfterEditTask read FAfterEdit write FAfterEdit; @@ -530,6 +538,7 @@ begin FShowResourceName := true; FColor := DEFAULT_COLOR; FLineColor := DEFAULT_LINECOLOR; + FTextMargin := TEXT_MARGIN; FScrollBars := ssVertical; FTaskIndex := -1; FShowIcon := True; @@ -777,6 +786,15 @@ begin end; end; +procedure TVpTaskList.SetTextMargin(AValue: Integer); +begin + if AValue <> FTextMargin then + begin + FTextMargin := AValue; + Invalidate; + end; +end; + {$IFNDEF LCL} procedure TVpTaskList.WMSize(var Msg: TWMSize); {$ELSE} @@ -1350,6 +1368,18 @@ begin 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} procedure TVpTaskList.FixDesignFontsPPI(const ADesignTimePPI: Integer); begin diff --git a/components/tvplanit/source/vptasklistpainter.pas b/components/tvplanit/source/vptasklistpainter.pas index 3ab596ce2..3035981fc 100644 --- a/components/tvplanit/source/vptasklistpainter.pas +++ b/components/tvplanit/source/vptasklistpainter.pas @@ -92,12 +92,18 @@ var d2: Integer; // 2*Scale {%H-}d1px, {%H-}d2px, d3px: Integer; begin - if Scale > 1 then - tm := Round(TextMargin * Scale) else - tm := ScaleY(Textmargin, DesigntimeDPI); + tm := Round(FTaskList.TextMargin * Scale); + + {$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); d2px := ScaleY(2, DesigntimeDPI); d3px := ScaleY(3, DesigntimeDPI); + {$IFEND} X := Rec.Left + tm; Y := Rec.Top + tm; @@ -244,7 +250,7 @@ begin HeadRect.Left := RealLeft + delta; HeadRect.Top := RealTop + 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); { draw the header cell borders } @@ -277,13 +283,16 @@ begin begin w := Round(bmp.Width * 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); {$IFDEF FPC} RotateBitmap(Bmp, Angle); {$ENDIF} TPSStretchDraw(RenderCanvas, Angle, RenderIn, GlyphRect, Bmp); - HeadRect.Left := HeadRect.Left + w + TextMargin; + HeadRect.Left := HeadRect.Left + w + FTasklist.TextMargin; end; finally bmp.Free; @@ -516,7 +525,7 @@ begin {$IF VP_LCL_SCALING = 0} RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI); {$ENDIF} - RowHeight := RenderCanvas.TextHeight(VpProductName) + TextMargin * 2; + RowHeight := RenderCanvas.TextHeight(VpProductName) + FTasklist.TextMargin * 2; end; procedure TVpTaskListPainter.RenderToCanvas(ARenderIn: TRect; diff --git a/components/tvplanit/source/vpweekview.pas b/components/tvplanit/source/vpweekview.pas index 7c0d27ad8..b78d27079 100644 --- a/components/tvplanit/source/vpweekview.pas +++ b/components/tvplanit/source/vpweekview.pas @@ -136,7 +136,7 @@ type FAllowDragAndDrop: Boolean; FApplyCategoryInfos: Boolean; FColor: TColor; - FColumnWidth: Integer; +// FColumnWidth: Integer; FComponentHint: TTranslateString; FDateLabelFormat: string; FDayHeadAttributes: TVpDayHeadAttr; @@ -151,6 +151,7 @@ type FMouseEvent: TVpEvent; FLayout: TVpWeekviewLayout; FShowEventTime: Boolean; + FTextMargin: Integer; FTimeFormat: TVpTimeFormat; FVisibleLines: Integer; FWeekStartsOn: TVpDayType; @@ -189,6 +190,7 @@ type procedure SetLineColor(Value: TColor); procedure SetPopupMenu(AValue: TPopupMenu); procedure SetShowEventTime(Value: Boolean); + procedure SetTextMargin(Value: Integer); procedure SetTimeFormat(Value: TVpTimeFormat); procedure SetWeekStartsOn(Value: TVpDayType); @@ -300,6 +302,11 @@ type StartLine: Integer; 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} procedure FixDesignFontsPPI(const ADesignTimePPI: Integer); 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 LineColor: TColor read FLineColor write SetLineColor default DEFAULT_LINECOLOR; 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 ShowEventTime: Boolean read FShowEventTime write SetShowEventTime default true; property WeekStartsOn: TVpDayType read FWeekStartsOn write SetWeekStartsOn default dtSunday; @@ -574,10 +582,11 @@ begin wvPainting := false; FColor := DEFAULT_COLOR; FLineColor := DEFAULT_LINECOLOR; + FTextMargin := TEXT_MARGIN; wvStartDate := trunc(GetStartOfWeek(Now, FWeekStartsOn)); FTimeFormat := tf12Hour; FDateLabelFormat := 'ddddd'; - FColumnWidth := 200; +// FColumnWidth := 200; FAllowInplaceEdit := true; { set up fonts and colors } @@ -936,6 +945,15 @@ begin end; end; +procedure TVpWeekView.SetTextMargin(Value: Integer); +begin + if Value <> FTextMargin then + begin + FTextMargin := Value; + Invalidate; + end; +end; + procedure TVpWeekView.SetTimeFormat(Value: TVpTimeFormat); begin if Value <> FTimeFormat then begin @@ -1928,6 +1946,18 @@ begin 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} procedure TVpWeekView.FixDesignFontsPPI(const ADesignTimePPI: Integer); begin diff --git a/components/tvplanit/source/vpweekviewpainter.pas b/components/tvplanit/source/vpweekviewpainter.pas index 7314caba5..a6be36573 100644 --- a/components/tvplanit/source/vpweekviewpainter.pas +++ b/components/tvplanit/source/vpweekviewpainter.pas @@ -94,6 +94,7 @@ var ADTextHeight: Integer; EventStr: string; txtDist: Integer; + txtMargin: Integer; cat: TVpCategoryInfo; savedBrushColor: TColor; savedPenColor: TColor; @@ -110,6 +111,8 @@ begin { number of all day events for the range of days covered by the control. } NumADEvents := 0; + txtMargin := FWeekView.TextMargin; + savedPenColor := RenderCanvas.Pen.Color; savedBrushColor := RenderCanvas.Brush.Color; ADEventsList := TList.Create; @@ -146,19 +149,19 @@ begin RenderCanvas.Brush.Color := ADBackgroundColor; { Measure the AllDayEvent TextHeight } - txtDist := TextMargin div 2; + txtDist := FWeekView.TextMargin div 2; RenderCanvas.Font.Assign(FWeekView.AllDayEventAttributes.Font); {$IF VP_LCL_SCALING = 0} RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI); {$ENDIF} - ADTextHeight := RenderCanvas.TextHeight(VpProductName) + TextMargin + txtDist; + ADTextHeight := RenderCanvas.TextHeight(VpProductName) + txtMargin + txtDist; { 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 ADEventsRect.Bottom := DayRect.Bottom else - ADEventsRect.Bottom := AdEventsRect.Top + NumADEvents * ADTextHeight + TextMargin * 2; + ADEventsRect.Bottom := AdEventsRect.Top + NumADEvents * ADTextHeight + txtMargin * 2; // Clear the AllDayEvents area TpsFillRect(RenderCanvas, Angle, RenderIn, ADEventsRect); @@ -181,7 +184,7 @@ begin StartsBeforeRange := true; // 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.Left := AdEventsRect.Left + txtDist; ADEvRect.Right := DayRect.Right; @@ -199,28 +202,28 @@ begin end; end; TPSRectangle(RenderCanvas, Angle, RenderIn, - ADEvRect.Left + TextMargin, + ADEvRect.Left + txtMargin, ADEvRect.Top + txtDist, - ADEvRect.Right - TextMargin, + ADEvRect.Right - txtMargin, ADEvRect.Top + ADTextHeight + txtDist ); // Paint the event string 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, - ADEvRect.Left + TextMargin * 2 + txtDist, - ADEvRect.Top + TextMargin, + ADEvRect.Left + txtMargin * 2 + txtDist, + ADEvRect.Top + txtMargin, EventStr ); Result := True; TVpWeekViewOpener(FWeekView).wvEventArray[EAIndex].Rec := Rect( - ADEvRect.Left + TextMargin, - ADEvRect.Top + TextMargin, - ADEvRect.Right - TextMargin, + ADEvRect.Left + txtMargin, + ADEvRect.Top + txtMargin, + ADEvRect.Right - txtMargin, ADEvRect.Bottom ); TVpWeekViewOpener(FWeekView).wvEventArray[EAIndex].Event := Event; @@ -318,7 +321,7 @@ begin if (FWeekView.DataStore <> nil) and (FWeekView.DataStore.Resource <> nil) and (FWeekView.DataStore.Resource.Schedule.EventCountByDay(StartDate + ADayIndex) > 0) and - (HeightOf(DayRect) >= TextMargin * 2 + FDayHeadHeight) + (HeightOf(DayRect) >= FWeekView.TextMargin * 2 + FDayHeadHeight) then begin // Events exist for this day EventList := TList.Create; @@ -354,7 +357,7 @@ begin { if the TextRect extends below the available space then draw a } { dot dot dot to indicate there are more events than can be drawn } { in the available space } - if TextRect.Bottom - TextMargin > DayRect.Bottom then begin + if TextRect.Bottom - FWeekView.TextMargin > DayRect.Bottom then begin { Draw ". . ." } DrawDotDotDot(DayRect, DotDotDotColor); break; @@ -458,11 +461,11 @@ begin RenderCanvas.Font.Style := RenderCanvas.Font.Style + [fsBold]; dayStr := GetDateDisplayString(RenderCanvas, StartDate + ADayIndex, - FWeekView.DayHeadAttributes.DateFormat, AHolidayName, WidthOf(TextRect) - TextMargin); + FWeekView.DayHeadAttributes.DateFormat, AHolidayName, WidthOf(TextRect) - FWeekView.TextMargin); strWid := RenderCanvas.TextWidth(dayStr); strH := RenderCanvas.TextHeight(dayStr); - TextRect.Left := TextRect.Right - strWid - TextMargin; + TextRect.Left := TextRect.Right - strWid - FWeekView.TextMargin; TPSTextOut( RenderCanvas, Angle, @@ -536,6 +539,7 @@ var dayStr: String; todayStartTime: TDateTime; todayEndTime: TDateTime; + txtMargin: Integer; strLen: Integer; oldFontColor: TColor; eventCat: TVpCategoryInfo; @@ -543,6 +547,8 @@ var begin oldFontColor := RenderCanvas.Font.Color; + txtmargin := FWeekView.TextMargin; + { format the display text } todayStartTime := AEvent.StartTime; todayEndTime := AEvent.EndTime; @@ -585,12 +591,12 @@ begin { Build the event text } dayStr := FWeekView.BuildEventString(AEvent, todayStartTime, todayEndTime, false); strLen := RenderCanvas.TextWidth(dayStr); - if (strLen > WidthOf(TextRect) - 2*TextMargin) then - dayStr := GetDisplayString(RenderCanvas, dayStr, 0, WidthOf(TextRect) - TextMargin * 2); + if (strLen > WidthOf(TextRect) - txtMargin * 2) then + dayStr := GetDisplayString(RenderCanvas, dayStr, 0, WidthOf(TextRect) - txtMargin * 2); { Write the event text } TPSTextOut(RenderCanvas, Angle, RenderIn, - TextRect.Left + TextMargin, TextRect.Top + TextMargin div 2, + TextRect.Left + txtMargin, TextRect.Top + txtMargin div 2, dayStr ); @@ -606,6 +612,7 @@ var weekNo: Integer; startStr, endStr: String; txtStart: Integer; + txtMargin: Integer; begin RenderCanvas.Brush.Color := RealHeadAttrColor; RenderCanvas.Font.Assign(TFont(FWeekView.HeadAttributes.Font)); @@ -613,6 +620,8 @@ begin RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI); {$ENDIF} + txtMargin := FWeekView.TextMargin; + { draw the header cell and borders } if FWeekView.DrawingStyle = ds3d then begin { draw a 3d bevel } @@ -641,7 +650,7 @@ begin { draw the text } 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 if DisplayOnly then HeadTextRect.TopLeft := Point( @@ -650,17 +659,17 @@ begin ) else 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 ); HeadTextRect.BottomRight := HeadRect.BottomRight; { Fix Header String } HeadStrLen := RenderCanvas.TextWidth(HeadStr); - if HeadStrLen > HeadTextRect.Right - HeadTextRect.Left - TextMargin then + if HeadStrLen > HeadTextRect.Right - HeadTextRect.Left - txtMargin then begin HeadStr := GetDisplayString(RenderCanvas, HeadStr, 0, - HeadTextRect.Right - HeadTextRect.Left - TextMargin ); + HeadTextRect.Right - HeadTextRect.Left - txtMargin ); end; { Position the spinner } @@ -698,11 +707,19 @@ end; procedure TVpWeekViewPainter.FixFontHeights; begin with FWeekView do begin + {$IF VP_LCL_SCALING = 0} AllDayEventAttributes.Font.Height := GetRealFontHeight(AllDayEventAttributes.Font); DayHeadAttributes.Font.Height := GetRealFontHeight(DayHeadAttributes.Font); EventFont.Height := GetRealFontHeight(EventFont); Font.Height := GetRealFontHeight(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; @@ -789,21 +806,21 @@ begin {$IF VP_LCL_SCALING = 0} RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI); {$ENDIF} - FDayHeadHeight := RenderCanvas.TextHeight(VpProductName) + TextMargin + 2 ; + FDayHeadHeight := RenderCanvas.TextHeight(VpProductName) + FWeekView.TextMargin + 2 ; RenderCanvas.Font.Assign(FWeekView.EventFont); {$IF VP_LCL_SCALING = 0} RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI); {$ENDIF} 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)); {$IF VP_LCL_SCALING = 0} RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI); {$ENDIF} with TVpWeekViewOpener(FWeekView) do - wvHeaderHeight := RenderCanvas.TextHeight(VpProductName) + TextMargin * 2; + wvHeaderHeight := RenderCanvas.TextHeight(VpProductName) + FWeekView.TextMargin * 2; end; end.