From 7a05a7ec1b55adfbbb8c736c081583ec012a982e Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Sun, 23 Feb 2014 13:42:38 +0000 Subject: edit: Remove more hard-coded values for improved themes support. --- src/gui/fpg_edit.pas | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) (limited to 'src') 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; -- cgit v1.2.3-70-g09d2