diff --git a/components/tvplanit/source/vpedelem.lfm b/components/tvplanit/source/vpedelem.lfm index 37c9fe9a7..f82f63d1a 100644 --- a/components/tvplanit/source/vpedelem.lfm +++ b/components/tvplanit/source/vpedelem.lfm @@ -1,133 +1,34 @@ object frmEditElement: TfrmEditElement Left = 691 - Height = 453 + Height = 503 Top = 226 - Width = 413 + Width = 489 HorzScrollBar.Page = 378 VertScrollBar.Page = 444 BorderStyle = bsDialog Caption = 'Edit Element' - ClientHeight = 453 - ClientWidth = 413 + ClientHeight = 503 + ClientWidth = 489 OnCreate = FormCreate OnShow = FormShow Position = poScreenCenter LCLVersion = '1.7' - object lblName: TLabel - Left = 12 - Height = 15 - Top = 16 - Width = 38 - Caption = 'Name: ' - ParentColor = False - end - object rgItemType: TRadioGroup - Left = 12 - Height = 81 - Top = 44 - Width = 388 - AutoFill = True - Caption = 'Item Type ' - ChildSizing.LeftRightSpacing = 6 - ChildSizing.TopBottomSpacing = 6 - ChildSizing.EnlargeHorizontal = crsHomogenousChildResize - ChildSizing.EnlargeVertical = crsHomogenousChildResize - ChildSizing.ShrinkHorizontal = crsScaleChilds - ChildSizing.ShrinkVertical = crsScaleChilds - ChildSizing.Layout = cclLeftToRightThenTopToBottom - ChildSizing.ControlsPerLine = 4 - ClientHeight = 61 - ClientWidth = 384 - Columns = 4 - ItemIndex = 0 - Items.Strings = ( - 'DayView' - 'WeekView' - 'MonthView' - 'Calendar' - 'Shape' - 'Caption' - 'Tasks' - 'Contacts' - ) - OnClick = rgItemTypeClick - TabOrder = 1 - end - object rgDayOffsetUnit: TRadioGroup - Left = 116 - Height = 56 - Top = 136 - Width = 284 - AutoFill = True - Caption = ' Day Offset Unit ' - ChildSizing.LeftRightSpacing = 6 - ChildSizing.TopBottomSpacing = 6 - ChildSizing.EnlargeHorizontal = crsHomogenousChildResize - ChildSizing.EnlargeVertical = crsHomogenousChildResize - ChildSizing.ShrinkHorizontal = crsScaleChilds - ChildSizing.ShrinkVertical = crsScaleChilds - ChildSizing.Layout = cclLeftToRightThenTopToBottom - ChildSizing.ControlsPerLine = 4 - ClientHeight = 36 - ClientWidth = 280 - Columns = 4 - ItemIndex = 0 - Items.Strings = ( - 'Day' - 'Week' - 'Month' - 'Year' - ) - TabOrder = 3 - end - object btnOk: TButton - Left = 240 - Height = 25 - Top = 416 - Width = 75 - Caption = 'OK' - Default = True - OnClick = btnOkClick - TabOrder = 7 - end - object btnCancel: TButton - Left = 325 - Height = 25 - Top = 416 - Width = 75 - Cancel = True - Caption = 'Cancel' - OnClick = btnCancelClick - TabOrder = 8 - end - object edName: TEdit - Left = 56 - Height = 23 - Top = 12 - Width = 344 - TabOrder = 0 - end - object btnShape: TButton - Left = 12 - Height = 25 - Top = 416 - Width = 75 - Caption = 'Shape...' - Enabled = False - OnClick = btnShapeClick - TabOrder = 6 - end object gbVisual: TGroupBox Left = 12 - Height = 129 - Top = 208 - Width = 388 + Height = 148 + Top = 181 + Width = 465 + Align = alTop + AutoSize = True + BorderSpacing.Left = 12 + BorderSpacing.Top = 8 + BorderSpacing.Right = 12 Caption = ' Visual ' - ClientHeight = 109 - ClientWidth = 384 - TabOrder = 4 + ClientHeight = 128 + ClientWidth = 461 + TabOrder = 0 object LblTop: TLabel - Left = 172 + Left = 224 Height = 15 Top = 20 Width = 23 @@ -136,7 +37,7 @@ object frmEditElement: TfrmEditElement ParentColor = False end object LblLeft: TLabel - Left = 172 + Left = 224 Height = 15 Top = 48 Width = 23 @@ -145,29 +46,36 @@ object frmEditElement: TfrmEditElement ParentColor = False end object LblHeight: TLabel - Left = 276 + Left = 352 Height = 15 Top = 20 Width = 39 + BorderSpacing.Right = 4 Caption = 'Height:' FocusControl = edHeight ParentColor = False end object LblWidth: TLabel - Left = 280 + Left = 357 Height = 15 Top = 48 Width = 35 + BorderSpacing.Right = 4 Caption = 'Width:' FocusControl = edWidth ParentColor = False end object rgMeasurement: TRadioGroup - Left = 76 - Height = 99 + AnchorSideLeft.Control = rgRotation + AnchorSideLeft.Side = asrBottom + Left = 103 + Height = 108 Top = 0 - Width = 89 + Width = 98 AutoFill = True + AutoSize = True + BorderSpacing.Left = 7 + BorderSpacing.Bottom = 8 Caption = ' Measurement ' ChildSizing.LeftRightSpacing = 6 ChildSizing.TopBottomSpacing = 6 @@ -177,8 +85,8 @@ object frmEditElement: TfrmEditElement ChildSizing.ShrinkVertical = crsScaleChilds ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.ControlsPerLine = 1 - ClientHeight = 79 - ClientWidth = 85 + ClientHeight = 88 + ClientWidth = 94 ItemIndex = 1 Items.Strings = ( 'Pixels' @@ -190,11 +98,17 @@ object frmEditElement: TfrmEditElement TabOrder = 1 end object rgRotation: TRadioGroup + AnchorSideTop.Control = rgMeasurement + AnchorSideBottom.Control = rgMeasurement + AnchorSideBottom.Side = asrBottom Left = 8 - Height = 99 + Height = 120 Top = 0 - Width = 61 + Width = 88 AutoFill = True + BorderSpacing.Left = 8 + BorderSpacing.Bottom = 8 + BorderSpacing.InnerBorder = 8 Caption = ' Rotation ' ChildSizing.LeftRightSpacing = 6 ChildSizing.TopBottomSpacing = 6 @@ -204,8 +118,8 @@ object frmEditElement: TfrmEditElement ChildSizing.ShrinkVertical = crsScaleChilds ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.ControlsPerLine = 1 - ClientHeight = 79 - ClientWidth = 57 + ClientHeight = 100 + ClientWidth = 84 ItemIndex = 0 Items.Strings = ( '0' @@ -216,7 +130,7 @@ object frmEditElement: TfrmEditElement TabOrder = 0 end object edTop: TEdit - Left = 208 + Left = 260 Height = 23 Top = 16 Width = 48 @@ -226,7 +140,7 @@ object frmEditElement: TfrmEditElement Text = '0.00' end object edLeft: TEdit - Left = 208 + Left = 260 Height = 23 Top = 44 Width = 48 @@ -236,7 +150,7 @@ object frmEditElement: TfrmEditElement Text = '0.00' end object edHeight: TEdit - Left = 321 + Left = 399 Height = 23 Top = 16 Width = 40 @@ -246,7 +160,7 @@ object frmEditElement: TfrmEditElement Text = '0.00' end object edWidth: TEdit - Left = 321 + Left = 399 Height = 23 Top = 44 Width = 40 @@ -256,7 +170,7 @@ object frmEditElement: TfrmEditElement Text = '0.00' end object chkVisible: TCheckBox - Left = 208 + Left = 260 Height = 19 Top = 80 Width = 54 @@ -264,7 +178,7 @@ object frmEditElement: TfrmEditElement TabOrder = 10 end object udTop: TUpDown - Left = 256 + Left = 308 Height = 23 Top = 16 Width = 12 @@ -276,7 +190,7 @@ object frmEditElement: TfrmEditElement Wrap = False end object udLeft: TUpDown - Left = 256 + Left = 308 Height = 23 Top = 44 Width = 12 @@ -288,11 +202,13 @@ object frmEditElement: TfrmEditElement Wrap = False end object udHeight: TUpDown - Left = 361 + AnchorSideRight.Side = asrBottom + Left = 439 Height = 23 Top = 16 Width = 12 Associate = edHeight + BorderSpacing.Right = 8 Min = 0 OnClick = UpDownClick Position = 0 @@ -300,11 +216,13 @@ object frmEditElement: TfrmEditElement Wrap = False end object udWidth: TUpDown - Left = 361 + AnchorSideRight.Side = asrBottom + Left = 439 Height = 23 Top = 44 Width = 12 Associate = edWidth + BorderSpacing.Right = 8 Min = 0 OnClick = UpDownClick Position = 0 @@ -314,67 +232,282 @@ object frmEditElement: TfrmEditElement end object gbCaption: TGroupBox Left = 12 - Height = 56 - Top = 352 - Width = 388 + Height = 54 + Top = 337 + Width = 465 + Align = alTop + AutoSize = True + BorderSpacing.Left = 12 + BorderSpacing.Top = 8 + BorderSpacing.Right = 12 Caption = ' Caption ' - ClientHeight = 36 - ClientWidth = 384 - TabOrder = 5 + ClientHeight = 34 + ClientWidth = 461 + TabOrder = 1 object lblCaptionText: TLabel - Left = 16 + AnchorSideLeft.Control = gbCaption + AnchorSideTop.Control = edCaptionText + AnchorSideTop.Side = asrCenter + Left = 8 Height = 15 - Top = 10 + Top = 6 Width = 27 + BorderSpacing.Left = 8 Caption = 'Text: ' FocusControl = edCaptionText ParentColor = False end object btnCaptionFont: TButton - Left = 312 + AnchorSideTop.Control = edCaptionText + AnchorSideTop.Side = asrCenter + AnchorSideRight.Control = gbCaption + AnchorSideRight.Side = asrBottom + Left = 386 Height = 25 - Top = 5 + Top = 1 Width = 67 + Anchors = [akTop, akRight] + BorderSpacing.Right = 8 + BorderSpacing.Bottom = 8 Caption = 'Font...' OnClick = btnCaptionFontClick TabOrder = 1 end object edCaptionText: TEdit - Left = 52 + AnchorSideLeft.Control = lblCaptionText + AnchorSideLeft.Side = asrBottom + AnchorSideRight.Control = btnCaptionFont + Left = 39 Height = 23 - Top = 6 - Width = 253 + Top = 2 + Width = 343 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Left = 4 + BorderSpacing.Top = 2 + BorderSpacing.Right = 4 + BorderSpacing.Bottom = 8 OnChange = edCaptionTextChange TabOrder = 0 end end - object gbDayOffset: TGroupBox + object Panel1: TPanel + Left = 12 + Height = 23 + Top = 8 + Width = 465 + Align = alTop + AutoSize = True + BorderSpacing.Left = 12 + BorderSpacing.Top = 8 + BorderSpacing.Right = 12 + BorderSpacing.Bottom = 8 + BevelOuter = bvNone + ClientHeight = 23 + ClientWidth = 465 + TabOrder = 2 + object lblName: TLabel + AnchorSideTop.Control = edName + AnchorSideTop.Side = asrCenter + Left = 0 + Height = 15 + Top = 4 + Width = 38 + Caption = 'Name: ' + ParentColor = False + end + object edName: TEdit + AnchorSideLeft.Control = lblName + AnchorSideLeft.Side = asrBottom + Left = 42 + Height = 23 + Top = 0 + Width = 423 + Align = alRight + Anchors = [akTop, akLeft, akRight, akBottom] + BorderSpacing.Left = 4 + TabOrder = 0 + end + end + object Panel2: TPanel Left = 12 Height = 56 - Top = 136 - Width = 92 - Caption = 'Day Offset' - ClientHeight = 36 - ClientWidth = 88 - TabOrder = 2 - object edOffset: TEdit - Left = 8 - Height = 23 - Top = 6 - Width = 54 + Top = 117 + Width = 467 + Align = alTop + AutoSize = True + BorderSpacing.Left = 12 + BorderSpacing.Top = 8 + BorderSpacing.Right = 10 + BevelOuter = bvNone + ClientHeight = 56 + ClientWidth = 467 + TabOrder = 3 + object gbDayOffset: TGroupBox + Left = 0 + Height = 56 + Top = 0 + Width = 98 + Caption = 'Day Offset' + ClientHeight = 36 + ClientWidth = 94 TabOrder = 0 - Text = '0' + object edOffset: TEdit + Left = 8 + Height = 23 + Top = 2 + Width = 64 + BorderSpacing.Left = 8 + BorderSpacing.Bottom = 8 + TabOrder = 0 + Text = '0' + end + object udOffset: TUpDown + Left = 72 + Height = 23 + Top = 2 + Width = 12 + Associate = edOffset + BorderSpacing.Right = 8 + Min = 0 + Position = 0 + TabOrder = 1 + Wrap = False + end end - object udOffset: TUpDown - Left = 62 - Height = 23 - Top = 6 - Width = 12 - Associate = edOffset - Min = 0 - Position = 0 + object rgDayOffsetUnit: TRadioGroup + AnchorSideLeft.Control = gbDayOffset + AnchorSideLeft.Side = asrBottom + AnchorSideRight.Control = Panel2 + AnchorSideRight.Side = asrBottom + Left = 106 + Height = 51 + Top = 0 + Width = 361 + Anchors = [akTop, akLeft, akRight] + AutoFill = True + AutoSize = True + BorderSpacing.Left = 8 + Caption = ' Day Offset Unit ' + ChildSizing.LeftRightSpacing = 6 + ChildSizing.TopBottomSpacing = 6 + ChildSizing.EnlargeHorizontal = crsHomogenousChildResize + ChildSizing.EnlargeVertical = crsHomogenousChildResize + ChildSizing.ShrinkHorizontal = crsScaleChilds + ChildSizing.ShrinkVertical = crsScaleChilds + ChildSizing.Layout = cclLeftToRightThenTopToBottom + ChildSizing.ControlsPerLine = 4 + ClientHeight = 31 + ClientWidth = 357 + Columns = 4 + ItemIndex = 0 + Items.Strings = ( + 'Day' + 'Week' + 'Month' + 'Year' + ) TabOrder = 1 - Wrap = False + end + end + object ButtonPanel: TPanel + Left = 12 + Height = 25 + Top = 399 + Width = 465 + Align = alTop + AutoSize = True + BorderSpacing.Left = 12 + BorderSpacing.Top = 8 + BorderSpacing.Right = 12 + BorderSpacing.Bottom = 9 + BevelOuter = bvNone + ClientHeight = 25 + ClientWidth = 465 + TabOrder = 4 + object btnShape: TButton + AnchorSideLeft.Control = ButtonPanel + Left = 0 + Height = 25 + Top = 0 + Width = 75 + Caption = 'Shape...' + Enabled = False + OnClick = btnShapeClick + TabOrder = 0 + end + object btnOk: TButton + AnchorSideRight.Control = btnCancel + Left = 309 + Height = 25 + Top = 0 + Width = 75 + Anchors = [akTop, akRight] + BorderSpacing.Right = 7 + Caption = 'OK' + Default = True + OnClick = btnOkClick + TabOrder = 1 + end + object btnCancel: TButton + AnchorSideRight.Control = ButtonPanel + AnchorSideRight.Side = asrBottom + Left = 391 + Height = 25 + Top = 0 + Width = 74 + Anchors = [akTop, akRight] + Cancel = True + Caption = 'Cancel' + OnClick = btnCancelClick + TabOrder = 2 + end + end + object ItemTypePanel: TPanel + Left = 12 + Height = 70 + Top = 39 + Width = 467 + Align = alTop + AutoSize = True + BorderSpacing.Left = 12 + BorderSpacing.Top = 8 + BorderSpacing.Right = 10 + BevelOuter = bvNone + ClientHeight = 70 + ClientWidth = 467 + TabOrder = 5 + object rgItemType: TRadioGroup + Left = 0 + Height = 70 + Top = 0 + Width = 303 + AutoFill = True + AutoSize = True + Caption = 'Item Type ' + ChildSizing.LeftRightSpacing = 6 + ChildSizing.TopBottomSpacing = 6 + ChildSizing.EnlargeHorizontal = crsHomogenousChildResize + ChildSizing.EnlargeVertical = crsHomogenousChildResize + ChildSizing.ShrinkHorizontal = crsScaleChilds + ChildSizing.ShrinkVertical = crsScaleChilds + ChildSizing.Layout = cclLeftToRightThenTopToBottom + ChildSizing.ControlsPerLine = 4 + ClientHeight = 50 + ClientWidth = 299 + Columns = 4 + ItemIndex = 0 + Items.Strings = ( + 'DayView' + 'WeekView' + 'MonthView' + 'Calendar' + 'Shape' + 'Caption' + 'Tasks' + 'Contacts' + ) + OnClick = rgItemTypeClick + TabOrder = 0 end end object FontDialog1: TFontDialog @@ -382,7 +515,7 @@ object frmEditElement: TfrmEditElement Font.Name = 'MS Sans Serif' MinFontSize = 0 MaxFontSize = 0 - left = 144 - top = 432 + left = 224 + top = 352 end end diff --git a/components/tvplanit/source/vpedelem.pas b/components/tvplanit/source/vpedelem.pas index 29a91971e..4dbc96c56 100644 --- a/components/tvplanit/source/vpedelem.pas +++ b/components/tvplanit/source/vpedelem.pas @@ -53,6 +53,10 @@ type edName: TEdit; gbDayOffset: TGroupBox; lblName: TLabel; + Panel1: TPanel; + Panel2: TPanel; + ButtonPanel: TPanel; + ItemTypePanel: TPanel; rgDayOffsetUnit: TRadioGroup; rgItemType: TRadioGroup; gbVisual: TGroupBox; @@ -290,18 +294,13 @@ begin end; procedure TfrmEditElement.PositionControls; -const - MARGIN = 16; - DELTA = 8; - RADIOITEM_CORRECTION = 24 + DELTA; - BUTTON_CORRECTION = 16; - GROUPBOX_CORRECTION = 16; - GROUPBOX_DISTANCE = 16; var - i, w, h, hEd, hBtn: Integer; - cnv: TControlCanvas; - rb: TRadioButton; + w, hEd, hBtn: Integer; + DELTA: Integer = 8; begin + DELTA := ScaleX(DELTA, DesignTimeDPI); + AutoSize := false; + // Fix edit heights at higher dpi with TEdit.Create(self) do try @@ -336,128 +335,43 @@ begin btnShape.Height := hBtn; btnCaptionFont.Height := hBtn; - cnv := TControlCanvas.Create; - try - cnv.Control := rgItemType; + gbDayOffset.Height := rgDayOffsetUnit.Height; + rgRotation.Height := rgMeasurement.Height; + rgRotation.Width := rgMeasurement.Width; - // Calculate with of ItemType groupbbox - cnv.Font.Assign(rgItemType.Font); - w := 0; - for i:=0 to rgItemType.Items.Count - 1 do - w := Max(w, cnv.TextWidth(rgItemType.Items[i])); - rgItemType.ClientWidth := rgItemType.Columns * (w + RADIOITEM_CORRECTION); + // Position Left/Top etc controls + w := Max(GetLabelWidth(lblLeft), GetLabelWidth(lblTop)); + edTop.Left := RightOf(rgMeasurement) + 2*DELTA + w + DELTA; + udTop.Left := RightOf(edTop); + lblTop.Left := edTop.Left - DELTA - GetLabelWidth(lblTop); + edLeft.Left := edTop.Left; + udLeft.Left := RightOf(edLeft); + lblLeft.Left := edLeft.Left - DELTA - GetLabelWidth(lblLeft); - // Calculate width of Visual groupbox - cnv.Font.Assign(rgRotation.Font); - rgRotation.ClientWidth := Max( - cnv.TextWidth(RSRotationCaption) + GROUPBOX_CORRECTION, - cnv.TextWidth('270') + RADIOITEM_CORRECTION - ); + w := Max(GetLabelWidth(lblWidth), GetLabelWidth(lblHeight)); + edHeight.Left := RightOf(edTop) + 2*DELTA + w + DELTA; + edWidth.Left := edHeight.Left; + udHeight.Left := RightOf(edHeight); + udWidth.Left := RightOf(edWidth); + lblHeight.Left := edHeight.Left - DELTA - GetLabelWidth(lblHeight); + lblWidth.Left := edWidth.Left - DELTA - GetLabelWidth(lblWidth); - cnv.Font.Assign(rgMeasurement.Font); - w := 0; - for i:=0 to RgMeasurement.Items.Count-1 do - w := Max(w, cnv.TextWidth(RgMeasurement.Items[i])); - rgMeasurement.ClientWidth := Max( - cnv.TextWidth(RSMeasurementCaption) + GROUPBOX_CORRECTION, - w + RADIOITEM_CORRECTION - ); - rgMeasurement.Left := rgRotation.Left + rgRotation.Width + GROUPBOX_DISTANCE; + chkVisible.Left := edTop.Left; - w := Max(GetLabelWidth(lblTop), GetLabelWidth(lblLeft)) + DELTA + EdTop.Width + udTop.Width + 24 + - Max(GetLabelWidth(lblHeight), GetLabelWidth(lblWidth) + DELTA) + EdHeight.Width + udHeight.Width; + // Buttons at the bottom + w := Max(GetButtonWidth(btnOK), GetButtonWidth(btnCancel)); + btnOK.Width := w; + btnCancel.Width := w; + btnShape.Width := GetButtonWidth(btnShape); - gbVisual.ClientWidth := RightOf(rgMeasurement) + 24 + w + rgRotation.Left; + // Form size + rgItemType.Align := alNone; + ClientWidth := rgItemType.Width + ItemTypePanel.BorderSpacing.Left + ItemTypePanel.BorderSpacing.Right; + rgItemType.Align := alClient; + if RightOf(udHeight) > gbVisual.ClientWidth then + ClientWidth := RightOf(udHeight) + gbVisual.BorderSpacing.Left + gbVisual.BorderSpacing.Right; - // The longest box determines the width of the form - if gbVisual.ClientWidth > rgItemType.ClientWidth then - rgItemType.ClientWidth := gbVisual.ClientWidth - else - gbVisual.ClientWidth := rgItemType.ClientWidth; - - // Width of the form - ClientWidth := gbVisual.ClientWidth + MARGIN * 2; - - // Position Left/Top etc controls - edTop.Left := (gbVisual.ClientWidth + RightOf(rgMeasurement) - w) div 2 + - Max(GetLabelWidth(lblTop), GetLabelWidth(lblLeft)) + DELTA; - edLeft.Left := edTop.Left; - udTop.Left := RightOf(edTop); - 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; - lblHeight.Left := edHeight.Left - GetLabelWidth(lblHeight) - DELTA; - lblWidth.Left := edHeight.Left - GetLabelWidth(lblWidth) - DELTA; - udHeight.Left := RightOf(edHeight); - udWidth.Left := RightOf(edWidth); - - // Name - LblName.Left := MARGIN; - EdName.Left := LblName.Left + GetLabelWidth(LblName) + DELTA; - EdName.Width := RightOf(gbVisual) - EdName.Left; - - // DayOffset groupbox - cnv.Font.Assign(gbDayOffset.Font); - gbDayOffset.Width := Max(RightOf(udOffset) + DELTA, cnv.TextWidth(gbDayOffset.Caption) + GROUPBOX_CORRECTION); - - // Day Offset Unit groupbox - rgDayOffsetUnit.Left := RightOf(gbDayOffset) + GROUPBOX_DISTANCE; - rgDayOffsetUnit.Width := RightOf(gbVisual) - rgDayOffsetUnit.Left; - - // Caption groupbox - gbCaption.Width := gbVisual.Width; - lblCaptionText.Left := DELTA; - edCaptionText.Left := lblCaptionText.Left + GetLabelWidth(lblCaptionTExt) + DELTA; - cnv.Font.Assign(btnCaptionFont.Font); - w := cnv.TextWidth(btnCaptionFont.Caption) + BUTTON_CORRECTION; - btnCaptionFont.Width := w; - btnCaptionFont.Left := gbCaption.ClientWidth - DELTA - w; - 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; + AutoSize := true; end; procedure TfrmEditElement.SetData(AnElement : TVpPrintFormatElementItem); diff --git a/components/tvplanit/source/vpmisc.pas b/components/tvplanit/source/vpmisc.pas index 4822d27b7..ed54fc72a 100644 --- a/components/tvplanit/source/vpmisc.pas +++ b/components/tvplanit/source/vpmisc.pas @@ -132,6 +132,7 @@ function GetEndLine(EndTime: TDateTime; Granularity: TVpGranularity): Integer; function LineToStartTime(Line: Integer; Granularity: TVpGranularity): TDateTime; function GetLineDuration(Granularity: TVpGranularity): Double; +function AutoHeight(ARadioGroup: TRadioGroup): Integer; function GetButtonWidth(AButton: TButton): Integer; function GetLabelWidth(ALabel: TLabel): Integer; function GetRealFontHeight(AFont: TFont): Integer; @@ -589,6 +590,17 @@ begin end; {=====} +function AutoHeight(ARadioGroup: TRadioGroup): Integer; +var + w: Integer; +begin + w := ARadioGroup.Width; + ARadioGroup.AutoSize := true; + Result := ARadioGroup.Height; + ARadioGroup.AutoSize := false; + ARadioGroup.Width := w; +end; + function GetLabelWidth(ALabel: TLabel): Integer; var canvas: TControlCanvas;