summaryrefslogtreecommitdiff
path: root/src/gui/fpg_edit.pas
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graemeg@gmail.com>2014-02-23 13:42:38 +0000
committerGraeme Geldenhuys <graemeg@gmail.com>2014-02-23 13:42:38 +0000
commit7a05a7ec1b55adfbbb8c736c081583ec012a982e (patch)
tree02ef43e2605c96f6eb0fc35add0d354b3c494d22 /src/gui/fpg_edit.pas
parenteed837a18d07169937413e1e21bc1894111137b9 (diff)
downloadfpGUI-7a05a7ec1b55adfbbb8c736c081583ec012a982e.tar.xz
edit: Remove more hard-coded values for improved themes support.
Diffstat (limited to 'src/gui/fpg_edit.pas')
-rw-r--r--src/gui/fpg_edit.pas43
1 files changed, 28 insertions, 15 deletions
diff --git a/src/gui/fpg_edit.pas b/src/gui/fpg_edit.pas
index 03acb64f..3910df61 100644
--- a/src/gui/fpg_edit.pas
+++ b/src/gui/fpg_edit.pas
@@ -1116,21 +1116,24 @@ begin
end;
procedure TfpgBaseEdit.SetFontDesc(const AValue: string);
+var
+ rect: TRect;
begin
FFont.Free;
FFont := fpgGetFont(AValue);
if AutoSize then
begin
+ rect := fpgStyle.GetControlFrameBorders;
case BorderStyle of
ebsNone:
if Height < FFont.Height + (FHeightMargin * 2) then
- Height:= FFont.Height + (FHeightMargin * 2);
+ Height := FFont.Height + (FHeightMargin * 2);
ebsDefault:
- if Height < FFont.Height + 4 + (FHeightMargin * 2) then
- Height:= FFont.Height + 4 + (FHeightMargin * 2);
+ if Height < FFont.Height + rect.Top + rect.Bottom + (FHeightMargin * 2) then
+ Height := FFont.Height + rect.Top + rect.Bottom + (FHeightMargin * 2);
ebsSingle:
- if Height < FFont.Height + 2 + (FHeightMargin * 2) then
- Height:= FFont.Height + 2 + (FHeightMargin * 2);
+ if Height < FFont.Height + rect.Top + rect.Bottom + (FHeightMargin * 2) then
+ Height := FFont.Height + rect.Top + rect.Bottom + (FHeightMargin * 2);
end;
end;
Adjust;
@@ -1179,18 +1182,24 @@ begin
end;
procedure TfpgBaseEdit.SetHeightMargin(const AValue: integer);
+var
+ rect: TRect;
begin
if (FHeightMargin = AValue) or (AValue <= 0) then
Exit; //=>
FHeightMargin := AValue;
- case BorderStyle of
- ebsNone:
- Height:= FFont.Height + (FHeightMargin * 2);
- ebsDefault:
- Height:= FFont.Height + 4 + (FHeightMargin * 2);
- ebsSingle:
- Height:= FFont.Height + 2 + (FHeightMargin * 2);
+ if AutoSize then
+ begin
+ rect := fpgStyle.GetControlFrameBorders;
+ case BorderStyle of
+ ebsNone:
+ Height := FFont.Height + (FHeightMargin * 2);
+ ebsDefault:
+ Height := FFont.Height + rect.Top + rect.Bottom + (FHeightMargin * 2);
+ ebsSingle:
+ Height := FFont.Height + rect.Top + rect.Bottom + (FHeightMargin * 2);
end;
+ end;
Repaint;
end;
@@ -1426,11 +1435,15 @@ begin
end;
function TfpgBaseEdit.GetClientRect: TfpgRect;
+var
+ rect: TRect;
begin
+ Result := inherited GetClientRect;
+ rect := fpgStyle.GetControlFrameBorders;
case BorderStyle of
- ebsNone: Result := inherited GetClientRect;
- ebsDefault: Result.SetRect(2, 2, Width-4, Height-4);
- ebsSingle: Result.SetRect(1, 1, Width-2, Height-2);
+// ebsNone: // nothing to do
+ ebsDefault: InflateRect(Result, -rect.Left, -rect.Top); { assuming borders are even on opposite sides }
+ ebsSingle: InflateRect(Result, -1, -1);
end;
end;