From d9a05ba0b96ecac83ccf56279f187984dccb14ae Mon Sep 17 00:00:00 2001 From: skalogryz Date: Sun, 30 Apr 2017 02:22:02 +0000 Subject: [PATCH] richmemo: implementing Redo and CanRedo for Win32 git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5844 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/richmemo/richmemo.pas | 18 ++++++++++++++++++ components/richmemo/win32/win32richmemo.pas | 16 +++++++++++++++- components/richmemo/wsrichmemo.pas | 14 ++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/components/richmemo/richmemo.pas b/components/richmemo/richmemo.pas index 7c5e7fad6..b37802aa4 100644 --- a/components/richmemo/richmemo.pas +++ b/components/richmemo/richmemo.pas @@ -203,6 +203,7 @@ type CurrentPage: Integer; var AbortPrint: Boolean); procedure DoLinkAction(ALinkAction: TLinkAction; const AMouseInfo: TLinkMouseInfo; LinkStart, LinkEnd: Integer); + function GetCanRedo: Boolean; virtual; public constructor Create(AOwner: TComponent); override; @@ -257,11 +258,14 @@ type function CharAtPos(x, y: Integer): Integer; + procedure Redo; virtual; + property HideSelection : Boolean read fHideSelection write SetHideSelection; property OnSelectionChange: TNotifyEvent read fOnSelectionChange write fOnSelectionChange; property ZoomFactor: Double read GetZoomFactor write SetZoomFactor; property OnPrintAction: TPrintActionEvent read fOnPrintAction write fOnPrintAction; property OnLinkAction: TLinkActionEvent read fOnLinkAction write fOnLinkAction; + property CanRedo: Boolean read GetCanRedo; end; { TRichMemo } @@ -1102,6 +1106,14 @@ begin Result:=-1; end; +function TCustomRichMemo.GetCanRedo: Boolean; +begin + if HandleAllocated then + Result:=TWSCustomRichMemoClass(WidgetSetClass).GetCanRedo(Self) + else + Result:=false; +end; + function TCustomRichMemo.PrintMeasure(const params: TPrintParams; var est: TPrintMeasure): Boolean; begin if not Assigned(Printer) then begin @@ -1117,5 +1129,11 @@ begin Result:=false; end; +procedure TCustomRichMemo.Redo; +begin + if HandleAllocated then + TWSCustomRichMemoClass(WidgetSetClass).Redo(Self); +end; + end. diff --git a/components/richmemo/win32/win32richmemo.pas b/components/richmemo/win32/win32richmemo.pas index d68c17c70..ef9f18326 100644 --- a/components/richmemo/win32/win32richmemo.pas +++ b/components/richmemo/win32/win32richmemo.pas @@ -136,6 +136,9 @@ type class function Print(const AWinControl: TWinControl; APrinter: TPrinter; const AParams: TPrintParams; DoPrint: Boolean): Integer; override; + + class procedure Redo(const AWinControl: TWinControl); override; + class function GetCanRedo(const AWinControl: TWinControl): Boolean; override; end; { TWin32Inline } @@ -531,7 +534,7 @@ begin end; class function TWin32WSCustomRichMemo.CanPasteFromClipboard( - const AWinControl: TWinControl): Boolean; + const AWinControl: TWinControl): boolean; begin Result:=Assigned(AWinControl) and (SendMessage(AWinControl.Handle, EM_CANPASTE, 0, 0)<>0); end; @@ -1437,6 +1440,17 @@ begin end; end; +class procedure TWin32WSCustomRichMemo.Redo(const AWinControl: TWinControl); +begin + SendMessage( AWinControl.Handle, EM_REDO, 0, 0); +end; + +class function TWin32WSCustomRichMemo.GetCanRedo(const AWinControl: TWinControl + ): Boolean; +begin + Result:=SendMessage( AWinControl.Handle, EM_CANREDO, 0, 0)<>0; +end; + // The function doesn't use Windows 7 (Vista?) animations. And should. function ThemedNCPaint(AWindow: Windows.HANDLE; RichMemo: TCustomRichMemo; WParam: WParam; LParam: LParam; var Handled: Boolean): LResult; diff --git a/components/richmemo/wsrichmemo.pas b/components/richmemo/wsrichmemo.pas index a612bc837..00c727112 100644 --- a/components/richmemo/wsrichmemo.pas +++ b/components/richmemo/wsrichmemo.pas @@ -115,6 +115,9 @@ type AHandler: TRichMemoInline; wsObj: TRichMemoInlineWSObject); virtual; class function Print(const AWinControl: TWinControl; APrinter: TPrinter; const AParams: TPrintParams; DoPrint: Boolean): Integer; virtual; + + class procedure Redo(const AWinControl: TWinControl); virtual; + class function GetCanRedo(const AWinControl: TWinControl): Boolean; virtual; end; TWSCustomRichMemoClass = class of TWSCustomRichMemo; @@ -406,5 +409,16 @@ begin Result:=0; end; +class procedure TWSCustomRichMemo.Redo(const AWinControl: TWinControl); +begin + +end; + +class function TWSCustomRichMemo.GetCanRedo(const AWinControl: TWinControl + ): Boolean; +begin + Result:=false; +end; + end.