mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-16 07:09:38 +02:00
LCL: added TPicture.FindGraphicClassWithFileExt
git-svn-id: trunk@13526 -
This commit is contained in:
parent
72c50fe0be
commit
02774924f6
@ -8773,19 +8773,21 @@ var
|
||||
{$ENDIF}
|
||||
begin
|
||||
{$IFDEF SYN_LAZARUS}
|
||||
LogCaret:=PhysicalToLogicalPos(CaretXY);
|
||||
LogCaret:=LogicalCaretXY;
|
||||
CX := LogCaret.X;
|
||||
CY := LogCaret.Y;
|
||||
{$ELSE}
|
||||
CX := CaretX;
|
||||
CY := CaretY;
|
||||
{$ENDIF}
|
||||
//DebugLn(['TCustomSynEdit.PrevWordPos ',dbgs(LogCaret)]);
|
||||
// valid line?
|
||||
if (CY >= 1) and (CY <= Lines.Count) then begin
|
||||
Line := Lines[CY - 1];
|
||||
CX := Min(CX, Length(Line) + 1);
|
||||
CurIdentChars:=IdentChars;
|
||||
WhiteChars := [#1..#255] - CurIdentChars;
|
||||
//DebugLn(['TCustomSynEdit.PrevWordPos Line="',dbgstr(Line),'" CX=',CX]);
|
||||
if CX <= 1 then begin
|
||||
// find last IdentChar in the previous line
|
||||
if CY > 1 then begin
|
||||
@ -8797,6 +8799,7 @@ begin
|
||||
// if previous char is a "whitespace" search for the last IdentChar
|
||||
if Line[CX - 1] in WhiteChars then
|
||||
CX := StrRScanForCharInSet(Line, CX - 1, CurIdentChars);
|
||||
//DebugLn(['TCustomSynEdit.PrevWordPos AAA1 CX=',CX]);
|
||||
if CX > 0 then
|
||||
// search for the first IdentChar of this "word"
|
||||
CX := StrRScanForCharInSet(Line, CX - 1, WhiteChars) + 1
|
||||
@ -8807,13 +8810,16 @@ begin
|
||||
Line := Lines[CY - 1];
|
||||
CX := Length(Line) + 1;
|
||||
end;
|
||||
//DebugLn(['TCustomSynEdit.PrevWordPos AAA2 CX=',CX]);
|
||||
end;
|
||||
end;
|
||||
//DebugLn(['TCustomSynEdit.PrevWordPos AAA3 ',CX,',',CY]);
|
||||
{$IFDEF SYN_LAZARUS}
|
||||
Result := LogicalToPhysicalPos(Point(CX, CY));
|
||||
{$ELSE}
|
||||
Result := Point(CX, CY);
|
||||
{$ENDIF}
|
||||
//DebugLn(['TCustomSynEdit.PrevWordPos END ',dbgs(Result)]);
|
||||
end;
|
||||
|
||||
procedure TCustomSynEdit.SetSelectionMode(const Value: TSynSelectionMode);
|
||||
|
@ -817,6 +817,7 @@ type
|
||||
destructor Destroy; override;
|
||||
procedure LoadFromFile(const Filename: string);
|
||||
procedure SaveToFile(const Filename: string);
|
||||
procedure LoadFromStream(const Filename: string);
|
||||
procedure LoadFromClipboardFormat(FormatID: TClipboardFormat);
|
||||
procedure LoadFromClipboardFormatID(ClipboardType: TClipboardType;
|
||||
FormatID: TClipboardFormat);
|
||||
@ -829,6 +830,8 @@ type
|
||||
AGraphicClass: TGraphicClass);
|
||||
class procedure UnregisterGraphicClass(AClass: TGraphicClass);
|
||||
procedure Clear; virtual;
|
||||
function FindGraphicClassWithFileExt(const Ext: string;
|
||||
ExceptionOnNotFound: boolean = true): TGraphicClass;
|
||||
public
|
||||
property Bitmap: TBitmap read GetBitmap write SetBitmap;
|
||||
property Icon: TIcon read GetIcon write SetIcon;
|
||||
|
@ -488,9 +488,7 @@ var
|
||||
begin
|
||||
Ext := ExtractFileExt(Filename);
|
||||
System.Delete(Ext, 1, 1); // delete '.'
|
||||
GraphicClass := GetPicFileFormats.FindExt(Ext);
|
||||
if GraphicClass = nil then
|
||||
raise EInvalidGraphic.CreateFmt(rsUnknownPictureExtension, [Ext]);
|
||||
GraphicClass := FindGraphicClassWithFileExt(Ext);
|
||||
|
||||
NewGraphic := GraphicClass.Create;
|
||||
ok:=false;
|
||||
@ -594,6 +592,19 @@ begin
|
||||
SetGraphic(nil);
|
||||
end;
|
||||
|
||||
function TPicture.FindGraphicClassWithFileExt(const Ext: string;
|
||||
ExceptionOnNotFound: boolean): TGraphicClass;
|
||||
var
|
||||
FileExt: String;
|
||||
begin
|
||||
FileExt:=Ext;
|
||||
if (FileExt<>'') and (FileExt[1]='.') then
|
||||
FileExt:=copy(FileExt,2,length(FileExt));
|
||||
Result := GetPicFileFormats.FindExt(FileExt);
|
||||
if (Result = nil) and ExceptionOnNotFound then
|
||||
raise EInvalidGraphic.CreateFmt(rsUnknownPictureExtension, [Ext]);
|
||||
end;
|
||||
|
||||
procedure TPicture.Changed(Sender: TObject);
|
||||
begin
|
||||
if Assigned(FOnChange) then FOnChange(Self);
|
||||
|
@ -548,7 +548,7 @@ procedure FreeUnusedLCLHelpSystem;
|
||||
function FilenameToURL(const Filename: string): string;
|
||||
function FilenameToURLPath(const Filename: string): string;
|
||||
function URLPathToFilename(const URLPath: string): string;
|
||||
procedure SplitURL(const URL: string; var URLType, URLPath, URLParams: string);
|
||||
procedure SplitURL(const URL: string; out URLType, URLPath, URLParams: string);
|
||||
function CombineURL(const URLType, URLPath, URLParams: string): string;
|
||||
function URLFilenameIsAbsolute(const URLPath: string): boolean;
|
||||
function FindURLPathStart(const URL: string): integer;
|
||||
@ -626,7 +626,7 @@ begin
|
||||
{$warnings on}
|
||||
end;
|
||||
|
||||
procedure SplitURL(const URL: string; var URLType, URLPath, URLParams: string);
|
||||
procedure SplitURL(const URL: string; out URLType, URLPath, URLParams: string);
|
||||
var
|
||||
Len: Integer;
|
||||
ColonPos: Integer;
|
||||
|
Loading…
Reference in New Issue
Block a user