You've already forked lazarus-ccr
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:
@@ -24,7 +24,7 @@ unit RichMemo;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, Graphics, StdCtrls, LazUTF8;
|
Types, Classes, SysUtils, Graphics, StdCtrls, LazUTF8;
|
||||||
|
|
||||||
type
|
type
|
||||||
TFontParams = record
|
TFontParams = record
|
||||||
@@ -91,6 +91,22 @@ type
|
|||||||
|
|
||||||
type
|
type
|
||||||
TRichMemoObject = class(TObject);
|
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 }
|
{ TCustomRichMemo }
|
||||||
|
|
||||||
@@ -99,6 +115,8 @@ type
|
|||||||
fHideSelection : Boolean;
|
fHideSelection : Boolean;
|
||||||
fOnSelectionChange: TNotifyEvent;
|
fOnSelectionChange: TNotifyEvent;
|
||||||
fZoomFactor : Double;
|
fZoomFactor : Double;
|
||||||
|
private
|
||||||
|
procedure InlineInvalidate(handler: TRichMemoInline);
|
||||||
protected
|
protected
|
||||||
procedure DoSelectionChange;
|
procedure DoSelectionChange;
|
||||||
class procedure WSRegisterClass; override;
|
class procedure WSRegisterClass; override;
|
||||||
@@ -143,6 +161,7 @@ type
|
|||||||
function SaveRichText(Dest: TStream): Boolean; virtual;
|
function SaveRichText(Dest: TStream): Boolean; virtual;
|
||||||
|
|
||||||
function InDelText(const UTF8Text: string; InsStartChar, ReplaceLength: Integer): Integer; 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);
|
procedure SetSelLengthFor(const aselstr: string);
|
||||||
|
|
||||||
@@ -295,6 +314,24 @@ begin
|
|||||||
n.Style:=pnBullet;
|
n.Style:=pnBullet;
|
||||||
end;
|
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 }
|
{ TRichMemo }
|
||||||
|
|
||||||
function TRichMemo.GetRTF: string;
|
function TRichMemo.GetRTF: string;
|
||||||
@@ -370,6 +407,14 @@ begin
|
|||||||
TWSCustomRichMemoClass(WidgetSetClass).SetZoomFactor(Self, AValue);
|
TWSCustomRichMemoClass(WidgetSetClass).SetZoomFactor(Self, AValue);
|
||||||
end;
|
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;
|
procedure TCustomRichMemo.DoSelectionChange;
|
||||||
begin
|
begin
|
||||||
if Assigned(fOnSelectionChange) then fOnSelectionChange(Self);
|
if Assigned(fOnSelectionChange) then fOnSelectionChange(Self);
|
||||||
@@ -674,6 +719,30 @@ begin
|
|||||||
end;
|
end;
|
||||||
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);
|
procedure TCustomRichMemo.SetSelLengthFor(const aselstr: string);
|
||||||
begin
|
begin
|
||||||
SelLength:=UTF8Length(aselstr);
|
SelLength:=UTF8Length(aselstr);
|
||||||
|
@@ -8,7 +8,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
RichMemoFactory, richmemoregister, RichMemoRTF, RichMemoUtils,
|
RichMemoFactory, richmemoregister, RichMemoRTF, RichMemoUtils,
|
||||||
RichMemoHelpers, RTFParsPre211, rtfeditpropdialog, LazarusPackageIntf;
|
RichMemoHelpers, RTFParsPre211, RtfEditPropDialog, LazarusPackageIntf;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
@@ -24,7 +24,7 @@ unit WSRichMemo;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils,
|
Types, Classes, SysUtils,
|
||||||
Graphics, Controls, StdCtrls,
|
Graphics, Controls, StdCtrls,
|
||||||
WSStdCtrls, RichMemo;
|
WSStdCtrls, RichMemo;
|
||||||
|
|
||||||
@@ -91,6 +91,12 @@ type
|
|||||||
class function Search(const AWinControl: TWinControl; const ANiddle: string; const SearchOpts: TIntSearchOpt): Integer; virtual;
|
class function Search(const AWinControl: TWinControl; const ANiddle: string; const SearchOpts: TIntSearchOpt): Integer; virtual;
|
||||||
|
|
||||||
class procedure SetZoomFactor(const AWinControl: TWinControl; AZoomFactor: Double); 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;
|
end;
|
||||||
TWSCustomRichMemoClass = class of TWSCustomRichMemo;
|
TWSCustomRichMemoClass = class of TWSCustomRichMemo;
|
||||||
|
|
||||||
@@ -215,5 +221,20 @@ begin
|
|||||||
|
|
||||||
end;
|
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.
|
end.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user