From bc4e7a1be7482a6f68fee38c129270da5930dbb8 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Thu, 14 Jul 2016 15:26:55 +0000 Subject: [PATCH] tvplanit: Improvement of vertical alignment in various forms git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4956 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/tvplanit/examples/demo/demo.lpi | 6 ++ .../tvplanit/examples/demo/demomain.lfm | 4 +- .../tvplanit/examples/demo/demomain.pas | 52 +++++++++----- .../tvplanit/source/vpcontacteditdlg.pas | 16 ++--- components/tvplanit/source/vpedelem.lfm | 28 ++++---- components/tvplanit/source/vpedelem.pas | 32 ++++++++- components/tvplanit/source/vpedfmt.lfm | 2 +- components/tvplanit/source/vpedfmt.pas | 70 ++++++++++++------- components/tvplanit/source/vpedfmtlst.lfm | 2 +- components/tvplanit/source/vpedfmtlst.pas | 50 +++++++++++-- components/tvplanit/source/vpedshape.lfm | 28 ++++---- components/tvplanit/source/vpedshape.pas | 52 ++++++++++---- components/tvplanit/source/vpprtfmtdlg.pas | 2 +- components/tvplanit/source/vpprtprvdlg.pas | 1 + components/tvplanit/source/vpreseditdlg.pas | 29 +++++++- 15 files changed, 270 insertions(+), 104 deletions(-) diff --git a/components/tvplanit/examples/demo/demo.lpi b/components/tvplanit/examples/demo/demo.lpi index b570d4199..3dbb99432 100644 --- a/components/tvplanit/examples/demo/demo.lpi +++ b/components/tvplanit/examples/demo/demo.lpi @@ -9,6 +9,9 @@ <ResourceType Value="res"/> <UseXPManifest Value="True"/> + <XPManifest> + <DpiAware Value="True"/> + </XPManifest> </General> <i18n> <EnableI18N Value="True"/> @@ -65,6 +68,9 @@ <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> </SearchPaths> <Linking> + <Debugging> + <UseExternalDbgSyms Value="True"/> + </Debugging> <Options> <Win32> <GraphicApplication Value="True"/> diff --git a/components/tvplanit/examples/demo/demomain.lfm b/components/tvplanit/examples/demo/demomain.lfm index 7b326ae5c..ada34b0b9 100644 --- a/components/tvplanit/examples/demo/demomain.lfm +++ b/components/tvplanit/examples/demo/demomain.lfm @@ -25,9 +25,9 @@ object MainForm: TMainForm Height = 532 Top = 48 Width = 780 - ActivePage = TabSettings + ActivePage = TabEvents Align = alClient - TabIndex = 4 + TabIndex = 0 TabOrder = 0 object TabEvents: TTabSheet Caption = 'Events' diff --git a/components/tvplanit/examples/demo/demomain.pas b/components/tvplanit/examples/demo/demomain.pas index 0b5c06f14..d3be2c1e9 100644 --- a/components/tvplanit/examples/demo/demomain.pas +++ b/components/tvplanit/examples/demo/demomain.pas @@ -108,6 +108,7 @@ type FActiveView: Integer; FVisibleDays: Integer; procedure PopulateLanguages; + procedure PositionControls; procedure SetActiveView(AValue: Integer); procedure SetLanguage(ALang: String); overload; procedure SetLanguage(AIndex: Integer); overload; @@ -487,6 +488,38 @@ begin end; end; +procedure TMainForm.PositionControls; +var + w: Integer; +begin + // Settings page + w := MaxValue([ + GetLabelWidth(LblLanguage), + GetLabelWidth(LblTimeFormat), + GetLabelWidth(LblFirstDayOfWeek), + GetLabelWidth(LblAddressBuilder) + ]); + CbLanguages.Left := 24 + w + 8; + CbTimeFormat.Left := CbLanguages.Left; + CbFirstDayOfWeek.Left := CbLanguages.Left; + CbAddressBuilder.Left := CbLanguages.Left; + LblLanguage.Left := CbLanguages.Left - 8 - GetLabelWidth(LblLanguage); + LblTimeFormat.Left := CbTimeFormat.Left - 8 - GetLabelWidth(LblTimeFormat); + LblFirstDayOfWeek.Left := CbFirstDayOfWeek.Left - 8 - GetLabelWidth(LblFirstDayOfWeek); + LblAddressBuilder.Left := CbAddressBuilder.Left - 8 - GetLabelWidth(LblAddressBuilder); + + CbAllowInplaceEditing.Left := CbLanguages.Left + CbLanguages.Width + 32; + w := GetLabelWidth(LblDrawingStyle); + lblDrawingStyle.Left := CbAllowInplaceEditing.Left; + CbDrawingStyle.Left := LblDrawingStyle.Left + w + 8; + + // Planner pages + DaysTrackbar.Left := GetLabelWidth(LblVisibleDays) + LblVisibleDays.Left + 8; + LblGranularity.Left := DaysTrackbar.Left + DaysTrackbar.Width + 32; + CbGranularity.Left := LblGranularity.Left + GetLabelWidth(LblGranularity) + 8; + RbHideCompletedTasks.Left := RbAllTasks.Left + RbAllTasks.Width + 48; +end; + procedure TMainForm.RbAllTasksChange(Sender: TObject); begin VpTaskList1.DisplayOptions.ShowAll := RbAllTasks.Checked; @@ -725,23 +758,6 @@ begin CbDrawingStyle.Items.Add(RS3d); CbDrawingStyle.Items.Add(RSBorderless); - DaysTrackbar.Left := GetLabelWidth(LblVisibleDays) + LblVisibleDays.Left + 8; - LblGranularity.Left := DaysTrackbar.Left + DaysTrackbar.Width + 32; - CbGranularity.Left := LblGranularity.Left + GetLabelWidth(LblGranularity) + 8; - w := MaxValue([GetLabelWidth(LblLanguage), GetLabelWidth(LblTimeFormat), GetLabelWidth(LblFirstDayOfWeek)]); - CbLanguages.Left := 24 + w + 8; - LblLanguage.Left := CbLanguages.Left - 8 - GetLabelWidth(LblLanguage); - CbTimeFormat.Left := CbLanguages.Left; - LblTimeFormat.Left := CbTimeFormat.Left - 8 - GetLabelWidth(LblTimeFormat); - CbFirstDayOfWeek.Left := CbLanguages.Left; - LblFirstDayOfWeek.Left := CbFirstDayOfWeek.Left - 8 - GetLabelWidth(LblFirstDayOfWeek); - CbAddressBuilder.Left := CbLanguages.Left; - LblAddressBuilder.Left := CbAddressBuilder.Left - 8 - GetLabelWidth(LblAddressBuilder); - CbAllowInplaceEditing.Left := CbLanguages.Left + CbLanguages.Width + 32; - LblDrawingStyle.Left := CbAllowInplaceEditing.Left; - CbDrawingStyle.Left := LblDrawingStyle.Left + GetLabelWidth(LblDrawingStyle) + 8; - RbHideCompletedTasks.Left := RbAllTasks.Left + RbAllTasks.Width + 48; - // Next settings work correctly only for Windows. {$IFDEF WINDOWS} UpdateFormatSettings(ALang); @@ -759,6 +775,8 @@ begin VpWeekView1.WeekStartsOn := firstWeekDay; {$ENDIF} + PositionControls; + SetActiveView(1001); Invalidate; end; diff --git a/components/tvplanit/source/vpcontacteditdlg.pas b/components/tvplanit/source/vpcontacteditdlg.pas index b9d4084e5..6e319d27f 100644 --- a/components/tvplanit/source/vpcontacteditdlg.pas +++ b/components/tvplanit/source/vpcontacteditdlg.pas @@ -390,16 +390,16 @@ var OldFont: TFont; FieldTop: Integer; delta: Integer; - corr: Integer; // difference between form's client width and tabsheet width - editHeight: Integer; // Height of an edit control - vDist: Integer; // Vertical distance between edits - hBorder: Integer; // Distance between container border and label - dist: Integer; // distance between label and edit/combo + corr: Integer; // difference between form's client width and tabsheet width + editHeight: Integer; // Height of an edit control + vDist: Integer = 4; // Vertical distance between edits + hBorder: Integer = 8; // Distance between container border and label + dist: Integer = 4; // distance between label and edit/combo begin - dist := round(4 * Screen.PixelsPerInch / DesignTimeDPI); - vdist := round(2 * Screen.PixelsPerInch / DesignTimeDPI); - hBorder := round(8 * Screen.PixelsPerInch / DesignTimeDPI); + dist := round(dist * Screen.PixelsPerInch / DesignTimeDPI); + vdist := round(vdist * Screen.PixelsPerInch / DesignTimeDPI); + hBorder := round(hBorder * Screen.PixelsPerInch / DesignTimeDPI); editHeight := LastNameEdit.Height * Screen.PixelsPerInch div DesignTimeDPI; { Note: The resizing algorithm is dependent upon the labels having their diff --git a/components/tvplanit/source/vpedelem.lfm b/components/tvplanit/source/vpedelem.lfm index 3b2e50cd9..37c9fe9a7 100644 --- a/components/tvplanit/source/vpedelem.lfm +++ b/components/tvplanit/source/vpedelem.lfm @@ -1,13 +1,13 @@ object frmEditElement: TfrmEditElement Left = 691 - Height = 479 + Height = 453 Top = 226 Width = 413 HorzScrollBar.Page = 378 VertScrollBar.Page = 444 BorderStyle = bsDialog Caption = 'Edit Element' - ClientHeight = 479 + ClientHeight = 453 ClientWidth = 413 OnCreate = FormCreate OnShow = FormShow @@ -83,7 +83,7 @@ object frmEditElement: TfrmEditElement object btnOk: TButton Left = 240 Height = 25 - Top = 440 + Top = 416 Width = 75 Caption = 'OK' Default = True @@ -91,9 +91,9 @@ object frmEditElement: TfrmEditElement TabOrder = 7 end object btnCancel: TButton - Left = 320 + Left = 325 Height = 25 - Top = 440 + Top = 416 Width = 75 Cancel = True Caption = 'Cancel' @@ -110,7 +110,7 @@ object frmEditElement: TfrmEditElement object btnShape: TButton Left = 12 Height = 25 - Top = 440 + Top = 416 Width = 75 Caption = 'Shape...' Enabled = False @@ -314,17 +314,17 @@ object frmEditElement: TfrmEditElement end object gbCaption: TGroupBox Left = 12 - Height = 69 + Height = 56 Top = 352 Width = 388 Caption = ' Caption ' - ClientHeight = 49 + ClientHeight = 36 ClientWidth = 384 TabOrder = 5 object lblCaptionText: TLabel Left = 16 Height = 15 - Top = 12 + Top = 10 Width = 27 Caption = 'Text: ' FocusControl = edCaptionText @@ -333,7 +333,7 @@ object frmEditElement: TfrmEditElement object btnCaptionFont: TButton Left = 312 Height = 25 - Top = 7 + Top = 5 Width = 67 Caption = 'Font...' OnClick = btnCaptionFontClick @@ -342,7 +342,7 @@ object frmEditElement: TfrmEditElement object edCaptionText: TEdit Left = 52 Height = 23 - Top = 8 + Top = 6 Width = 253 OnChange = edCaptionTextChange TabOrder = 0 @@ -369,7 +369,7 @@ object frmEditElement: TfrmEditElement Left = 62 Height = 23 Top = 6 - Width = 11 + Width = 12 Associate = edOffset Min = 0 Position = 0 @@ -382,7 +382,7 @@ object frmEditElement: TfrmEditElement Font.Name = 'MS Sans Serif' MinFontSize = 0 MaxFontSize = 0 - left = 176 - top = 288 + left = 144 + top = 432 end end diff --git a/components/tvplanit/source/vpedelem.pas b/components/tvplanit/source/vpedelem.pas index 78a84fb00..ffd17aced 100644 --- a/components/tvplanit/source/vpedelem.pas +++ b/components/tvplanit/source/vpedelem.pas @@ -299,8 +299,9 @@ const GROUPBOX_CORRECTION = 16; GROUPBOX_DISTANCE = 16; var - i, w: Integer; + i, w, h: Integer; cnv: TControlCanvas; + rb: TRadioButton; begin cnv := TControlCanvas.Create; try @@ -352,6 +353,7 @@ begin udLeft.Left := udTop.Left; lblTop.Left := edTop.Left - GetLabelWidth(lblTop) - DELTA; lblLeft.Left := edTop.Left - GetLabelWidth(lblLeft) - DELTA; + chkVisible.Left := edLeft.Left; edHeight.Left := (gbVisual.ClientWidth + RightOf(rgMeasurement) + w ) div 2 - udHeight.Width - edHeight.Width; edWidth.Left := edHeight.Left; @@ -384,14 +386,42 @@ begin edCaptionText.Width := btnCaptionFont.Left - DELTA - edCaptionText.Left; // Buttons at the bottom + w := Max(GetButtonWidth(btnOK), GetButtonWidth(btnCancel)); + btnOK.Width := w; + btnCancel.Width := w; + { cnv.Font.Assign(btnOK.Font); w := Max(cnv.TextWidth(btnOK.Caption), cnv.TextWidth(btnCancel.Caption)); btnOK.Width := w + BUTTON_CORRECTION; btnCancel.Width := btnOK.Width; + } btnCancel.Left := RightOf(gbCaption) - btnCancel.Width; btnOK.Left := btnCancel.Left - DELTA - btnOK.Width; btnShape.Width := cnv.TextWidth(btnShape.Caption) + BUTTON_CORRECTION; + // Height + gbDayOffset.ClientHeight := edOffset.Height + DELTA*2; + rgDayOffsetUnit.Height := gbDayOffset.Height; + + rb := TRadioButton.Create(self); + try + rb.Parent := self; + h := rb.Height; + finally + rb.Free; + end; + rgRotation.Height := 4*h + 28; + rgMeasurement.Height := rgRotation.Height; + gbVisual.ClientHeight := BottomOf(rgMeasurement) + DELTA; + + gbCaption.Top := BottomOf(gbVisual) + DELTA; + gbCaption.ClientHeight := BottomOf(edCaptionText) + DELTA; + + btnOK.Top := BottomOf(gbCaption) + DELTA; + btnCancel.Top := btnOK.Top; + btnShape.Top := btnOK.Top; + + ClientHeight := BottomOf(btnOK) + DELTA; finally cnv.Free; end; diff --git a/components/tvplanit/source/vpedfmt.lfm b/components/tvplanit/source/vpedfmt.lfm index 4564e20c6..20bd761b5 100644 --- a/components/tvplanit/source/vpedfmt.lfm +++ b/components/tvplanit/source/vpedfmt.lfm @@ -105,7 +105,7 @@ object frmEditFormat: TfrmEditFormat Left = 158 Height = 23 Top = 68 - Width = 16 + Width = 12 Associate = edIncrement Max = 365 Min = 0 diff --git a/components/tvplanit/source/vpedfmt.pas b/components/tvplanit/source/vpedfmt.pas index 1c194d30d..60cd629b9 100644 --- a/components/tvplanit/source/vpedfmt.pas +++ b/components/tvplanit/source/vpedfmt.pas @@ -62,6 +62,7 @@ type procedure FormCreate(Sender: TObject); procedure FormShow(Sender: TObject); private + procedure PositionControls; procedure SetCaptions; protected procedure SaveData(AFormat: TVpPrintFormatItem); @@ -136,12 +137,6 @@ begin end; procedure TfrmEditFormat.SetCaptions; -const - DELTA = 8; - MARGIN = 16; -var - cnv: TControlCanvas; - w: Integer; begin Caption := RSEditFormatCaption; LblName.Caption := RSNameLbl; @@ -155,31 +150,58 @@ begin btnOK.Caption := RSOKBtn; btnCancel.Caption := RSCancelBtn; + PositionControls; +end; + +procedure TfrmEditFormat.PositionControls; +var + delta: integer = 8; + margin: Integer = 16; + vdist: Integer = 4; +var + w, h: Integer; + dummyRB: TRadioButton; +begin + delta := Round(delta * Screen.PixelsPerInch / DesignTimeDPI); + margin := Round(margin * Screen.PixelsPerInch / DesignTimeDPI); + vdist := Round(vdist * Screen.PixelsPerInch / DesignTimeDPI); + w := MaxValue([GetLabelWidth(LblName), GetLabelWidth(LblDescription), GetLabelWidth(LblIncrement)]); - edName.Left := MARGIN + w + DELTA; + edName.Left := margin + w + delta; edDescription.Left := edName.Left; edDescription.Width := edName.Width; edIncrement.Left := edName.Left; udIncrement.Left := edIncrement.Left + edIncrement.Width; - LblName.Left := edName.Left - GetLabelWidth(LblName) - DELTA; - LblDescription.Left := edDescription.Left - GetLabelWidth(lblDescription) - DELTA; - lblIncrement.Left := edIncrement.Left - GetLabelWidth(lblIncrement) - DELTA; + LblName.Left := edName.Left - GetLabelWidth(LblName) - delta; + LblDescription.Left := edDescription.Left - GetLabelWidth(lblDescription) - delta; + lblIncrement.Left := edIncrement.Left - GetLabelWidth(lblIncrement) - delta; - ClientWidth := MARGIN + w + DELTA + edName.Width + MARGIN; - rgDayIncrement.Width := ClientWidth - 2*MARGIN; + ClientWidth := MARGIN + w + delta + edName.Width + margin; + rgDayIncrement.Width := ClientWidth - 2*margin; - cnv := TControlCanvas.Create; - try - cnv.Control := btnOK; - cnv.Font.Assign(btnOK.Font); - w := Max(cnv.TextWidth(RSOKBtn), cnv.TextWidth(RSCancelBtn)); - finally - cnv.Free; - end; - btnOK.Width := w + 16; - btnCancel.Width := w + 16; - btnCancel.Left := ClientWidth - MARGIN - btnCancel.Width; - btnOK.Left := btnCancel.Left - 8 - btnOK.Width; + w := Max(GetButtonWidth(btnOK), GetButtonWidth(btnCancel)); + btnOK.Width := w; + btnCancel.Width := w; + btnCancel.Left := RightOf(rgDayIncrement) - btnCancel.Width; + btnOK.Left := btnCancel.Left - delta - btnOK.Width; + + edDescription.Top := BottomOf(edName) + vDist; + lblDescription.Top := edDescription.Top + (edDescription.Height - lblDescription.Height) div 2; + edIncrement.Top := BottomOf(edDescription) + vDist; + udIncrement.Top := edIncrement.Top; + lblIncrement.top := edIncrement.Top + (edIncrement.Height - lblIncrement.Height) div 2; + rgDayIncrement.Top := BottomOf(edIncrement) + vDist + vDist; + + DummyRB := TRadioButton.Create(self); + DummyRB.Parent := self; + h := DummyRB.Height; + DummyRB.Free; + + rgdayIncrement.Height := h + 2*LblName.Height; + btnOK.Top := Bottomof(rgDayIncrement) + vDist; + btnCancel.Top := btnOK.Top; + + ClientHeight := Bottomof(btnOK) + vDist*2; end; procedure TfrmEditFormat.SetData(AFormat: TVpPrintFormatItem); diff --git a/components/tvplanit/source/vpedfmtlst.lfm b/components/tvplanit/source/vpedfmtlst.lfm index cb122e09d..8aacf8727 100644 --- a/components/tvplanit/source/vpedfmtlst.lfm +++ b/components/tvplanit/source/vpedfmtlst.lfm @@ -54,7 +54,7 @@ object frmPrnFormat: TfrmPrnFormat OnClick = btnMoveElementUpClick end object btnMoveElementDn: TSpeedButton - Left = 305 + Left = 304 Height = 22 Top = 403 Width = 23 diff --git a/components/tvplanit/source/vpedfmtlst.pas b/components/tvplanit/source/vpedfmtlst.pas index fae6def12..1b45017c7 100644 --- a/components/tvplanit/source/vpedfmtlst.pas +++ b/components/tvplanit/source/vpedfmtlst.pas @@ -103,6 +103,7 @@ type LastX, LastY: Integer; DragItem: Integer; FDrawingStyle: TVpDrawingStyle; + procedure PositionControls; procedure SetCaptions; procedure SetDrawingStyle(const v: TVpDrawingStyle); @@ -167,7 +168,7 @@ end; procedure TfrmPrnFormat.EnableMoveButtons; begin btnMoveElementUp.Enabled := lbElements.ItemIndex > 0; - btnMoveElementDn.Enabled := lbElements.ItemIndex < lbElements.Items.Count - 1; + btnMoveElementDn.Enabled := (lbElements.ItemIndex > -1) and (lbElements.ItemIndex < lbElements.Items.Count - 1); end; {=====} procedure TfrmPrnFormat.FormShow(Sender: TObject); @@ -647,9 +648,6 @@ begin end; procedure TfrmPrnFormat.SetCaptions; -var - cnv: TControlCanvas; - w: Integer; begin Caption := RSPrintFormatDesigner; LblFormats.Caption := RSFormats; @@ -666,6 +664,48 @@ begin btnLoadFile.Caption := RSLoadFileBtn; btnSaveFile.Caption := RSSaveFileBtn; + PositionControls; +end; + +procedure TfrmPrnFormat.PositionControls; +var + w: Integer; + dist: Integer; + btndist: Integer; +begin + dist := round(8 * Screen.PixelsPerInch / DesignTimeDPI); + btnDist := btnEditFormat.Top - BottomOf(btnNewFormat); + + w := MaxValue([GetButtonWidth(btnNewFile), GetButtonWidth(btnLoadFile), GetButtonWidth(btnSaveFile)]); + btnNewFile.Width := w; + btnLoadFile.Width := w; + btnSaveFile.Width := w; + btnLoadFile.Left := RightOf(btnNewFile) + dist; + btnSaveFile.Left := RightOf(btnLoadFile) + dist; + + w := MaxValue([GetButtonWidth(btnNewFormat), GetButtonWidth(btnEditFormat), GetButtonWidth(btnDeleteFormat)]); + btnNewFormat.Left := RightOf(lbFormats) + dist; + btnEditFormat.Left := btnNewFormat.Left; + btnDeleteFormat.Left := btnNewFormat.Left; + btnNewElement.Left := btnNewFormat.Left; + btnEditElement.Left := btnNewFormat.Left; + btnDeleteElement.Left := btnNewFormat.Left; + + LblPrintOrder.Left := BtnNewFormat.Left + (BtnNewFormat.Width - GetLabelWidth(LblPrintOrder)) div 2; + btnMoveElementUp.Left := BtnNewFormat.Left + (BtnNewFormat.Width - btnMoveElementUp.Width) div 2; + btnMoveElementDn.Left := btnMoveElementUp.Left; + LblPrintOrder.Top := BottomOf(BtnDeleteElement) + btndist; + btnMoveElementUp.Top := BottomOf(LblPrintOrder) + Round(8 * Screen.PixelsPerInch / DesignTimeDPI); + btnMoveElementDn.Top := BottomOf(BtnMoveElementUp) + Round(8 * Screen.PixelsPerInch / DesignTimeDPI); + + PrintPreviewPanel.Left := BtnNewFormat.Left + BtnNewFormat.Width + dist; + + ClientWidth := PrintPreviewPanel.Left + PrintPreviewPanel.Width + 8; +end; +{ + + + w := 0; cnv := TControlCanvas.Create; try @@ -698,6 +738,7 @@ begin BtnNewElement.Width := w; BtnEditElement.Width := w; BtnDeleteElement.Width := w; + LblPrintOrder.Left := BtnNewFormat.Left + (BtnNewFormat.Width - GetLabelWidth(LblPrintOrder)) div 2; btnMoveElementUp.Left := BtnNewFormat.Left + (BtnNewFormat.Width - btnMoveElementUp.Width) div 2; btnMoveElementDn.Left := btnMoveElementUp.Left; @@ -709,6 +750,7 @@ begin cnv.Free; end; end; + } procedure TfrmPrnFormat.SetDrawingStyle(const v: TVpDrawingStyle); begin diff --git a/components/tvplanit/source/vpedshape.lfm b/components/tvplanit/source/vpedshape.lfm index c037ded24..f67a8b8a4 100644 --- a/components/tvplanit/source/vpedshape.lfm +++ b/components/tvplanit/source/vpedshape.lfm @@ -22,7 +22,7 @@ object frmEditShape: TfrmEditShape Caption = 'OK' Default = True OnClick = btnOkClick - TabOrder = 2 + TabOrder = 3 end object btnCancel: TButton Left = 272 @@ -32,7 +32,7 @@ object frmEditShape: TfrmEditShape Cancel = True Caption = 'Cancel' OnClick = btnCancelClick - TabOrder = 3 + TabOrder = 4 end object gbBrush: TGroupBox Left = 186 @@ -42,7 +42,7 @@ object frmEditShape: TfrmEditShape Caption = ' Brush ' ClientHeight = 66 ClientWidth = 161 - TabOrder = 1 + TabOrder = 2 object lblBrushStyle: TLabel Left = 8 Height = 15 @@ -54,13 +54,12 @@ object frmEditShape: TfrmEditShape end object cbBrushStyle: TComboBox Left = 52 - Height = 22 + Height = 23 Top = 32 Width = 97 - ItemHeight = 16 + ItemHeight = 15 OnChange = cbBrushStyleChange OnDrawItem = cbBrushStyleDrawItem - Style = csOwnerDrawFixed TabOrder = 0 end object lblBrushColor: TLabel @@ -91,7 +90,7 @@ object frmEditShape: TfrmEditShape Caption = ' Pen ' ClientHeight = 120 ClientWidth = 161 - TabOrder = 0 + TabOrder = 1 object lblPenStyle: TLabel Left = 8 Height = 15 @@ -121,14 +120,13 @@ object frmEditShape: TfrmEditShape end object cbPenStyle: TComboBox Left = 52 - Height = 22 + Height = 23 Top = 32 Width = 97 - ItemHeight = 16 + ItemHeight = 15 OnChange = cbPenStyleChange OnDrawItem = cbPenStyleDrawItem - Style = csOwnerDrawFixed - TabOrder = 0 + TabOrder = 1 end object cbPenMode: TComboBox Left = 52 @@ -136,13 +134,13 @@ object frmEditShape: TfrmEditShape Top = 88 Width = 97 ItemHeight = 15 - TabOrder = 1 + TabOrder = 4 end object udPenWidth: TUpDown Left = 98 Height = 23 Top = 60 - Width = 11 + Width = 12 Associate = edPenWidth Min = 0 Position = 0 @@ -166,7 +164,7 @@ object frmEditShape: TfrmEditShape Style = [cbStandardColors, cbExtendedColors, cbPrettyNames, cbCustomColors] ItemHeight = 16 OnChange = cbPenColorChange - TabOrder = 4 + TabOrder = 0 end object lblPenColor: TLabel Left = 8 @@ -186,7 +184,7 @@ object frmEditShape: TfrmEditShape Caption = 'gbShapes' ClientHeight = 47 ClientWidth = 320 - TabOrder = 4 + TabOrder = 0 object SpeedButton1: TSpeedButton Left = 12 Height = 32 diff --git a/components/tvplanit/source/vpedshape.pas b/components/tvplanit/source/vpedshape.pas index 91e74df56..710729cd3 100644 --- a/components/tvplanit/source/vpedshape.pas +++ b/components/tvplanit/source/vpedshape.pas @@ -297,13 +297,26 @@ begin end; {=====} procedure TfrmEditShape.PositionControls; -const - DELTA = 8; var - w: Integer; - cnv: TControlCanvas; + w, h: Integer; shape: TVpShapeType; + delta: Integer; + vdist: Integer; begin + // This is needed as workaround for the combobox height at higher dpi. + // We design it with Style csDropdown where the height is correct, and then + // use the corresponding, correct ItemHeight after switching to csOwnerDrawFixed + // (which is needed to draw the icons). + h := cbPenStyle.ItemHeight; + cbPenStyle.Style := csOwnerDrawFixed; + cbPenStyle.ItemHeight := h+1; + cbBrushStyle.Style := csOwnerDrawFixed; + cbBrushStyle.ItemHeight := h+1; + + delta := round(8 * Screen.PixelsPerInch / DesignTimeDPI); + vdist := round(4 * Screen.PixelsPerInch / DesignTimeDPI); + + // Horizontal alignment w := MaxValue([GetLabelWidth(lblPenColor), GetLabelWidth(lblPenStyle), GetLabelWidth(lblPenWidth), GetLabelWidth(lblPenMode)]) + 2 * DELTA; cbPenColor.Left := w; @@ -324,15 +337,7 @@ begin gbBrush.Left := RightOf(gbPen) + 16; gbBrush.Width := RightOf(cbBrushColor) + DELTA; - cnv := TControlCanvas.Create; - try - cnv.Control := btnOK; - cnv.Font.Assign(btnOK.Font); - btnOK.Width := MaxValue([cnv.TextWidth(btnOK.Caption), cnv.TextWidth(btnCancel.Caption)]) + 16; - finally - cnv.Free; - end; - + btnOK.Width := Max(GetButtonWidth(btnOK), GetButtonWidth(btnCancel)); btnCancel.Width := btnOK.Width; if btnOK.Width + DELTA + btnCancel.Width > gbBrush.Width then gbBrush.Width := btnOK.Width + DELTA + btnCancel.Width; @@ -349,6 +354,27 @@ begin FShapeButtons[shape].Left := RightOf(FShapeButtons[pred(shape)]) + DELTA; FShapeButtons[shape].Width := w; end; + + // Vertical alignment + lblPenColor.Top := cbPenColor.Top + (cbPenColor.Height - lblPenColor.Height) div 2; + lblBrushColor.Top := lblPenColor.Top; + cbPenStyle.Top := BottomOf(cbPenColor) + vdist; + cbBrushStyle.Top := cbPenStyle.Top; + lblPenstyle.Top := cbPenStyle.Top + (cbPenStyle.Height - lblPenStyle.Height) div 2; + lblBrushStyle.Top := lblPenStyle.Top; + edPenWidth.Top := BottomOf(cbPenStyle) + vDist; + udPenWidth.Top := edPenWidth.Top; + lblPenWidth.Top := edPenWidth.Top + (edPenWidth.Height - lblPenWidth.Height) div 2; + cbPenMode.Top := BottomOf(edPenWidth) + vDist; + lblPenMode.Top := cbPenMode.Top + (cbPenMode.Height - lblPenMode.Height) div 2; + gbPen.ClientHeight := BottomOf(cbPenMode) + delta; + gbBrush.ClientHeight := BottomOf(cbBrushStyle) + delta; + + btnOK.Top := BottomOf(gbPen) - btnOK.Height; + btnCancel.Top := btnOK.Top; + + ClientHeight := BottomOf(btnOK) + delta; + end; procedure TfrmEditShape.SaveData(AShape: TVpPrintShape); diff --git a/components/tvplanit/source/vpprtfmtdlg.pas b/components/tvplanit/source/vpprtfmtdlg.pas index 0c59596ce..9cad12f56 100644 --- a/components/tvplanit/source/vpprtfmtdlg.pas +++ b/components/tvplanit/source/vpprtfmtdlg.pas @@ -44,7 +44,7 @@ uses type - TVpPrintFormatEditDialog = class (TVpBaseDialog) + TVpPrintFormatEditDialog = class(TVpBaseDialog) private FControlLink: TVpControlLink; FDrawingStyle: TVpDrawingStyle; diff --git a/components/tvplanit/source/vpprtprvdlg.pas b/components/tvplanit/source/vpprtprvdlg.pas index 19557f597..bfe0fac33 100644 --- a/components/tvplanit/source/vpprtprvdlg.pas +++ b/components/tvplanit/source/vpprtprvdlg.pas @@ -434,6 +434,7 @@ begin maxlen := Max(maxlen, cnv.TextWidth(fmts.Items[i].FormatName)); VpPrintFormatCombobox1.Width := maxlen + 30; cboxZoom.Left := VpPrintFormatCombobox1.Left + VpPrintFormatCombobox1.Width + 8; + finally cnv.Free; end; diff --git a/components/tvplanit/source/vpreseditdlg.pas b/components/tvplanit/source/vpreseditdlg.pas index eecea1f13..d43a9b85f 100644 --- a/components/tvplanit/source/vpreseditdlg.pas +++ b/components/tvplanit/source/vpreseditdlg.pas @@ -64,6 +64,7 @@ type procedure Change(Sender: TObject); procedure FormShow(Sender: TObject); private + procedure PositionControls; procedure SetControls; public ReturnCode: TVpEditorReturnCode; @@ -99,6 +100,7 @@ implementation {$ENDIF} uses + Math, vpSR, vpMisc; function ExecuteResourceDlg(Resource: TVpResource): Boolean; @@ -208,12 +210,33 @@ begin OKBtn.Caption := RSOKBtn; CancelBtn.Caption := RSCancelBtn; - DescriptionEdit.Left := lblDescription.Left + GetLabelWidth(lblDescription) + 8; - DescriptionEdit.Width := imgResources.Left - 16 - DescriptionEdit.Left; - + PositionControls; end; {=====} +procedure TResEditForm.PositionControls; +var + Delta: Integer; +begin + delta := round(8 *Screen.PixelsPerInch / DesignTimeDPI); + + DescriptionEdit.Left := lblDescription.Left + GetLabelWidth(lblDescription) + Delta; + DescriptionEdit.Width := imgResources.Left - delta - delta - DescriptionEdit.Left; + DescriptionEdit.Top := imgResources.Top + (imgResources.Height - DescriptionEdit.Height) div 2; + lblDescription.Top := DescriptionEdit.Top + (DescriptionEdit.Height - lblDescription.Height) div 2; + + lblNotes.Top := BottomOf(DescriptionEdit) + delta; + NotesMemo.Top := BottomOf(lblNotes) + delta div 2; + NotesMemo.Height := tabResource.ClientHeight - NotesMemo.Top - NotesMemo.Left; + + OKBtn.Width := Max(GetButtonWidth(OKBtn), GetButtonWidth(CancelBtn)); + CancelBtn.Width := OKBtn.Width; + CancelBtn.Left := pnlBottom.ClientWidth - lblDescription.Left - CancelBtn.Width; + OKBtn.Left := CancelBtn.Left - OKBtn.Width - delta - (ClientWidth - tabResource.ClientWidth); + OKBtn.Top := (pnlBottom.ClientHeight - OKBtn.Height) div 2; + CancelBtn.Top := OKBtn.Top; +end; + procedure TResEditForm.OKBtnClick(Sender: TObject); begin if ResourceChanged then