richmemo: introduced GetText (GetUText). default and win32 implementation

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4077 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
skalogryz
2015-04-06 03:10:21 +00:00
parent 04b7618b48
commit 0fe137b895
4 changed files with 189 additions and 65 deletions

View File

@ -242,6 +242,8 @@ type
function InDelText(const UTF8Text: string; InsStartChar, ReplaceLength: Integer): Integer; virtual;
function InDelInline(inlineobj: TRichMemoInline; InsStartChar, ReplaceLength: Integer; const ASize: TSize): Integer; virtual;
function GetText(TextStart, TextLength: Integer): String;
function GetUText(TextStart, TextLength: Integer): UnicodeString;
procedure SetSelLengthFor(const aselstr: string);
@ -295,6 +297,7 @@ type
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnLinkAction;
property OnMouseDown;
property OnMouseEnter;
property OnMouseLeave;
@ -967,6 +970,34 @@ begin
inlineObj.Free;
end;
function TCustomRichMemo.GetText(TextStart, TextLength: Integer): String;
var
isu : Boolean;
txt : String;
utxt : UnicodeString;
begin
Result:='';
if not HandleAllocated then HandleNeeded;
if HandleAllocated and not TWSCustomRichMemoClass(WidgetSetClass).GetSubText(Self, TextStart, TextLength, false, isu, txt, utxt) then
Exit;
if isu then Result:=UTF8Decode(utxt)
else Result:=txt;
end;
function TCustomRichMemo.GetUText(TextStart, TextLength: Integer): UnicodeString;
var
isu : Boolean;
txt : String;
utxt : UnicodeString;
begin
Result:='';
if not HandleAllocated then HandleNeeded;
if HandleAllocated and not TWSCustomRichMemoClass(WidgetSetClass).GetSubText(Self, TextStart, TextLength, false, isu, txt, utxt) then
Exit;
if isu then Result:=utxt
else Result:=UTF8Encode(txt);
end;
procedure TCustomRichMemo.SetSelLengthFor(const aselstr: string);
begin
SelLength:=UTF8Length(aselstr);