ToDoList: Use TSpinEdit for item Priority. Improve anchoring.

git-svn-id: trunk@45735 -
This commit is contained in:
juha 2014-06-30 11:01:35 +00:00
parent 9a0aef19e2
commit 4f1d01fd5b
2 changed files with 58 additions and 58 deletions

View File

@ -1,31 +1,31 @@
object TodoDialog: TTodoDialog object TodoDialog: TTodoDialog
Left = 342 Left = 342
Height = 267 Height = 266
Top = 202 Top = 202
Width = 475 Width = 482
ActiveControl = TodoMemo ActiveControl = TodoMemo
Caption = 'Insert Todo' Caption = 'Insert Todo'
ClientHeight = 267 ClientHeight = 266
ClientWidth = 475 ClientWidth = 482
OnCreate = FormCreate OnCreate = FormCreate
Position = poScreenCenter Position = poScreenCenter
LCLVersion = '0.9.31' LCLVersion = '1.3'
object TodoLabel: TLabel object TodoLabel: TLabel
Left = 8 Left = 8
Height = 18 Height = 15
Top = 8 Top = 8
Width = 30 Width = 28
Caption = 'Text:' Caption = 'Text:'
FocusControl = TodoMemo FocusControl = TodoMemo
ParentColor = False ParentColor = False
end end
object PriorityLabel: TLabel object PriorityLabel: TLabel
AnchorSideLeft.Control = TodoLabel
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = PriorityEdit Left = 8
Left = 10 Height = 15
Height = 18 Top = 181
Top = 179 Width = 44
Width = 45
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2 BorderSpacing.Bottom = 2
Caption = 'Priority' Caption = 'Priority'
@ -33,32 +33,33 @@ object TodoDialog: TTodoDialog
end end
object OwnerLabel: TLabel object OwnerLabel: TLabel
AnchorSideTop.Control = PriorityLabel AnchorSideTop.Control = PriorityLabel
Left = 75 Left = 77
Height = 18 Height = 15
Top = 179 Top = 181
Width = 41 Width = 39
Caption = 'Owner' Caption = 'Owner'
ParentColor = False ParentColor = False
end end
object CategoryLabel: TLabel object CategoryLabel: TLabel
AnchorSideTop.Control = PriorityLabel AnchorSideTop.Control = PriorityLabel
Left = 248 Left = 248
Height = 18 Height = 15
Top = 179 Top = 181
Width = 59 Width = 57
Caption = 'Category' Caption = 'Category'
ParentColor = False ParentColor = False
end end
object TodoMemo: TMemo object TodoMemo: TMemo
AnchorSideLeft.Control = TodoLabel
AnchorSideTop.Control = TodoLabel AnchorSideTop.Control = TodoLabel
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = PriorityLabel AnchorSideBottom.Control = PriorityLabel
Left = 6 Left = 8
Height = 145 Height = 150
Top = 28 Top = 25
Width = 463 Width = 468
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2 BorderSpacing.Top = 2
BorderSpacing.Right = 6 BorderSpacing.Right = 6
@ -66,42 +67,36 @@ object TodoDialog: TTodoDialog
ScrollBars = ssAutoBoth ScrollBars = ssAutoBoth
TabOrder = 0 TabOrder = 0
end end
object PriorityEdit: TEdit
AnchorSideTop.Side = asrBottom
Left = 6
Height = 27
Top = 199
Width = 38
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 6
OnKeyPress = PriorityEditKeyPress
TabOrder = 1
end
object OwnerEdit: TEdit object OwnerEdit: TEdit
AnchorSideTop.Control = PriorityEdit AnchorSideLeft.Control = OwnerLabel
Left = 76 AnchorSideTop.Control = OwnerLabel
Height = 27 AnchorSideTop.Side = asrBottom
Top = 199 Left = 77
Height = 25
Top = 198
Width = 162 Width = 162
BorderSpacing.Top = 2
TabOrder = 2 TabOrder = 2
end end
object CategoryEdit: TEdit object CategoryEdit: TEdit
AnchorSideTop.Control = PriorityEdit AnchorSideLeft.Control = CategoryLabel
AnchorSideRight.Control = Owner AnchorSideTop.Control = CategoryLabel
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 248 Left = 248
Height = 27 Height = 25
Top = 199 Top = 198
Width = 221 Width = 228
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 2
BorderSpacing.Right = 6 BorderSpacing.Right = 6
TabOrder = 3 TabOrder = 3
end end
object BtnPanel: TButtonPanel object BtnPanel: TButtonPanel
Left = 6 Left = 6
Height = 36 Height = 33
Top = 225 Top = 227
Width = 463 Width = 470
OKButton.Name = 'OKButton' OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True OKButton.DefaultCaption = True
HelpButton.Name = 'HelpButton' HelpButton.Name = 'HelpButton'
@ -114,4 +109,16 @@ object TodoDialog: TTodoDialog
ShowButtons = [pbOK, pbCancel] ShowButtons = [pbOK, pbCancel]
ShowBevel = False ShowBevel = False
end end
object PriorityEdit: TSpinEdit
AnchorSideLeft.Control = PriorityLabel
AnchorSideTop.Control = PriorityLabel
AnchorSideTop.Side = asrBottom
Left = 8
Height = 25
Top = 198
Width = 58
BorderSpacing.Top = 2
BorderSpacing.Bottom = 6
TabOrder = 1
end
end end

