diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-01-11 07:32:05 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-01-11 07:32:05 +0000 |
commit | af360479b99e24dddae75e1a75fa51baeca0db30 (patch) | |
tree | 34d51687e7e142aae4c80dd9cd6afa6df958c8f5 /src | |
parent | 249cb5ab4a5150a34fc36c1b58e45cdb6310e331 (diff) | |
download | fpGUI-af360479b99e24dddae75e1a75fa51baeca0db30.tar.xz |
* TfpgEdit now paints the selected text even if the component doesn't have focus. Different colors get used if it has focus or not.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/gui_edit.pas | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/src/gui/gui_edit.pas b/src/gui/gui_edit.pas index c5f94dba..83ded8ff 100644 --- a/src/gui/gui_edit.pas +++ b/src/gui/gui_edit.pas @@ -1,7 +1,7 @@ { fpGUI - Free Pascal GUI Library - Copyright (C) 2006 - 2007 See the file AUTHORS.txt, included in this + Copyright (C) 2006 - 2008 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, @@ -162,6 +162,30 @@ var r: TfpgRect; tw, tw2, st, len: integer; dtext: string; + + // paint selection rectangle + procedure DrawSelection; + var + lcolor: TfpgColor; + begin + if Focused then + lcolor := clSelection + else + lcolor := clInactiveSel; + + len := FSelOffset; + st := FSelStart; + if len < 0 then + begin + st := st + len; + len := -len; + end; + tw := FFont.TextWidth(UTF8copy(dtext, 1, st)); + tw2 := FFont.TextWidth(UTF8copy(dtext, 1, st + len)); + Canvas.XORFillRectangle(fpgColorToRGB(lcolor) xor $FFFFFF, + -FDrawOffset + FSideMargin + tw, 3, tw2 - tw, FFont.Height); + end; + begin Canvas.BeginDraw; @@ -191,30 +215,18 @@ begin else Canvas.SetColor(clWindowBackground); - Canvas.FillRectAngle(r); + Canvas.FillRectangle(r); dtext := GetDrawText; Canvas.SetTextColor(clText1); Canvas.SetFont(FFont); fpgStyle.DrawString(Canvas, -FDrawOffset + FSideMargin, 3, dtext, Enabled); + // drawing selection + if FSelOffset <> 0 then + DrawSelection; + if Focused then begin - // drawing selection - if FSelOffset <> 0 then - begin - len := FSelOffset; - st := FSelStart; - if len < 0 then - begin - st := st + len; - len := -len; - end; - tw := FFont.TextWidth(UTF8copy(dtext, 1, st)); - tw2 := FFont.TextWidth(UTF8copy(dtext, 1, st + len)); - Canvas.XORFillRectangle(fpgColorToRGB(clSelection) xor $FFFFFF, -FDrawOffset + - FSideMargin + tw, 3, tw2 - tw, FFont.Height); - end; - // drawing cursor tw := FFont.TextWidth(UTF8copy(dtext, 1, FCursorPos)); fpgCaret.SetCaret(Canvas, -FDrawOffset + FSideMargin + tw, 3, fpgCaret.Width, FFont.Height); |