You've already forked lazarus-ccr
richmemo: inserting image utility function
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3753 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -20,9 +20,57 @@ unit RichMemoUtils;
|
||||
|
||||
interface
|
||||
|
||||
{$mode objfpc}{$h+}
|
||||
|
||||
uses
|
||||
RichMemo;
|
||||
Types, RichMemo;
|
||||
|
||||
const
|
||||
NoResize : TSize = ( cx: 0; cy : 0 );
|
||||
|
||||
type
|
||||
TInsertOptions = set of (ioBelowBaseLine);
|
||||
var
|
||||
{ Disclaimer: the function would insert an image file into RichMemo
|
||||
(if implemented by the widgetset) But in a very inefficient way.
|
||||
The image would be read again and the memory would be re-allocated for
|
||||
the image every time. So please, don't use it for smileys in
|
||||
your chat instant messaging. A better API (with data caching) is considered.
|
||||
(That's why this method is not part of TCustomRichMemo class)
|
||||
|
||||
APos - position in the text
|
||||
AImgSize - size to be inserted (in POINTS, not pixels!).
|
||||
if both width and height are 0, the image would not be resized at all.
|
||||
}
|
||||
InsertImageFromFile : function (const ARichMemo: TCustomRichMemo; APos: Integer;
|
||||
const FileNameUTF8: string;
|
||||
const Options : TInsertOptions;
|
||||
const AImgSize: TSize
|
||||
): Boolean = nil;
|
||||
|
||||
function InsertImageFromFileNoResize (const ARichMemo: TCustomRichMemo; APos: Integer;
|
||||
const FileNameUTF8: string;
|
||||
const Options : TInsertOptions): Boolean;
|
||||
|
||||
implementation
|
||||
|
||||
function InsertImageFileDummy(const ARichMemo: TCustomRichMemo; APos: Integer;
|
||||
const FileNameUTF8: string;
|
||||
const Options: TInsertOptions;
|
||||
const AImgSize: TSize): Boolean;
|
||||
begin
|
||||
Result:=false;
|
||||
end;
|
||||
|
||||
function InsertImageFromFileNoResize (const ARichMemo: TCustomRichMemo; APos: Integer;
|
||||
const FileNameUTF8: string;
|
||||
const Options : TInsertOptions): Boolean;
|
||||
begin
|
||||
Result:=InsertImageFromFile(ARichMemo, APos, FileNameUTF8, Options, NoResize);
|
||||
end;
|
||||
|
||||
initialization
|
||||
if not Assigned(InsertImageFromFile) then
|
||||
InsertImageFromFile := @InsertImageFileDummy;
|
||||
|
||||
end.
|
||||
|
||||
Reference in New Issue
Block a user