From 8ae2cae749397957cd0093bb240ff002f1e30e32 Mon Sep 17 00:00:00 2001 From: wp_xyz Date: Fri, 12 May 2023 20:19:46 +0200 Subject: [PATCH] IDE: Improved layout of the ToDoDlg. (Slightly modified) patch by Don Siders. Issue #40258 --- components/todolist/tododlg.lfm | 175 ++++++++++++++++++++------------ components/todolist/tododlg.pas | 15 +++ 2 files changed, 123 insertions(+), 67 deletions(-) diff --git a/components/todolist/tododlg.lfm b/components/todolist/tododlg.lfm index 4780dc7892..74599a83ec 100644 --- a/components/todolist/tododlg.lfm +++ b/components/todolist/tododlg.lfm @@ -1,109 +1,126 @@ object TodoDialog: TTodoDialog - Left = 186 - Height = 244 - Top = 86 - Width = 384 + Left = 224 + Height = 230 + Top = 127 + Width = 361 ActiveControl = TodoMemo Caption = 'Insert Todo' - ClientHeight = 244 - ClientWidth = 384 - Constraints.MinHeight = 190 - Constraints.MinWidth = 384 + ClientHeight = 230 + ClientWidth = 361 + Constraints.MinWidth = 360 OnCloseQuery = FormCloseQuery OnCreate = FormCreate + OnShow = FormShow Position = poScreenCenter SessionProperties = 'chkAlternateTokens.Checked;rdoDone.Checked;rdoNote.Checked;rdoToDo.Checked;OwnerEdit.Text' ShowHint = True - LCLVersion = '2.1.0.0' + LCLVersion = '2.3.0.0' object TodoLabel: TLabel + AnchorSideLeft.Control = Owner + AnchorSideTop.Control = Owner Left = 8 Height = 15 - Top = 8 - Width = 25 + Top = 4 + Width = 24 + BorderSpacing.Left = 8 + BorderSpacing.Top = 4 + BorderSpacing.Bottom = 2 Caption = 'Text:' FocusControl = TodoMemo ParentColor = False end object PriorityLabel: TLabel - AnchorSideLeft.Control = TodoLabel + AnchorSideLeft.Control = PriorityEdit AnchorSideTop.Side = asrBottom AnchorSideBottom.Control = PriorityEdit Left = 8 Height = 15 - Top = 90 + Top = 74 Width = 38 Anchors = [akLeft, akBottom] + BorderSpacing.Top = 4 BorderSpacing.Bottom = 2 Caption = 'Priority' ParentColor = False end object OwnerLabel: TLabel - AnchorSideTop.Control = PriorityLabel - Left = 77 + AnchorSideLeft.Control = OwnerEdit + AnchorSideBottom.Control = OwnerEdit + Left = 74 Height = 15 - Top = 90 + Top = 74 Width = 35 + Anchors = [akLeft, akBottom] + BorderSpacing.Top = 4 + BorderSpacing.Bottom = 2 Caption = 'Owner' ParentColor = False end object CategoryLabel: TLabel - AnchorSideTop.Control = PriorityLabel - Left = 248 + AnchorSideLeft.Control = CategoryEdit + AnchorSideBottom.Control = CategoryEdit + Left = 217 Height = 15 - Top = 90 + Top = 74 Width = 48 + Anchors = [akLeft, akBottom] + BorderSpacing.Top = 4 + BorderSpacing.Bottom = 2 Caption = 'Category' ParentColor = False end object TodoMemo: TMemo - AnchorSideLeft.Control = TodoLabel + AnchorSideLeft.Control = PriorityEdit AnchorSideTop.Control = TodoLabel AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = Owner + AnchorSideRight.Control = CategoryEdit AnchorSideRight.Side = asrBottom AnchorSideBottom.Control = PriorityLabel Left = 8 - Height = 59 - Top = 25 - Width = 370 + Height = 49 + Top = 21 + Width = 345 Anchors = [akTop, akLeft, akRight, akBottom] - BorderSpacing.Top = 2 - BorderSpacing.Right = 6 - BorderSpacing.Bottom = 6 ScrollBars = ssAutoBoth TabOrder = 0 end object OwnerEdit: TEdit - AnchorSideLeft.Control = OwnerLabel - AnchorSideTop.Control = OwnerLabel + AnchorSideLeft.Control = PriorityEdit + AnchorSideLeft.Side = asrBottom AnchorSideTop.Side = asrBottom - Left = 77 + AnchorSideRight.Control = Bevel2 + AnchorSideBottom.Control = grpboxToDoType + Left = 74 Height = 23 - Top = 107 - Width = 162 - BorderSpacing.Top = 2 + Top = 91 + Width = 135 + Anchors = [akLeft, akRight, akBottom] + BorderSpacing.Left = 8 + BorderSpacing.Bottom = 8 TabOrder = 2 end object CategoryEdit: TEdit - AnchorSideLeft.Control = CategoryLabel - AnchorSideTop.Control = CategoryLabel + AnchorSideLeft.Control = Bevel2 + AnchorSideLeft.Side = asrBottom AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = Owner AnchorSideRight.Side = asrBottom - Left = 248 + AnchorSideBottom.Control = grpboxToDoType + Left = 217 Height = 23 - Top = 107 - Width = 130 - Anchors = [akTop, akLeft, akRight] - BorderSpacing.Top = 2 - BorderSpacing.Right = 6 + Top = 91 + Width = 136 + Anchors = [akLeft, akRight, akBottom] + BorderSpacing.Right = 8 + BorderSpacing.Bottom = 8 TabOrder = 3 end object BtnPanel: TButtonPanel AnchorSideTop.Side = asrBottom Left = 6 Height = 26 - Top = 212 - Width = 372 + Top = 198 + Width = 349 OKButton.Name = 'OKButton' OKButton.DefaultCaption = True HelpButton.Name = 'HelpButton' @@ -117,40 +134,36 @@ object TodoDialog: TTodoDialog ShowBevel = False end object PriorityEdit: TSpinEdit - AnchorSideLeft.Control = PriorityLabel + AnchorSideLeft.Control = grpboxToDoType AnchorSideTop.Side = asrBottom AnchorSideBottom.Control = grpboxToDoType Left = 8 Height = 23 - Top = 107 + Top = 91 Width = 58 Anchors = [akLeft, akBottom] - BorderSpacing.Top = 2 - BorderSpacing.Bottom = 6 + BorderSpacing.Bottom = 8 TabOrder = 1 end object grpboxToDoType: TGroupBox - AnchorSideLeft.Control = PriorityLabel AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = CategoryEdit - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = chkAlternateTokens Left = 8 Height = 45 - Top = 136 - Width = 370 - Anchors = [akLeft, akRight, akBottom] + Top = 122 + Width = 345 + Align = alBottom AutoSize = True - BorderSpacing.Bottom = 6 + BorderSpacing.Left = 8 + BorderSpacing.Right = 8 Caption = 'ToDo type' ClientHeight = 25 - ClientWidth = 366 + ClientWidth = 341 TabOrder = 4 object rdoToDo: TRadioButton Left = 6 Height = 19 Top = 0 - Width = 49 + Width = 46 BorderSpacing.Left = 6 BorderSpacing.Bottom = 6 Caption = 'ToDo' @@ -161,10 +174,12 @@ object TodoDialog: TTodoDialog end object rdoDone: TRadioButton Tag = 1 - Left = 160 + AnchorSideLeft.Control = grpboxToDoType + AnchorSideLeft.Side = asrCenter + Left = 149 Height = 19 Top = 0 - Width = 48 + Width = 46 Anchors = [akTop] Caption = 'Done' OnChange = rdoToDoTypeChange @@ -172,34 +187,60 @@ object TodoDialog: TTodoDialog end object rdoNote: TRadioButton Tag = 2 - Left = 311 + AnchorSideRight.Control = grpboxToDoType + AnchorSideRight.Side = asrBottom + Left = 291 Height = 19 Top = 0 - Width = 46 + Width = 44 Anchors = [akTop, akRight] + BorderSpacing.Right = 6 Caption = 'Note' OnChange = rdoToDoTypeChange TabOrder = 2 end end object chkAlternateTokens: TCheckBox - AnchorSideLeft.Control = grpboxToDoType AnchorSideTop.Side = asrBottom - AnchorSideBottom.Control = BtnPanel Left = 8 Height = 19 - Top = 187 - Width = 128 + Top = 173 + Width = 345 + Align = alBottom Anchors = [akLeft, akBottom] + BorderSpacing.Left = 8 + BorderSpacing.Top = 6 + BorderSpacing.Right = 8 BorderSpacing.Bottom = 6 Caption = 'UseAlternate Tokens' TabOrder = 5 end + object Bevel1: TBevel + AnchorSideLeft.Control = OwnerEdit + AnchorSideRight.Control = CategoryEdit + AnchorSideRight.Side = asrBottom + Left = 74 + Height = 21 + Top = 107 + Width = 279 + Anchors = [akLeft, akRight, akBottom] + Shape = bsSpacer + end + object Bevel2: TBevel + AnchorSideLeft.Control = Bevel1 + AnchorSideLeft.Side = asrCenter + Left = 209 + Height = 16 + Top = 72 + Width = 8 + Anchors = [akLeft, akBottom] + Shape = bsSpacer + end object XMLPropStorage: TXMLPropStorage StoredValues = <> FileName = 'todolistdialogoptions.xml' Active = False - left = 224 - top = 8 + Left = 168 + Top = 24 end end diff --git a/components/todolist/tododlg.pas b/components/todolist/tododlg.pas index b16590d341..6b5f0f7e3b 100644 --- a/components/todolist/tododlg.pas +++ b/components/todolist/tododlg.pas @@ -50,6 +50,8 @@ type { TTodoDialog } TTodoDialog = class(TForm) + Bevel1: TBevel; + Bevel2: TBevel; BtnPanel: TButtonPanel; chkAlternateTokens: TCheckBox; grpboxToDoType: TGroupBox; @@ -67,6 +69,7 @@ type XMLPropStorage: TXMLPropStorage; procedure FormCloseQuery(Sender: TObject; var {%H-}CanClose: Boolean); procedure FormCreate(Sender: TObject); + procedure FormShow(Sender: TObject); procedure rdoToDoTypeChange(Sender: TObject); end; @@ -197,6 +200,18 @@ begin XMLPropStorage.Active := True; end; +procedure TTodoDialog.FormShow(Sender: TObject); +begin + TodoMemo.Constraints.MinHeight := OwnerEdit.Height; + Constraints.MinHeight := ToDoMemo.Top + ToDoMemo.Constraints.MinHeight + + ClientHeight - PriorityLabel.Top + PriorityLabel.BorderSpacing.Top; + // Constraints.MinWidth is set in Object Inspector for LCL scaling + + // Enforce constraints + if Width < Constraints.MinWidth then Width := 0; + if Height < Constraints.MinHeight then Height := 0; +end; + procedure TTodoDialog.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin XMLPropStorage.Save;