You've already forked lazarus-ccr
tvplanit: Improved vertical alignment of controls in contact editor.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4948 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -29,111 +29,101 @@ object ContactEditForm: TContactEditForm
|
|||||||
ClientHeight = 351
|
ClientHeight = 351
|
||||||
ClientWidth = 425
|
ClientWidth = 425
|
||||||
object LastNameLbl: TLabel
|
object LastNameLbl: TLabel
|
||||||
Left = 8
|
Left = 9
|
||||||
Height = 16
|
Height = 15
|
||||||
Top = 6
|
Top = 6
|
||||||
Width = 127
|
Width = 54
|
||||||
Alignment = taRightJustify
|
Alignment = taRightJustify
|
||||||
AutoSize = False
|
|
||||||
Caption = 'Last name'
|
Caption = 'Last name'
|
||||||
FocusControl = LastNameEdit
|
FocusControl = LastNameEdit
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object AddrLbl: TLabel
|
object AddrLbl: TLabel
|
||||||
Left = 8
|
Left = 8
|
||||||
Height = 16
|
Height = 15
|
||||||
Top = 81
|
Top = 81
|
||||||
Width = 127
|
Width = 42
|
||||||
Alignment = taRightJustify
|
Alignment = taRightJustify
|
||||||
AutoSize = False
|
|
||||||
Caption = 'Address'
|
Caption = 'Address'
|
||||||
FocusControl = AddressEdit
|
FocusControl = AddressEdit
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object CityLbl: TLabel
|
object CityLbl: TLabel
|
||||||
Left = 8
|
Left = 8
|
||||||
Height = 16
|
Height = 15
|
||||||
Top = 105
|
Top = 104
|
||||||
Width = 127
|
Width = 21
|
||||||
Alignment = taRightJustify
|
Alignment = taRightJustify
|
||||||
AutoSize = False
|
|
||||||
Caption = 'City'
|
Caption = 'City'
|
||||||
FocusControl = CityEdit
|
FocusControl = CityEdit
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object StateLbl: TLabel
|
object StateLbl: TLabel
|
||||||
Left = 8
|
Left = 8
|
||||||
Height = 16
|
Height = 15
|
||||||
Top = 129
|
Top = 129
|
||||||
Width = 127
|
Width = 26
|
||||||
Alignment = taRightJustify
|
Alignment = taRightJustify
|
||||||
AutoSize = False
|
|
||||||
Caption = 'State'
|
Caption = 'State'
|
||||||
FocusControl = cboxState
|
FocusControl = cboxState
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object ZipLbl: TLabel
|
object ZipLbl: TLabel
|
||||||
Left = 8
|
Left = 8
|
||||||
Height = 16
|
Height = 15
|
||||||
Top = 153
|
Top = 153
|
||||||
Width = 127
|
Width = 48
|
||||||
Alignment = taRightJustify
|
Alignment = taRightJustify
|
||||||
AutoSize = False
|
|
||||||
Caption = 'Zip Code'
|
Caption = 'Zip Code'
|
||||||
FocusControl = ZipCodeEdit
|
FocusControl = ZipCodeEdit
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object CountryLbl: TLabel
|
object CountryLbl: TLabel
|
||||||
Left = 8
|
Left = 8
|
||||||
Height = 16
|
Height = 15
|
||||||
Top = 177
|
Top = 177
|
||||||
Width = 127
|
Width = 43
|
||||||
Alignment = taRightJustify
|
Alignment = taRightJustify
|
||||||
AutoSize = False
|
|
||||||
Caption = 'Country'
|
Caption = 'Country'
|
||||||
FocusControl = cboxCountry
|
FocusControl = cboxCountry
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object PositionLbl: TLabel
|
object PositionLbl: TLabel
|
||||||
Left = 8
|
Left = 8
|
||||||
Height = 16
|
Height = 15
|
||||||
Top = 226
|
Top = 226
|
||||||
Width = 127
|
Width = 43
|
||||||
Alignment = taRightJustify
|
Alignment = taRightJustify
|
||||||
AutoSize = False
|
|
||||||
Caption = 'Position'
|
Caption = 'Position'
|
||||||
FocusControl = PositionEdit
|
FocusControl = PositionEdit
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object TitleLbl: TLabel
|
object TitleLbl: TLabel
|
||||||
Left = 8
|
Left = 8
|
||||||
Height = 16
|
Height = 15
|
||||||
Top = 58
|
Top = 58
|
||||||
Width = 127
|
Width = 23
|
||||||
Alignment = taRightJustify
|
Alignment = taRightJustify
|
||||||
AutoSize = False
|
|
||||||
Caption = 'Title'
|
Caption = 'Title'
|
||||||
FocusControl = TitleEdit
|
FocusControl = TitleEdit
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object CompanyLbl: TLabel
|
object CompanyLbl: TLabel
|
||||||
Left = 8
|
Left = 8
|
||||||
Height = 16
|
Height = 15
|
||||||
Top = 202
|
Top = 202
|
||||||
Width = 127
|
Width = 52
|
||||||
Alignment = taRightJustify
|
Alignment = taRightJustify
|
||||||
AutoSize = False
|
|
||||||
Caption = 'Company'
|
Caption = 'Company'
|
||||||
FocusControl = CompanyEdit
|
FocusControl = CompanyEdit
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object CategoryLbl: TLabel
|
object CategoryLbl: TLabel
|
||||||
Left = 8
|
Left = 8
|
||||||
Height = 16
|
Height = 15
|
||||||
Top = 253
|
Top = 253
|
||||||
Width = 127
|
Width = 48
|
||||||
Alignment = taRightJustify
|
Alignment = taRightJustify
|
||||||
AutoSize = False
|
|
||||||
Caption = 'Category'
|
Caption = 'Category'
|
||||||
FocusControl = cboxCategory
|
FocusControl = cboxCategory
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
@ -257,11 +247,10 @@ object ContactEditForm: TContactEditForm
|
|||||||
end
|
end
|
||||||
object FirstNameLbl: TLabel
|
object FirstNameLbl: TLabel
|
||||||
Left = 8
|
Left = 8
|
||||||
Height = 16
|
Height = 15
|
||||||
Top = 31
|
Top = 31
|
||||||
Width = 127
|
Width = 55
|
||||||
Alignment = taRightJustify
|
Alignment = taRightJustify
|
||||||
AutoSize = False
|
|
||||||
Caption = 'First name'
|
Caption = 'First name'
|
||||||
FocusControl = FirstNameEdit
|
FocusControl = FirstNameEdit
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
@ -283,11 +272,10 @@ object ContactEditForm: TContactEditForm
|
|||||||
end
|
end
|
||||||
object BirthdateLbl: TLabel
|
object BirthdateLbl: TLabel
|
||||||
Left = 8
|
Left = 8
|
||||||
Height = 16
|
Height = 15
|
||||||
Top = 284
|
Top = 284
|
||||||
Width = 127
|
Width = 51
|
||||||
Alignment = taRightJustify
|
Alignment = taRightJustify
|
||||||
AutoSize = False
|
|
||||||
Caption = 'Birth date'
|
Caption = 'Birth date'
|
||||||
FocusControl = BirthdateEdit
|
FocusControl = BirthdateEdit
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
|
@ -368,13 +368,15 @@ end;
|
|||||||
procedure TContactEditForm.ResizeControls;
|
procedure TContactEditForm.ResizeControls;
|
||||||
const
|
const
|
||||||
ComboArrowWidth = 32;
|
ComboArrowWidth = 32;
|
||||||
FieldVertSep = 25;
|
// FieldVertSep = 25;
|
||||||
// FormRightBorder = 20;
|
// FormRightBorder = 20;
|
||||||
// MinFormWidth = 265;
|
// MinFormWidth = 265;
|
||||||
// FormHeightOffset = 103;
|
// FormHeightOffset = 103;
|
||||||
// MinFormHeight = 250;
|
// MinFormHeight = 250;
|
||||||
TopField = 8;
|
TopField = 8;
|
||||||
DIST = 4; // distance between label and edit/combo
|
DIST = 4; // distance between label and edit/combo
|
||||||
|
HBORDER = 8; // distance between container border and label
|
||||||
|
VDIST = 2; // vertical distance between edits
|
||||||
|
|
||||||
type
|
type
|
||||||
TLabelArray = array of TLabel;
|
TLabelArray = array of TLabel;
|
||||||
@ -385,14 +387,14 @@ var
|
|||||||
Labels: TLabelArray;
|
Labels: TLabelArray;
|
||||||
Comboboxes: TComboboxArray;
|
Comboboxes: TComboboxArray;
|
||||||
Edits: TEditArray;
|
Edits: TEditArray;
|
||||||
LargestLabel: Integer;
|
LargestLabelWidth: Integer;
|
||||||
WidestField: Integer;
|
WidestField: Integer;
|
||||||
i, j: Integer;
|
i, j: Integer;
|
||||||
OldFont: TFont;
|
OldFont: TFont;
|
||||||
FieldTop: Integer;
|
FieldTop: Integer;
|
||||||
delta: Integer;
|
delta: Integer;
|
||||||
horMargin: Integer; // Margin at left and right from tabsheet to label/edit
|
|
||||||
corr: Integer; // difference between form's client width and tabsheet width
|
corr: Integer; // difference between form's client width and tabsheet width
|
||||||
|
editHeight: Integer; // Height of an edit control
|
||||||
|
|
||||||
begin
|
begin
|
||||||
{ Note: The resizing algorithm is dependent upon the labels having their
|
{ Note: The resizing algorithm is dependent upon the labels having their
|
||||||
@ -412,17 +414,17 @@ begin
|
|||||||
Labels[10] := CategoryLbl;
|
Labels[10] := CategoryLbl;
|
||||||
Labels[11] := BirthdateLbl;
|
Labels[11] := BirthdateLbl;
|
||||||
|
|
||||||
LargestLabel := 0;
|
LargestLabelWidth := 0;
|
||||||
for i := Low(Labels) to High(Labels) do
|
for i := Low(Labels) to High(Labels) do
|
||||||
LargestLabel := Max(LargestLabel, GetLabelWidth(Labels[i]));
|
LargestLabelWidth := Max(LargestLabelWidth, GetLabelWidth(Labels[i]));
|
||||||
|
|
||||||
{ Determine width of label based upon whether large or small fonts are
|
{ Determine width of label based upon whether large or small fonts are
|
||||||
in effect. }
|
in effect. }
|
||||||
for i := Low(Labels) to High(Labels) do begin
|
for i := Low(Labels) to High(Labels) do begin
|
||||||
Labels[i].Width := LargestLabel;
|
Labels[i].FocusControl.Left := HBORDER + LargestLabelWidth + DIST;
|
||||||
Labels[i].FocusControl.Left := LastNameLbl.Left + LargestLabel + DIST;
|
Labels[i].Left := Labels[i].FocusControl.Left - DIST - GetLabelWidth(Labels[i]);
|
||||||
|
Labels[i].Top := Labels[i].FocusControl.Top + (Labels[i].FocusControl.Height - Labels[i].Height) div 2;
|
||||||
end;
|
end;
|
||||||
horMargin := Labels[0].Left;
|
|
||||||
|
|
||||||
widestField := 250;
|
widestField := 250;
|
||||||
|
|
||||||
@ -452,7 +454,7 @@ begin
|
|||||||
|
|
||||||
{ Set form width according to widest field }
|
{ Set form width according to widest field }
|
||||||
corr := ClientWidth - tabMain.ClientWidth;
|
corr := ClientWidth - tabMain.ClientWidth;
|
||||||
ClientWidth := LastNameEdit.Left + widestfield + horMargin + corr;
|
ClientWidth := LastNameEdit.Left + widestfield + HBORDER + corr;
|
||||||
|
|
||||||
{ Set edit and combo widths }
|
{ Set edit and combo widths }
|
||||||
for i:= Low(Labels) to High(Labels) do
|
for i:= Low(Labels) to High(Labels) do
|
||||||
@ -464,13 +466,15 @@ begin
|
|||||||
cboxState.Width := widestField;
|
cboxState.Width := widestField;
|
||||||
|
|
||||||
{ Vertically arrange the fields. }
|
{ Vertically arrange the fields. }
|
||||||
|
editHeight := LastNameEdit.Height;
|
||||||
|
|
||||||
delta := (Labels[0].FocusControl.Height - labels[0].Height) div 2;
|
delta := (Labels[0].FocusControl.Height - labels[0].Height) div 2;
|
||||||
FieldTop := TopField;
|
FieldTop := TopField;
|
||||||
for i := Low(Labels) to High(Labels) do
|
for i := Low(Labels) to High(Labels) do
|
||||||
if Labels[i].Visible then begin
|
if Labels[i].Visible then begin
|
||||||
Labels[i].FocusControl.Top := FieldTop;
|
Labels[i].FocusControl.Top := FieldTop;
|
||||||
Labels[i].Top := FieldTop + delta;
|
Labels[i].Top := FieldTop + delta;
|
||||||
inc(FieldTop, FieldVertSep);
|
inc(FieldTop, editHeight + VDIST);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Set form height such that first tab is filled completely by controls }
|
{ Set form height such that first tab is filled completely by controls }
|
||||||
@ -492,13 +496,13 @@ begin
|
|||||||
Edits[3] := Phone4Edit;
|
Edits[3] := Phone4Edit;
|
||||||
Edits[4] := Phone5Edit;
|
Edits[4] := Phone5Edit;
|
||||||
|
|
||||||
largestLabel := GetLabelWidth(EMailLbl);
|
largestLabelWidth := GetLabelWidth(EMailLbl);
|
||||||
OldFont := TFont.Create;
|
OldFont := TFont.Create;
|
||||||
try
|
try
|
||||||
OldFont.Assign(Canvas.Font);
|
OldFont.Assign(Canvas.Font);
|
||||||
Canvas.Font.Assign(cboxPhoneLbl1.Font);
|
Canvas.Font.Assign(cboxPhoneLbl1.Font);
|
||||||
for i:=0 to cboxPhoneLbl1.Items.Count-1 do
|
for i:=0 to cboxPhoneLbl1.Items.Count-1 do
|
||||||
largestLabel := Max(cboxPhoneLbl1.Canvas.TextWidth(cboxPhoneLbl1.Items[i]) + ComboArrowWidth, largestlabel);
|
largestLabelWidth := Max(cboxPhoneLbl1.Canvas.TextWidth(cboxPhoneLbl1.Items[i]) + ComboArrowWidth, largestlabelWidth);
|
||||||
finally
|
finally
|
||||||
Canvas.Font.Assign(OldFont);
|
Canvas.Font.Assign(OldFont);
|
||||||
OldFont.Free;
|
OldFont.Free;
|
||||||
@ -506,25 +510,24 @@ begin
|
|||||||
|
|
||||||
FieldTop := TopField;
|
FieldTop := TopField;
|
||||||
for i:=Low(Comboboxes) to High(Comboboxes) do begin
|
for i:=Low(Comboboxes) to High(Comboboxes) do begin
|
||||||
Comboboxes[i].Left := horMargin;
|
Comboboxes[i].Left := HBORDER;
|
||||||
Comboboxes[i].Width := largestLabel;
|
Comboboxes[i].Width := largestLabelWidth;
|
||||||
Comboboxes[i].Top := FieldTop;
|
Comboboxes[i].Top := FieldTop;
|
||||||
inc(FieldTop, FieldVertSep);
|
inc(FieldTop, editHeight + VDIST);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
for i:= Low(Edits) to High(Edits) do begin
|
for i:= Low(Edits) to High(Edits) do begin
|
||||||
Edits[i].Left := cboxPhoneLbl1.Left + cboxPhoneLbl1.Width + DIST;
|
Edits[i].Left := cboxPhoneLbl1.Left + cboxPhoneLbl1.Width + DIST;
|
||||||
Edits[i].Width := ClientWidth - Edits[i].Left - horMargin - corr;
|
Edits[i].Width := ClientWidth - Edits[i].Left - HBORDER - corr;
|
||||||
Edits[i].Top := Comboboxes[i].Top;
|
Edits[i].Top := Comboboxes[i].Top;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
EMailEdit.Left := Phone1Edit.Left;
|
EMailEdit.Left := Phone1Edit.Left;
|
||||||
EMailEdit.Width := Phone1Edit.Width;
|
EMailEdit.Width := Phone1Edit.Width;
|
||||||
EMailEdit.Top := Phone5Edit.Top + FieldVertSep;
|
EMailEdit.Top := Phone5Edit.Top + editHeight + VDIST;
|
||||||
EMailLbl.Left := EMailEdit.Left - GetLabelWidth(EMailLbl) - DIST;
|
EMailLbl.Left := EMailEdit.Left - GetLabelWidth(EMailLbl) - DIST;
|
||||||
EMailLbl.Top := EMailEdit.Top + delta;
|
EMailLbl.Top := EMailEdit.Top + delta;
|
||||||
|
|
||||||
|
|
||||||
{ Page "User-defined" }
|
{ Page "User-defined" }
|
||||||
SetLength(Labels, 4);
|
SetLength(Labels, 4);
|
||||||
Labels[0] := CustomLbl1;
|
Labels[0] := CustomLbl1;
|
||||||
@ -532,19 +535,19 @@ begin
|
|||||||
Labels[2] := CustomLbl3;
|
Labels[2] := CustomLbl3;
|
||||||
Labels[3] := CustomLbl4;
|
Labels[3] := CustomLbl4;
|
||||||
|
|
||||||
largestLabel := 0;
|
largestLabelWidth := 0;
|
||||||
for i := Low(Labels) to High(Labels) do
|
for i := Low(Labels) to High(Labels) do
|
||||||
largestLabel := Max(largestLabel, GetLabelWidth(Labels[i]));
|
largestLabelWidth := Max(largestLabelWidth, GetLabelWidth(Labels[i]));
|
||||||
|
|
||||||
FieldTop := TopField;
|
FieldTop := TopField;
|
||||||
for i := Low(Labels) to High(Labels) do begin
|
for i := Low(Labels) to High(Labels) do begin
|
||||||
Labels[i].FocusControl.Left := horMargin + LargestLabel + DIST;
|
Labels[i].FocusControl.Left := HBORDER + LargestLabelWidth + DIST;
|
||||||
Labels[i].FocusControl.Top := FieldTop;
|
Labels[i].FocusControl.Top := FieldTop;
|
||||||
Labels[i].FocusControl.Width := ClientWidth - Labels[i].FocusControl.Left - horMargin - corr;
|
Labels[i].FocusControl.Width := ClientWidth - Labels[i].FocusControl.Left - HBORDER - corr;
|
||||||
Labels[i].Width := LargestLabel;
|
Labels[i].Width := LargestLabelWidth;
|
||||||
Labels[i].Left := Labels[i].FocusControl.Left - GetLabelWidth(Labels[i]) - DIST;
|
Labels[i].Left := Labels[i].FocusControl.Left - GetLabelWidth(Labels[i]) - DIST;
|
||||||
Labels[i].Top := FieldTop + delta;
|
Labels[i].Top := FieldTop + delta;
|
||||||
inc(FieldTop, FieldVertSep);
|
inc(FieldTop, editHeight + VDIST);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user