richmemo: added GetParaRange methods and its win32 implementation

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3783 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
skalogryz
2014-11-26 16:16:54 +00:00
parent 192e1008cc
commit 6dcc6025d4
4 changed files with 119 additions and 3 deletions

View File

@ -63,6 +63,14 @@ type
TSearchOption = (soMatchCase, soWholeWord, soBackward);
TSearchOptions = set of TSearchOption;
TParaRange = record
start : Integer; // the first character in the paragraph
lenghtNoBr : Integer; // the length of the paragraph, excluding the line break character
length : Integer; // the length of the paragrpah, including the line break, if present
// the last line in the control doesn't contain a line break character,
// thus length = lengthNoBr
end;
type
TRichMemoObject = class(TObject);
@ -97,6 +105,8 @@ type
procedure SetParaMetric(TextStart, TextLen: Integer; const AMetric: TParaMetric); virtual;
function GetParaNumbering(TextStart: Integer; var ANumber: TParaNumbering): Boolean; virtual;
procedure SetParaNumbering(TextStart, TextLen: Integer; const ANumber: TParaNumbering); virtual;
function GetParaRange(CharOfs: Integer; var ParaRange: TParaRange): Boolean; virtual;
function GetParaRange(CharOfs: Integer; var TextStart, TextLength: Integer): Boolean;
procedure SetTextAttributes(TextStart, TextLen: Integer; AFont: TFont);
procedure SetRangeColor(TextStart, TextLength: Integer; FontColor: TColor);
@ -350,6 +360,25 @@ begin
TWSCustomRichMemoClass(WidgetSetClass).SetParaNumbering(Self, TextStart, TextLen, ANumber);
end;
function TCustomRichMemo.GetParaRange(CharOfs: Integer;
var ParaRange: TParaRange): Boolean;
begin
Result:=false;
if not HandleAllocated then HandleNeeded;
if HandleAllocated then
Result:=TWSCustomRichMemoClass(WidgetSetClass).GetParaRange(Self, CharOfs, ParaRange);
end;
function TCustomRichMemo.GetParaRange(CharOfs: Integer; var TextStart,
TextLength: Integer): Boolean;
var
p : TParaRange;
begin
Result:=GetParaRange(CharOfs, p);
TextStart:=p.start;
TextLength:=p.length;
end;
function TCustomRichMemo.GetContStyleLength(TextStart: Integer): Integer;
var
ofs, len : Integer;