From 7c11c226d31f2ac50035d8d179092d69c767af64 Mon Sep 17 00:00:00 2001 From: skalogryz Date: Sat, 20 Dec 2014 16:44:08 +0000 Subject: [PATCH] richmemo: inline objects to the interface git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3846 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/richmemo/richmemo.pas | 71 ++++++++++++++++++++++++- components/richmemo/richmemopackage.pas | 2 +- components/richmemo/wsrichmemo.pas | 23 +++++++- 3 files changed, 93 insertions(+), 3 deletions(-) diff --git a/components/richmemo/richmemo.pas b/components/richmemo/richmemo.pas index f40ca1da9..0aafc0dbb 100644 --- a/components/richmemo/richmemo.pas +++ b/components/richmemo/richmemo.pas @@ -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); diff --git a/components/richmemo/richmemopackage.pas b/components/richmemo/richmemopackage.pas index 708bc364d..b15332681 100644 --- a/components/richmemo/richmemopackage.pas +++ b/components/richmemo/richmemopackage.pas @@ -8,7 +8,7 @@ interface uses RichMemoFactory, richmemoregister, RichMemoRTF, RichMemoUtils, - RichMemoHelpers, RTFParsPre211, rtfeditpropdialog, LazarusPackageIntf; + RichMemoHelpers, RTFParsPre211, RtfEditPropDialog, LazarusPackageIntf; implementation diff --git a/components/richmemo/wsrichmemo.pas b/components/richmemo/wsrichmemo.pas index 2f01e5b5a..28db2730f 100644 --- a/components/richmemo/wsrichmemo.pas +++ b/components/richmemo/wsrichmemo.pas @@ -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.