richmemo: inline objects to the interface

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3846 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
skalogryz
2014-12-20 16:44:08 +00:00
parent 098b7daf32
commit 7c11c226d3
3 changed files with 93 additions and 3 deletions

View File

@ -24,7 +24,7 @@ unit RichMemo;
interface
uses
Classes, SysUtils, Graphics, StdCtrls, LazUTF8;
Types, Classes, SysUtils, Graphics, StdCtrls, LazUTF8;
type
TFontParams = record
@ -91,6 +91,22 @@ type
type
TRichMemoObject = class(TObject);
TCustomRichMemo = class;
TRichMemoInlineWSObject = TObject;
{ TRichMemoInline }
TRichMemoInline = class(TObject)
private
WSObj : TRichMemoInlineWSObject;
fOwner : TCustomRichMemo;
public
procedure Draw(Canvas: TCanvas; const ASize: TSize); virtual;
procedure SetVisible(AVisible: Boolean); virtual;
procedure Invalidate;
property Owner: TCustomRichMemo read fOwner;
end;
{ TCustomRichMemo }
@ -99,6 +115,8 @@ type
fHideSelection : Boolean;
fOnSelectionChange: TNotifyEvent;
fZoomFactor : Double;
private
procedure InlineInvalidate(handler: TRichMemoInline);
protected
procedure DoSelectionChange;
class procedure WSRegisterClass; override;
@ -143,6 +161,7 @@ type
function SaveRichText(Dest: TStream): Boolean; virtual;
function InDelText(const UTF8Text: string; InsStartChar, ReplaceLength: Integer): Integer; virtual;
function InDelInline(inlineobj: TRichMemoInline; InsStartChar, ReplaceLength: Integer; const ASize: TSize): Integer; virtual;
procedure SetSelLengthFor(const aselstr: string);
@ -295,6 +314,24 @@ begin
n.Style:=pnBullet;
end;
{ TRichMemoInline }
procedure TRichMemoInline.Draw(Canvas: TCanvas; const ASize: TSize);
begin
end;
procedure TRichMemoInline.SetVisible(AVisible: Boolean);
begin
end;
procedure TRichMemoInline.Invalidate;
begin
if not Assigned(fOwner) then Exit;
Owner.InlineInvalidate( Self );
end;
{ TRichMemo }
function TRichMemo.GetRTF: string;
@ -370,6 +407,14 @@ begin
TWSCustomRichMemoClass(WidgetSetClass).SetZoomFactor(Self, AValue);
end;
procedure TCustomRichMemo.InlineInvalidate(handler: TRichMemoInline);
begin
if not Assigned(handler) then Exit;
if not HandleAllocated then HandleNeeded;
if HandleAllocated then
TWSCustomRichMemoClass(WidgetSetClass).InlineInvalidate(Self, handler, handler.WSObj);
end;
procedure TCustomRichMemo.DoSelectionChange;
begin
if Assigned(fOnSelectionChange) then fOnSelectionChange(Self);
@ -674,6 +719,30 @@ begin
end;
end;
function TCustomRichMemo.InDelInline(inlineobj: TRichMemoInline; InsStartChar,
ReplaceLength: Integer; const ASize: TSize): Integer;
var
obj : TRichMemoInlineWSObject;
begin
Result:=0;
if not Assigned(inlineObj) then Exit;
if Assigned(inlineobj.fOwner) and (inlineobj.fOwner<>Self) then Exit;
if not HandleAllocated then HandleNeeded;
if HandleAllocated then begin
obj:=nil;
if not TWSCustomRichMemoClass(WidgetSetClass).InlineInsert(Self, InsStartChar
, ReplaceLength, ASize, inlineObj, obj) then begin
inlineObj.Free;
Result:=0;
end;
if not Assigned(inlineObj.fOwner) then inlineObj.fOwner:=Self;
inlineObj.WSObj:=obj;
Result:=ReplaceLength;
end else
inlineObj.Free;
end;
procedure TCustomRichMemo.SetSelLengthFor(const aselstr: string);
begin
SelLength:=UTF8Length(aselstr);

View File

@ -8,7 +8,7 @@ interface
uses
RichMemoFactory, richmemoregister, RichMemoRTF, RichMemoUtils,
RichMemoHelpers, RTFParsPre211, rtfeditpropdialog, LazarusPackageIntf;
RichMemoHelpers, RTFParsPre211, RtfEditPropDialog, LazarusPackageIntf;
implementation

View File

@ -24,7 +24,7 @@ unit WSRichMemo;
interface
uses
Classes, SysUtils,
Types, Classes, SysUtils,
Graphics, Controls, StdCtrls,
WSStdCtrls, RichMemo;
@ -91,6 +91,12 @@ type
class function Search(const AWinControl: TWinControl; const ANiddle: string; const SearchOpts: TIntSearchOpt): Integer; virtual;
class procedure SetZoomFactor(const AWinControl: TWinControl; AZoomFactor: Double); virtual;
//inline handler
class function InlineInsert(const AWinControl: TWinControl; ATextStart, ATextLength: Integer;
const ASize: TSize; AHandler: TRichMemoInline; var wsObj: TRichMemoInlineWSObject): Boolean; virtual;
class procedure InlineInvalidate(const AWinControl: TWinControl;
AHandler: TRichMemoInline; wsObj: TRichMemoInlineWSObject); virtual;
end;
TWSCustomRichMemoClass = class of TWSCustomRichMemo;
@ -215,5 +221,20 @@ begin
end;
class function TWSCustomRichMemo.InlineInsert(const AWinControl: TWinControl;
ATextStart, ATextLength: Integer; const ASize: TSize; AHandler: TRichMemoInline;
var wsObj: TRichMemoInlineWSObject): Boolean;
begin
wsObj:=nil;
Result:=false;
end;
class procedure TWSCustomRichMemo.InlineInvalidate(
const AWinControl: TWinControl; AHandler: TRichMemoInline;
wsObj: TRichMemoInlineWSObject);
begin
end;
end.