summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graemeg@gmail.com>2010-06-01 00:16:38 +0200
committerGraeme Geldenhuys <graemeg@gmail.com>2010-06-01 00:16:38 +0200
commit406b5dad944a5e5e8ee2a0f1add8a367e4d2f1e1 (patch)
treeda9c5edbd4c944973bbee797e77c9cf3538bc6af
parentad24d3be685a1f2e86e0b0cfdd7dfdf2e3a99b04 (diff)
downloadfpGUI-406b5dad944a5e5e8ee2a0f1add8a367e4d2f1e1.tar.xz
Added 3 new properties. FontHeight, FontWidth and OnDrawLine.
-rw-r--r--prototypes/textedit/fpg_textedit.pas15
1 files changed, 13 insertions, 2 deletions
diff --git a/prototypes/textedit/fpg_textedit.pas b/prototypes/textedit/fpg_textedit.pas
index 62d6d644..ebe66222 100644
--- a/prototypes/textedit/fpg_textedit.pas
+++ b/prototypes/textedit/fpg_textedit.pas
@@ -62,12 +62,18 @@ type
end;
+ TfpgDrawLineEvent = procedure(Sender: TObject; ALineText: TfpgString;
+ ALineIndex: Integer; ACanvas: TfpgCanvas; ATextRect: TfpgRect;
+ var AllowSelfDraw: Boolean) of object;
+
+
TfpgBaseTextEdit = class(TfpgWidget)
private
FFont: TfpgFont;
FFullRedraw: Boolean;
FLines: TStrings;
CaretPos: TPoint;
+ FOnDrawLine: TfpgDrawLineEvent;
FScrollBarStyle: TfpgScrollStyle;
MousePos: TPoint;
FChrW: Integer;
@@ -142,6 +148,7 @@ type
property ScrollBarStyle: TfpgScrollStyle read FScrollBarStyle write SetScrollBarStyle default ssAutoBoth;
property TabWidth: Integer read FTabWidth write SetTabWidth default 8;
property Tracking: Boolean read FTracking write FTracking default True;
+ property OnDrawLine: TfpgDrawLineEvent read FOnDrawLine write FOnDrawLine;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
@@ -153,6 +160,8 @@ type
procedure DeleteSelection;
procedure SaveToFile(const AFileName: TfpgString);
procedure LoadFromFile(const AFileName: TfpgString);
+ property FontHeight: Integer read FChrH;
+ property FontWidth: Integer read FChrW;
property ScrollPos_H: Integer read GetHScrollPos write SetHScrollPos;
property ScrollPos_V: Integer read GetVScrollPos write SetVScrollPos;
property TopLine: Integer read FTopLine;
@@ -172,6 +181,7 @@ type
property ScrollBarStyle;
property TabWidth;
property Tracking;
+ property OnDrawLine;
end;
@@ -1295,11 +1305,12 @@ begin
{ start drawing formatted text }
R.SetRect(X, Y, UTF8Length(S) * FChrW, FChrH);
AllowDraw := True;
-// if Assigned(FOnDrawLine) then FOnDrawLine(Self, S, I, LGliph, R, AllowDraw);
+ { end-user can hook in here to do syntax highlighting and other custom drawing }
+ if Assigned(FOnDrawLine) then
+ FOnDrawLine(self, S, I, Canvas, R, AllowDraw);
{ Draw simple text line... }
if AllowDraw then
Canvas.DrawText(R, S);
-// DrawText(LGliph.Canvas.Handle, PChar(S), Length(S), R, DT_DRAWLINE);
{ todo: Do other formatting here. }
{ todo: Do selection painting here. }