View File

@ -30,8 +30,9 @@ interface
uses uses
Classes, SysUtils, LCLProc, Forms, Controls, Graphics, Dialogs, StdCtrls, Classes, SysUtils, LCLProc, Forms, Controls, Graphics, Dialogs, StdCtrls,
ExtCtrls, TodoList, ToDoListStrConsts, Buttons, ButtonPanel, Menus, MenuIntf, ExtCtrls, Buttons, ButtonPanel, Menus, Spin,
PackageIntf, SrcEditorIntf, IDECommands, LCLType, IDEWindowIntf, LazIDEIntf; TodoList, ToDoListStrConsts, IDECommands, LCLType,
MenuIntf, PackageIntf, SrcEditorIntf, IDEWindowIntf, LazIDEIntf;
type type
@ -42,13 +43,12 @@ type
OwnerEdit: TEdit; OwnerEdit: TEdit;
CategoryEdit: TEdit; CategoryEdit: TEdit;
CategoryLabel: TLabel; CategoryLabel: TLabel;
PriorityEdit: TEdit; PriorityEdit: TSpinEdit;
PriorityLabel: TLabel; PriorityLabel: TLabel;
OwnerLabel: TLabel; OwnerLabel: TLabel;
TodoLabel: TLabel; TodoLabel: TLabel;
TodoMemo: TMemo; TodoMemo: TMemo;
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure PriorityEditKeyPress(Sender: TObject; var Key: char);
private private
public public
@ -153,12 +153,6 @@ end;
{ TTodoDialog } { TTodoDialog }
procedure TTodoDialog.PriorityEditKeyPress(Sender: TObject; var Key: char);
begin
if not (Key in ['0'..'9']) then
Key := #0;
end;
procedure TTodoDialog.FormCreate(Sender: TObject); procedure TTodoDialog.FormCreate(Sender: TObject);
begin begin
ActiveControl:=TodoMemo; ActiveControl:=TodoMemo;
@ -185,8 +179,7 @@ begin
Result.Done := False; Result.Done := False;
Result.Owner := aTodoDialog.OwnerEdit.Text; Result.Owner := aTodoDialog.OwnerEdit.Text;
Result.Text := aTodoDialog.TodoMemo.Text; Result.Text := aTodoDialog.TodoMemo.Text;
if TryStrToInt(aTodoDialog.PriorityEdit.Text, aPriority) then Result.Priority := aTodoDialog.PriorityEdit.Value;
Result.Priority := aPriority;
end; end;
aTodoDialog.Free; aTodoDialog.Free;
end; end;