You've already forked lazarus-ccr
tvplanit: Improved button positioning
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4954 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -105,14 +105,14 @@ type
|
|||||||
EMailLbl: TLabel;
|
EMailLbl: TLabel;
|
||||||
EMailEdit: TEdit;
|
EMailEdit: TEdit;
|
||||||
CategoryLbl: TLabel;
|
CategoryLbl: TLabel;
|
||||||
procedure OKBtnClick(Sender: TObject);
|
procedure cboxCountryChange(Sender: TObject);
|
||||||
procedure CancelBtnClick(Sender: TObject);
|
procedure CancelBtnClick(Sender: TObject);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure ItemChanged(Sender: TObject);
|
|
||||||
procedure cboxCountryChange(Sender: TObject);
|
|
||||||
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||||
procedure tsContactsChange(Sender: TObject);
|
|
||||||
procedure FormShow(Sender: TObject);
|
procedure FormShow(Sender: TObject);
|
||||||
|
procedure OKBtnClick(Sender: TObject);
|
||||||
|
procedure ItemChanged(Sender: TObject);
|
||||||
|
procedure tsContactsChange(Sender: TObject);
|
||||||
private
|
private
|
||||||
procedure SetCaptions;
|
procedure SetCaptions;
|
||||||
procedure DisplayCurrentCountry;
|
procedure DisplayCurrentCountry;
|
||||||
@@ -426,7 +426,7 @@ begin
|
|||||||
{ 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].FocusControl.Left := HBORDER + LargestLabelWidth + DIST;
|
Labels[i].FocusControl.Left := HBorder + LargestLabelWidth + Dist;
|
||||||
Labels[i].Left := Labels[i].FocusControl.Left - DIST - GetLabelWidth(Labels[i]);
|
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;
|
Labels[i].Top := Labels[i].FocusControl.Top + (Labels[i].FocusControl.Height - Labels[i].Height) div 2;
|
||||||
end;
|
end;
|
||||||
@@ -459,7 +459,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 + HBORDER + 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
|
||||||
@@ -477,7 +477,7 @@ begin
|
|||||||
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, editHeight + VDIST);
|
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 }
|
||||||
@@ -513,22 +513,22 @@ 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 := HBORDER;
|
Comboboxes[i].Left := HBorder;
|
||||||
Comboboxes[i].Width := largestLabelWidth;
|
Comboboxes[i].Width := largestLabelWidth;
|
||||||
Comboboxes[i].Top := FieldTop;
|
Comboboxes[i].Top := FieldTop;
|
||||||
inc(FieldTop, editHeight + VDIST);
|
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 - HBORDER - 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 + editHeight + VDIST;
|
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" }
|
||||||
@@ -544,14 +544,20 @@ begin
|
|||||||
|
|
||||||
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 := HBORDER + LargestLabelWidth + 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 - HBORDER - corr;
|
Labels[i].FocusControl.Width := ClientWidth - Labels[i].FocusControl.Left - HBorder - corr;
|
||||||
Labels[i].Width := LargestLabelWidth;
|
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, editHeight + VDIST);
|
inc(FieldTop, editHeight + VDist);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
OKBtn.Width := Max(GetButtonWidth(OKBtn), GetButtonWidth(CancelBtn));
|
||||||
|
CancelBtn.Width := OKBtn.Width;
|
||||||
|
CancelBtn.Left := pnlBottom.ClientWidth - HBorder - CancelBtn.Width;
|
||||||
|
OKBtn.Left := CancelBtn.Left - Dist - OKBtn.Width;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TContactEditForm.DisplayCurrentCountry;
|
procedure TContactEditForm.DisplayCurrentCountry;
|
||||||
|
@@ -132,6 +132,7 @@ function GetEndLine(EndTime: TDateTime; Granularity: TVpGranularity): Integer;
|
|||||||
function LineToStartTime(Line: Integer; Granularity: TVpGranularity): TDateTime;
|
function LineToStartTime(Line: Integer; Granularity: TVpGranularity): TDateTime;
|
||||||
function GetLineDuration(Granularity: TVpGranularity): Double;
|
function GetLineDuration(Granularity: TVpGranularity): Double;
|
||||||
|
|
||||||
|
function GetButtonWidth(AButton: TButton): Integer;
|
||||||
function GetLabelWidth(ALabel: TLabel): Integer;
|
function GetLabelWidth(ALabel: TLabel): Integer;
|
||||||
function GetRealFontHeight(AFont: TFont): Integer;
|
function GetRealFontHeight(AFont: TFont): Integer;
|
||||||
|
|
||||||
@@ -599,6 +600,18 @@ begin
|
|||||||
canvas.Free;
|
canvas.Free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function GetButtonWidth(AButton: TButton): Integer;
|
||||||
|
const
|
||||||
|
MARGIN = 16;
|
||||||
|
var
|
||||||
|
canvas: TControlCanvas;
|
||||||
|
begin
|
||||||
|
canvas := TControlCanvas.Create;
|
||||||
|
canvas.Control := AButton;
|
||||||
|
canvas.Font.Assign(AButton.Font);
|
||||||
|
Result := canvas.TextWidth(AButton.Caption) + 24 * Screen.PixelsPerInch div DesignTimeDPI;
|
||||||
|
end;
|
||||||
|
|
||||||
function GetRealFontHeight(AFont: TFont): Integer;
|
function GetRealFontHeight(AFont: TFont): Integer;
|
||||||
begin
|
begin
|
||||||
if AFont.Size = 0 then
|
if AFont.Size = 0 then
|
||||||
|
@@ -14,7 +14,7 @@ object TaskEditForm: TTaskEditForm
|
|||||||
OnShow = FormShow
|
OnShow = FormShow
|
||||||
Position = poScreenCenter
|
Position = poScreenCenter
|
||||||
LCLVersion = '1.7'
|
LCLVersion = '1.7'
|
||||||
object Panel2: TPanel
|
object ButtonPanel: TPanel
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 37
|
Height = 37
|
||||||
Top = 303
|
Top = 303
|
||||||
|
@@ -51,7 +51,7 @@ type
|
|||||||
{ TTaskEditForm }
|
{ TTaskEditForm }
|
||||||
|
|
||||||
TTaskEditForm = class(TForm)
|
TTaskEditForm = class(TForm)
|
||||||
Panel2: TPanel;
|
ButtonPanel: TPanel;
|
||||||
OKBtn: TButton;
|
OKBtn: TButton;
|
||||||
CancelBtn: TButton;
|
CancelBtn: TButton;
|
||||||
PageControl1: TPageControl;
|
PageControl1: TPageControl;
|
||||||
@@ -106,7 +106,7 @@ type
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
VpMisc;
|
Math, VpMisc;
|
||||||
|
|
||||||
{$IFDEF LCL}
|
{$IFDEF LCL}
|
||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
@@ -159,11 +159,17 @@ procedure TTaskEditForm.PositionControls;
|
|||||||
var
|
var
|
||||||
VBevelDist: Integer; // Distance bevel-to-control
|
VBevelDist: Integer; // Distance bevel-to-control
|
||||||
VDist: Integer; // Vertical distance between controls
|
VDist: Integer; // Vertical distance between controls
|
||||||
|
HDist: Integer; // Horizontal distance between controls:
|
||||||
begin
|
begin
|
||||||
VBevelDist := round(8 * Screen.PixelsPerInch / DesignTimeDPI);
|
VBevelDist := round(8 * Screen.PixelsPerInch / DesignTimeDPI);
|
||||||
VDist := round(8 * Screen.PixelsPerInch / DesignTimeDPI);
|
VDist := round(8 * Screen.PixelsPerInch / DesignTimeDPI);
|
||||||
|
HDist := round(8 * Screen.PixelsPerInch / DesignTimeDPI);
|
||||||
|
|
||||||
DueDateEdit.Left := DueDateLbl.Left + GetLabelWidth(DueDateLbl) + 8;
|
DueDateEdit.Left := DueDateLbl.Left + GetLabelWidth(DueDateLbl) + HDist;
|
||||||
|
OKBtn.Width := Max(GetButtonWidth(OKBtn), GetButtonWidth(CancelBtn));
|
||||||
|
CancelBtn.Width := OKBtn.Width;
|
||||||
|
CancelBtn.Left := ButtonPanel.ClientWidth - ResourcenameLbl.Left - CancelBtn.Width;
|
||||||
|
OKBtn.Left := CancelBtn.Left - HDist - OKBtn.Width;
|
||||||
|
|
||||||
Bevel1.Top := BottomOf(DescriptionEdit) + VBevelDist;
|
Bevel1.Top := BottomOf(DescriptionEdit) + VBevelDist;
|
||||||
|
|
||||||
@@ -178,6 +184,10 @@ begin
|
|||||||
|
|
||||||
DetailsMemo.Top := BottomOf(CreatedOnLbl) + VBevelDist;
|
DetailsMemo.Top := BottomOf(CreatedOnLbl) + VBevelDist;
|
||||||
DetailsMemo.Height := tabTask.ClientHeight - DetailsMemo.Top - DescriptionEdit.Top;
|
DetailsMemo.Height := tabTask.ClientHeight - DetailsMemo.Top - DescriptionEdit.Top;
|
||||||
|
|
||||||
|
OKBtn.Top := (ButtonPanel.Height - OKBtn.Height) div 2;
|
||||||
|
CancelBtn.Top := OKBtn.Top;
|
||||||
|
ResourceNameLbl.Top := (ButtonPanel.Height - ResourceNameLbl.Height) div 2;
|
||||||
end;
|
end;
|
||||||
{=====}
|
{=====}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user