From 8d29dccb152905b9cffa9b39e1e79a87de33a817 Mon Sep 17 00:00:00 2001 From: skalogryz Date: Sun, 19 Apr 2015 03:25:43 +0000 Subject: [PATCH] richmemo: CharAtPos method git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4086 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/richmemo/richmemo.pas | 10 ++++++++++ components/richmemo/win32/win32richmemo.pas | 15 +++++++++++++++ components/richmemo/wsrichmemo.pas | 8 ++++++++ 3 files changed, 33 insertions(+) diff --git a/components/richmemo/richmemo.pas b/components/richmemo/richmemo.pas index 32cc56daa..3a0b8faad 100644 --- a/components/richmemo/richmemo.pas +++ b/components/richmemo/richmemo.pas @@ -251,6 +251,8 @@ type function Print(const params: TPrintParams): Integer; + function CharAtPos(x, y: Integer): Integer; + property HideSelection : Boolean read fHideSelection write SetHideSelection; property OnSelectionChange: TNotifyEvent read fOnSelectionChange write fOnSelectionChange; property ZoomFactor: Double read GetZoomFactor write SetZoomFactor; @@ -1027,6 +1029,14 @@ begin Result:=TWSCustomRichMemoClass(WidgetSetClass).Print(Self, Printer, params, true); end; +function TCustomRichMemo.CharAtPos(x, y: Integer): Integer; +begin + if HandleAllocated then + Result:=TWSCustomRichMemoClass(WidgetSetClass).CharAtPos(Self, x, y) + else + Result:=-1; +end; + function TCustomRichMemo.PrintMeasure(const params: TPrintParams; var est: TPrintMeasure): Boolean; begin if not Assigned(Printer) then begin diff --git a/components/richmemo/win32/win32richmemo.pas b/components/richmemo/win32/win32richmemo.pas index 88bf37d54..b025d59f5 100644 --- a/components/richmemo/win32/win32richmemo.pas +++ b/components/richmemo/win32/win32richmemo.pas @@ -108,6 +108,7 @@ type class procedure InDelText(const AWinControl: TWinControl; const TextUTF8: String; DstStart, DstLen: Integer); override; class function GetSubText(const AWinControl: TWinControl; TextStart, TextLen: Integer; AsUnicode: Boolean; var isUnicode: Boolean; var txt: string; var utxt: UnicodeString): Boolean; override; + class function CharAtPos(const AWinControl: TWinControl; x,y: Integer): Integer; override; class function Search(const AWinControl: TWinControl; const ANiddle: string; const SearchOpts: TIntSearchOpt): Integer; override; @@ -986,6 +987,20 @@ begin RichEditManager.SetEventMask(Hnd, eventmask); end; +class function TWin32WSCustomRichMemo.CharAtPos(const AWinControl: TWinControl; + x, y: Integer): Integer; +var + p : POINTL; +begin + if not Assigned(AWinControl) then + inherited + else begin + p.x:=x; + p.y:=y; + Result:=Windows.SendMessage(AWinControl.Handle, EM_CHARFROMPOS, 0, LPARAM(@p)); + end; +end; + class function TWin32WSCustomRichMemo.Search(const AWinControl: TWinControl; const ANiddle: string; const SearchOpts: TIntSearchOpt): Integer; begin diff --git a/components/richmemo/wsrichmemo.pas b/components/richmemo/wsrichmemo.pas index 13dfec4ac..65d98db3a 100644 --- a/components/richmemo/wsrichmemo.pas +++ b/components/richmemo/wsrichmemo.pas @@ -88,6 +88,8 @@ type class function GetSubText(const AWinControl: TWinControl; TextStart, TextLen: Integer; AsUnicode: Boolean; var isUnicode: Boolean; var txt: string; var utxt: UnicodeString): Boolean; virtual; + class function CharAtPos(const AWinControl: TWinControl; x,y: Integer): Integer; virtual; + //class procedure SetHideSelection(const ACustomEdit: TCustomEdit; AHideSelection: Boolean); override; class function LoadRichText(const AWinControl: TWinControl; Source: TStream): Boolean; virtual; class function SaveRichText(const AWinControl: TWinControl; Dest: TStream): Boolean; virtual; @@ -244,6 +246,12 @@ begin Result:=true; end; +class function TWSCustomRichMemo.CharAtPos(const AWinControl: TWinControl; x, + y: Integer): Integer; +begin + Result:=-1; +end; + {class procedure TWSCustomRichMemo.SetHideSelection(const ACustomEdit: TCustomEdit; AHideSelection: Boolean); begin