You've already forked lazarus-ccr
richmemo: extending linkaction information with linkRef
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6290 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -137,7 +137,8 @@ type
|
||||
TLinkAction = (laClick);
|
||||
|
||||
TLinkMouseInfo = record
|
||||
button : TMouseButton;
|
||||
Button : TMouseButton;
|
||||
LinkRef : String;
|
||||
end;
|
||||
|
||||
TLinkActionEvent = procedure (Sender: TObject;
|
||||
|
@ -329,6 +329,8 @@ begin
|
||||
if isClick then begin
|
||||
FillChar(minfo, sizeof(minfo), 0);
|
||||
minfo.button:=mb;
|
||||
RichEditManager.LinkNotifyToInfo( AWinControl.Handle,
|
||||
lnk^, minfo );
|
||||
TIntCustomRichMemo(AWinControl).DoLinkAction(laClick, minfo, lnk^.chrg.cpMin, lnk^.chrg.cpMax-lnk^.chrg.cpMin);
|
||||
end;
|
||||
|
||||
|
@ -196,6 +196,9 @@ type
|
||||
|
||||
class procedure GetScroll(RichEditWnd: Handle; out pt: TPoint); virtual;
|
||||
class procedure SetScroll(RichEditWnd: Handle; const pt: TPoint); virtual;
|
||||
|
||||
class function LinkNotifyToInfo(RichEditWnd: Handle; const LinkNotify: TENLINK;
|
||||
var LinkInfo: TLinkMouseInfo): Boolean; virtual;
|
||||
end;
|
||||
TRichManagerClass = class of TRichEditManager;
|
||||
|
||||
@ -203,6 +206,8 @@ type
|
||||
|
||||
TRichEditManagerWinXP = class(TRichEditManager)
|
||||
class procedure SetTextUIStyle(RichEditWnd: Handle; const ui: TTextUIParam); override;
|
||||
class function LinkNotifyToInfo(RichEditWnd: Handle; const LinkNotify: TENLINK;
|
||||
var LinkInfo: TLinkMouseInfo): Boolean; override;
|
||||
end;
|
||||
|
||||
var
|
||||
@ -349,7 +354,7 @@ end;
|
||||
class procedure TRichEditManagerWinXP.SetTextUIStyle(RichEditWnd: Handle;
|
||||
const ui: TTextUIParam);
|
||||
var
|
||||
st : TSetTextEx;
|
||||
st : TSetTextEx;
|
||||
linkrtf : String;
|
||||
txt : WideString;
|
||||
txtrtf : String;
|
||||
@ -357,14 +362,32 @@ begin
|
||||
if RichEditWnd = 0 then Exit;
|
||||
|
||||
txt := GetTextW(RichEditWnd, true);
|
||||
st.codepage:=CP_UTF8;
|
||||
st.flags:=ST_SELECTION;
|
||||
txtrtf:=UTF8Encode(txt);
|
||||
linkrtf:=Format('{\rtf1{\field{\*\fldinst{ HYPERLINK "%s"}}{\fldrslt{%s}}}}',
|
||||
[ui.linkref, txtrtf]);
|
||||
st.codepage := CP_UTF8;
|
||||
st.flags := ST_SELECTION;
|
||||
txtrtf := UTF8Encode(txt);
|
||||
linkrtf := Format(
|
||||
'{\rtf1{\colortbl ;\red0\green0\blue238;}{\field \ul \cf1 {\*\fldinst{ HYPERLINK "%s"}}{\fldrslt{%s}\ul0 \cf0}}}',
|
||||
[ui.linkref, txtrtf]
|
||||
);
|
||||
SendMessage(RichEditWnd, EM_SETTEXTEX, WPARAM(@st), LParam(@linkrtf[1]));
|
||||
end;
|
||||
|
||||
class function TRichEditManagerWinXP.LinkNotifyToInfo(RichEditWnd: Handle;
|
||||
const LinkNotify: TENLINK; var LinkInfo: TLinkMouseInfo): Boolean;
|
||||
var
|
||||
w : WideString;
|
||||
tr : RichEdit.TEXTRANGEW;
|
||||
res : LResult;
|
||||
begin
|
||||
FillChar(tr, sizeof(tr),0);
|
||||
tr.chrg.cpMin:=LinkNotify.chrg.cpMin;
|
||||
tr.chrg.cpMax:=LinkNotify.chrg.cpMax;
|
||||
setLength(w, tr.chrg.cpMax-tr.chrg.cpMin+1);
|
||||
tr.lpstrText:=@w[1];
|
||||
res := Windows.SendMessage(RichEditWnd, EM_GETTEXTRANGE, 0, Windows.lParam(@tr));
|
||||
LinkInfo.LinkRef := UTF8Encode( Copy(w, 1, res) );
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
{ TRichEditManager }
|
||||
|
||||
@ -1013,6 +1036,12 @@ begin
|
||||
SendMessage(RichEditWnd, EM_SETSCROLLPOS, 0, LPARAM(@pt));
|
||||
end;
|
||||
|
||||
class function TRichEditManager.LinkNotifyToInfo(RichEditWnd: Handle;
|
||||
const LinkNotify: TENLINK; var LinkInfo: TLinkMouseInfo): Boolean;
|
||||
begin
|
||||
Result := false;
|
||||
end;
|
||||
|
||||
function WinInsertImageFromFile (const ARichMemo: TCustomRichMemo; APos: Integer;
|
||||
const FileNameUTF8: string;
|
||||
const AImgSize: TSize): Boolean;
|
||||
|
Reference in New Issue
Block a user