diff options
author | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2009-06-23 13:10:09 +0200 |
---|---|---|
committer | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2009-06-23 13:10:09 +0200 |
commit | ace5a931cb58672e7805813276cb97caeacf7c93 (patch) | |
tree | 3751a90c67c7092f34f055a06ac9bf334dfb5644 /src/gui | |
parent | a50cd6cb09146a43b3efb639399e2a9543e074c8 (diff) | |
download | fpGUI-ace5a931cb58672e7805813276cb97caeacf7c93.tar.xz |
Fix overlapping text in RadioButton and CheckBox
* If BoxLayout = right, then the text caption could paint
over the radio or check images. This is now fixed.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/fpg_checkbox.pas | 11 | ||||
-rw-r--r-- | src/gui/fpg_radiobutton.pas | 11 |
2 files changed, 18 insertions, 4 deletions
diff --git a/src/gui/fpg_checkbox.pas b/src/gui/fpg_checkbox.pas index 532d60be..87a1b4df 100644 --- a/src/gui/fpg_checkbox.pas +++ b/src/gui/fpg_checkbox.pas @@ -151,19 +151,23 @@ var tx: integer; ix: integer; img: TfpgImage; + cliprect: TfpgRect; begin inherited HandlePaint; Canvas.SetColor(FBackgroundColor); Canvas.FillRectangle(0, 0, Width, Height); Canvas.SetFont(Font); + cliprect.SetRect(1, 1, Width-2, Height-2); if FFocused then begin Canvas.SetColor(clText1); Canvas.SetLineStyle(1, lsDot); - Canvas.DrawRectangle(1, 1, Width-2, Height-2); + Canvas.DrawRectangle(cliprect); + InflateRect(cliprect, 1, 1); end; + Canvas.SetClipRect(cliprect); Canvas.SetLineStyle(1, lsSolid); if FBoxLayout = tbLeftBox then @@ -190,7 +194,7 @@ begin inc(r.left, 2); end else - tx := 0; + tx := 3; // leave space for focus rectangle inc(r.top, 1); // paint the check (in this case a X) img := fpgImages.GetImage('sys.checkboxes'); // Do NOT localize @@ -200,6 +204,9 @@ begin if ty < 0 then ty := 0; Canvas.SetTextColor(FTextColor); + Canvas.ClearClipRect; + cliprect.SetRect(tx, ty, Width-FBoxSize-8, cliprect.Height); + Canvas.SetClipRect(cliprect); fpgStyle.DrawString(Canvas, tx, ty, FText, Enabled); end; diff --git a/src/gui/fpg_radiobutton.pas b/src/gui/fpg_radiobutton.pas index c0bb20da..97303bb5 100644 --- a/src/gui/fpg_radiobutton.pas +++ b/src/gui/fpg_radiobutton.pas @@ -184,19 +184,23 @@ var tx: integer; img: TfpgImage; ix: integer; + cliprect: TfpgRect; begin inherited HandlePaint; Canvas.SetColor(FBackgroundColor); Canvas.FillRectangle(0, 0, Width, Height); Canvas.SetFont(Font); + cliprect.SetRect(1, 1, Width-2, Height-2); if FFocused then begin Canvas.SetColor(clText1); Canvas.SetLineStyle(1, lsDot); - Canvas.DrawRectangle(1, 1, Width-2, Height-2); + Canvas.DrawRectangle(cliprect); + InflateRect(cliprect, 1, 1); end; + Canvas.SetClipRect(cliprect); Canvas.SetLineStyle(1, lsSolid); if FBoxLayout = tbLeftBox then @@ -223,7 +227,7 @@ begin inc(r.left, 2); end else - tx := 0; + tx := 3; // leave space for focus rectangle inc(r.top, 1); // paint the radio button img := fpgImages.GetImage('sys.radiobuttons'); // Do NOT localize @@ -233,6 +237,9 @@ begin if ty < 0 then ty := 0; Canvas.SetTextColor(FTextColor); + Canvas.ClearClipRect; + cliprect.SetRect(tx, ty, Width-FBoxSize-8, cliprect.Height); + Canvas.SetClipRect(cliprect); fpgStyle.DrawString(Canvas, tx, ty, FText, Enabled); end; |