2018-03-23 00:10:05 +00:00
|
|
|
{-----------------------------------------------------------------------------
|
|
|
|
The contents of this file are subject to the Mozilla Public License
|
|
|
|
Version 1.1 (the "License"); you may not use this file except in compliance
|
|
|
|
with the License. You may obtain A Copy of the License at
|
|
|
|
http://www.mozilla.org/MPL/MPL-1.1.html
|
|
|
|
|
|
|
|
Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for
|
|
|
|
the specific language governing rights and limitations under the License.
|
|
|
|
|
|
|
|
The Original Code is: JvThumbView.PAS, released on 2002-07-03.
|
|
|
|
|
|
|
|
The Initial Developer of the Original Code is John Kozikopulos [Stdreamer att Excite dott com]
|
|
|
|
Portions created by John Kozikopulos are Copyright (C) 2002 John Kozikopulos.
|
|
|
|
All Rights Reserved.
|
|
|
|
|
|
|
|
Contributor(s):
|
|
|
|
|
|
|
|
You may retrieve the latest version of this file at the Project JEDI's JVCL home page,
|
|
|
|
located at http://jvcl.delphi-jedi.org
|
|
|
|
|
|
|
|
Known Issues:
|
|
|
|
-----------------------------------------------------------------------------}
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
unit JvThumbViews;
|
|
|
|
|
|
|
|
{$MODE objfpc}{$H+}
|
|
|
|
//{$I windowsonly.inc}
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2018-04-20 11:17:15 +00:00
|
|
|
LCLIntf, LCLType, LMessages, Types,
|
2018-03-23 00:10:05 +00:00
|
|
|
Classes, Controls, Forms, ExtCtrls,
|
|
|
|
SysUtils, Graphics,
|
2018-08-26 14:25:44 +00:00
|
|
|
JvThumbnails, JvBaseThumbnail; //, JvExControls;
|
2018-03-23 00:10:05 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
// (rom) already in JvBaseThumbnail
|
|
|
|
//TPercent = 0..100;
|
|
|
|
TScrollMode = (smHorizontal, smVertical, smBoth);
|
|
|
|
TViewType = (vtNormal, vtCenter, vtFitToScreen);
|
|
|
|
// (rom) obviously unused
|
|
|
|
//TBufferAction = (bfCancel, bfCreate, bfOpen, bfInsert, bfReplace, bfDelete);
|
|
|
|
TTitleNotify = procedure(Sender: TObject; FileName: string;
|
|
|
|
var ThumbnailTitle: string; var ThumbnailFont: TFont;
|
|
|
|
var ThumbnailColor: TColor) of object;
|
|
|
|
TProgressStartNotify = procedure(Sender: TObject; Max: Integer) of object;
|
|
|
|
|
|
|
|
TJvThumbList = class(TStringList) // declare A new type of Thumblist and try not to Break the old code;
|
|
|
|
protected
|
|
|
|
function GetThumbnail(Index: Longint): TJvThumbnail;
|
|
|
|
public
|
|
|
|
property Thumbnail[Index: Longint]: TJvThumbnail read GetThumbnail; default;
|
|
|
|
end;
|
|
|
|
|
|
|
|
TJvThumbView = class(TJvBaseThumbView)
|
|
|
|
private
|
|
|
|
FAlignView: TViewType;
|
2018-03-24 22:02:34 +00:00
|
|
|
FAsButtons: Boolean;
|
|
|
|
FAutoHandleKeyb: Boolean;
|
|
|
|
FAutoScrolling: Boolean;
|
|
|
|
FDirectory: string;
|
|
|
|
FDiskSize: DWORD;
|
2018-03-23 00:10:05 +00:00
|
|
|
FFileList: TStringList;
|
|
|
|
FFileListSorted: TStringList;
|
|
|
|
FFilling: Boolean;
|
|
|
|
FFilter: string;
|
2018-03-24 22:02:34 +00:00
|
|
|
FGraphicExtensions: TStringList;
|
|
|
|
FMaxSize: TPoint;
|
|
|
|
FMaxX: Word;
|
|
|
|
FMinMemory: Boolean;
|
|
|
|
FPainted: Boolean;
|
|
|
|
FPercent: TPercent;
|
|
|
|
FScrollMode: TScrollMode;
|
|
|
|
FSelected: Longint;
|
|
|
|
FShadowColor: TColor;
|
|
|
|
FShowShadow: Boolean;
|
|
|
|
FSorted: Boolean;
|
2018-03-25 00:04:05 +00:00
|
|
|
FThumbBevelInner: TPanelBevel;
|
|
|
|
FThumbBevelOuter: TPanelBevel;
|
|
|
|
FThumbBorderStyle: TBorderStyle;
|
2018-03-23 00:10:05 +00:00
|
|
|
FThumbColor: TColor;
|
2020-01-17 23:29:41 +00:00
|
|
|
FThumbGap: Integer;
|
2018-03-24 22:02:34 +00:00
|
|
|
FThumbList: TJvThumbList;
|
|
|
|
FThumbSize: TPoint;
|
2018-03-25 00:04:05 +00:00
|
|
|
FThumbTitleBevelInner: TPanelBevel;
|
|
|
|
FThumbTitleBevelOuter: TPanelBevel;
|
|
|
|
FThumbTitleBorderStyle: TBorderStyle;
|
2018-03-23 23:59:33 +00:00
|
|
|
FThumbTitleColor: TColor;
|
2018-03-23 00:10:05 +00:00
|
|
|
FTitlePlacement: TTitlePos;
|
2018-03-24 22:02:34 +00:00
|
|
|
FWaitUntilFull: Boolean;
|
|
|
|
FOnChanging: TNotifyEvent;
|
|
|
|
FOnChange: TNotifyEvent;
|
|
|
|
FOnGetTitle: TTitleNotify;
|
|
|
|
FOnInvalidImage: TInvalidImageEvent;
|
2018-03-23 00:10:05 +00:00
|
|
|
FOnKeyDown: TKeyEvent;
|
|
|
|
FOnKeyPress: TKeyPressEvent;
|
2018-03-24 22:02:34 +00:00
|
|
|
FOnKeyUp: TKeyEvent;
|
|
|
|
FOnScanProgress: TProgressNotify;
|
|
|
|
FOnStartScanning: TProgressStartNotify;
|
|
|
|
FOnStopScanning: TNotifyEvent;
|
|
|
|
//FBufferFile: string;
|
|
|
|
//Dummy: string;
|
|
|
|
|
2018-03-23 00:10:05 +00:00
|
|
|
procedure CalculateMaxX;
|
|
|
|
procedure CalculateSize;
|
|
|
|
function CalculateXPos(Num: Word): Longint;
|
|
|
|
function CalculateYPos(Num: Word): Longint;
|
2018-03-24 22:02:34 +00:00
|
|
|
function CreateFilter: string;
|
|
|
|
procedure DoInvalidImage(Sender: TObject; const FileName: string);
|
|
|
|
function GetCount: Word;
|
|
|
|
procedure GetFiles(ADirectory: string);
|
|
|
|
function GetMaxHeight: Longint;
|
|
|
|
function GetMaxWidth: Longint;
|
2018-03-23 00:10:05 +00:00
|
|
|
procedure GoLeft;
|
|
|
|
procedure GoRight;
|
|
|
|
procedure GoDown;
|
|
|
|
procedure GoUp;
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure Reposition(Start: Integer);
|
|
|
|
procedure ScrollTo(const Number: Longint);
|
|
|
|
procedure SetAlignView(AType: TViewType);
|
2018-03-23 00:10:05 +00:00
|
|
|
procedure SetAsButton(const NewVal: Boolean);
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure SetFilters;
|
|
|
|
procedure SetPercent(P: TPercent);
|
|
|
|
procedure SetScrollMode(AMode: TScrollMode);
|
|
|
|
procedure SetSorted(const Value: Boolean);
|
2018-03-25 00:04:05 +00:00
|
|
|
procedure SetThumbBevelInner(const AValue: TPanelBevel);
|
|
|
|
procedure SetThumbBevelOuter(const AValue: TPanelBevel);
|
|
|
|
procedure SetThumbBorderStyle(const AValue: TBorderStyle);
|
2018-03-23 23:59:33 +00:00
|
|
|
procedure SetThumbColor(const AValue: TColor);
|
2020-01-17 23:29:41 +00:00
|
|
|
procedure SetThumbGap(Sp: Integer);
|
2018-03-23 23:59:33 +00:00
|
|
|
procedure SetThumbTitleColor(const AValue: TColor);
|
2018-03-25 00:04:05 +00:00
|
|
|
procedure SetThumbTitleBevelInner(const AValue: TPanelBevel);
|
|
|
|
procedure SetThumbTitleBevelOuter(const AValue: TPanelBevel);
|
|
|
|
procedure SetThumbTitleBorderStyle(const AValue: TBorderStyle);
|
2018-03-23 00:10:05 +00:00
|
|
|
procedure SetTitlePos(const NewVal: TTitlePos);
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure WMPaint(var Msg: TLMPaint); message LM_PAINT;
|
2018-03-23 00:10:05 +00:00
|
|
|
//function GetBufferName(AName: string): string;
|
2018-03-24 22:02:34 +00:00
|
|
|
//procedure WMLoadWhenReady(var Msg: TMessage); message WM_LOADWHENREADY;
|
|
|
|
|
2018-03-23 00:10:05 +00:00
|
|
|
protected
|
|
|
|
procedure CreateHandle; override;
|
2020-01-17 23:29:41 +00:00
|
|
|
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
|
|
|
|
const AXProportion, AYProportion: Double); override;
|
2018-03-23 00:10:05 +00:00
|
|
|
(*********** NOT CONVERTED **
|
|
|
|
procedure GetDlgCode(var Code: TDlgCodes); override;
|
|
|
|
*****)
|
2018-03-24 22:02:34 +00:00
|
|
|
function GetSelectedFile: string;
|
2018-03-23 00:10:05 +00:00
|
|
|
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure KeyPress(var Key: Char); override;
|
2018-03-23 00:10:05 +00:00
|
|
|
procedure KeyUp(var Key: Word; Shift: TShiftState); override;
|
|
|
|
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
|
|
|
|
X, Y: Integer); override;
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure Resize; override;
|
|
|
|
procedure SetDirectory(Value: string);
|
|
|
|
procedure SetMaxHeight(H: Longint);
|
|
|
|
procedure SetMaxWidth(W: Longint);
|
|
|
|
procedure SetSelected(Number: Longint);
|
|
|
|
procedure SetSelectedFile(AFile: string);
|
|
|
|
//function GetBufferFile: string;
|
|
|
|
//procedure SetBufferFile(NewName: string);
|
|
|
|
|
2018-03-23 00:10:05 +00:00
|
|
|
public
|
|
|
|
constructor Create(AOwner: TComponent); override;
|
|
|
|
destructor Destroy; override;
|
|
|
|
function AddFromFile(AFile: string) : Integer;
|
|
|
|
procedure AddFromStream(AStream: TStream; AType: TGRFKind); overload;
|
|
|
|
function AddFromStream(AStream: TStream; AType: TGRFKind; const aTitle: string): Integer; overload;
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure AddThumb(ATitle: string; Redraw: Boolean);
|
2018-03-23 00:10:05 +00:00
|
|
|
procedure Delete(No: Longint);
|
|
|
|
procedure EmptyList;
|
|
|
|
procedure Refresh;
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure SortList;
|
2018-03-23 00:10:05 +00:00
|
|
|
property ThumbList: TJvThumbList read FThumbList write FThumbList;
|
2018-03-23 18:43:14 +00:00
|
|
|
|
2018-03-23 00:10:05 +00:00
|
|
|
published
|
2019-11-20 11:05:08 +00:00
|
|
|
property AlignView: TViewType read FAlignView write SetAlignView default vtNormal;
|
|
|
|
property AsButtons: Boolean read FAsButtons write SetAsButton default false;
|
|
|
|
property AutoHandleKeyb: Boolean read FAutoHandleKeyb write FAutoHandleKeyb default true;
|
|
|
|
property AutoScrolling: Boolean read FAutoScrolling write FAutoScrolling default true;
|
2018-03-24 22:02:34 +00:00
|
|
|
//property BufferFile : String Read FBufferFile write SetBufferFile;
|
2018-03-23 00:10:05 +00:00
|
|
|
property Count: Word read GetCount default 0;
|
2018-03-24 22:02:34 +00:00
|
|
|
property Directory: string read FDirectory write SetDirectory;
|
|
|
|
property Filter: string read FFilter write FFilter;
|
2020-01-17 23:29:41 +00:00
|
|
|
property MaxHeight: Longint read GetMaxHeight write SetMaxHeight default 200;
|
|
|
|
property MaxWidth: Longint read GetMaxWidth write SetMaxWidth default 200;
|
2019-11-20 11:05:08 +00:00
|
|
|
property MinMemory: Boolean read FMinMemory write FMinMemory default true;
|
|
|
|
property ScrollMode: TScrollMode read FScrollMode write SetScrollMode default smHorizontal;
|
2018-03-23 00:10:05 +00:00
|
|
|
property Selected: Longint read FSelected write SetSelected default -1;
|
2018-03-24 22:02:34 +00:00
|
|
|
property SelectedFile: string read GetSelectedFile write SetSelectedFile;
|
2019-11-20 11:05:08 +00:00
|
|
|
property ShadowColor: TColor read FShadowColor write FShadowColor default clBlack;
|
|
|
|
property ShowShadow: Boolean read FShowShadow write FShowShadow default false;
|
|
|
|
property Size: TPercent read FPercent write SetPercent default 100;
|
2019-11-20 10:54:57 +00:00
|
|
|
property Sorted: Boolean read FSorted write SetSorted default true;
|
2018-03-25 00:04:05 +00:00
|
|
|
property ThumbBevelInner: TPanelBevel
|
|
|
|
read FThumbBevelInner write SetThumbBevelInner default bvNone;
|
|
|
|
property ThumbBevelOuter: TPanelBevel
|
|
|
|
read FThumbBevelOuter write SetThumbBevelOuter default bvRaised;
|
|
|
|
property ThumbBorderStyle: TBorderStyle
|
|
|
|
read FThumbBorderStyle write SetThumbBorderStyle default bsNone;
|
|
|
|
property ThumbColor: TColor
|
|
|
|
read FThumbColor write SetThumbColor default clDefault;
|
2020-01-17 23:29:41 +00:00
|
|
|
property ThumbGap: Integer
|
2018-03-25 00:04:05 +00:00
|
|
|
read FThumbGap write SetThumbGap default 4;
|
|
|
|
property ThumbTitleBevelInner: TPanelBevel
|
|
|
|
read FThumbTitleBevelInner write SetThumbTitleBevelInner default bvNone;
|
|
|
|
property ThumbTitleBevelOuter: TPanelBevel
|
|
|
|
read FThumbTitleBevelOuter write SetThumbTitleBevelOuter default bvLowered;
|
|
|
|
property ThumbTitleBorderStyle: TBorderStyle
|
|
|
|
read FThumbTitleBorderStyle write SetThumbTitleBorderStyle default bsNone;
|
|
|
|
property ThumbTitleColor: TColor
|
|
|
|
read FThumbTitleColor write SetThumbTitleColor default clDefault;
|
|
|
|
property TitlePlacement: TTitlePos
|
|
|
|
read FTitlePlacement write SetTitlePos default tpUp;
|
2018-03-24 22:02:34 +00:00
|
|
|
|
2018-03-23 00:10:05 +00:00
|
|
|
property OnChange: TNotifyEvent read FOnChange write FOnChange;
|
|
|
|
property OnChanging: TNotifyEvent read FOnChanging write FOnChanging;
|
2018-03-24 22:02:34 +00:00
|
|
|
property OnGetTitle: TTitleNotify read FOnGetTitle write FOnGetTitle;
|
|
|
|
property OnInvalidImage: TInvalidImageEvent read FOnInvalidImage write FOnInvalidImage;
|
2018-03-23 00:10:05 +00:00
|
|
|
property OnKeyDown: TKeyEvent read FOnKeyDown write FOnKeyDown;
|
|
|
|
property OnKeyPress: TKeyPressEvent read FOnKeyPress write FOnKeyPress;
|
2018-03-24 22:02:34 +00:00
|
|
|
property OnKeyUp: TKeyEvent read FOnKeyUp write FOnKeyUp;
|
|
|
|
property OnScanProgress: TProgressNotify read FOnScanProgress write FOnScanProgress;
|
|
|
|
property OnStartScanning: TProgressStartNotify read FOnStartScanning write FOnStartScanning;
|
|
|
|
property OnStopScanning: TNotifyEvent read FOnStopScanning write FOnStopScanning;
|
|
|
|
|
|
|
|
property Align;
|
2018-03-23 00:10:05 +00:00
|
|
|
property AutoScroll;
|
|
|
|
property BorderStyle;
|
|
|
|
property Color;
|
|
|
|
property Cursor;
|
|
|
|
property DragCursor;
|
|
|
|
property DragMode;
|
|
|
|
property Enabled;
|
2018-03-24 22:02:34 +00:00
|
|
|
property PopupMenu;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
|
|
|
JvConsts;
|
|
|
|
|
|
|
|
{const
|
|
|
|
FGraphicExtensions : array[1..9] of string = ('*.BMP','*.JPG','*.WMF','*.EMF',
|
|
|
|
'*.ICO','*.GIF','*.PCX',
|
|
|
|
'*.TGA','*.PNG'); }
|
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
{ TJvThumbView }
|
|
|
|
|
2018-03-23 00:10:05 +00:00
|
|
|
constructor TJvThumbView.Create(AOwner: TComponent);
|
|
|
|
begin
|
|
|
|
FMaxSize.X := 200;
|
|
|
|
FMaxSize.Y := 200;
|
|
|
|
|
|
|
|
inherited Create(AOwner);
|
|
|
|
|
|
|
|
TabStop := True;
|
|
|
|
FPainted := False;
|
|
|
|
Width := 600;
|
|
|
|
Height := 480;
|
|
|
|
FPercent := 100;
|
|
|
|
FThumbGap := 4;
|
|
|
|
VertScrollBar.Tracking := True;
|
|
|
|
HorzScrollBar.Tracking := True;
|
|
|
|
FScrollMode := smHorizontal;
|
|
|
|
Caption := '';
|
|
|
|
CalculateSize;
|
|
|
|
FWaitUntilFull := False;
|
|
|
|
FFilling := False;
|
|
|
|
FSorted := True;
|
|
|
|
FMinMemory := True;
|
|
|
|
FSelected := -1;
|
|
|
|
AutoScrolling := True;
|
|
|
|
FDiskSize := 0;
|
|
|
|
FAutoHandleKeyb := True;
|
|
|
|
FFilter := CreateFilter;
|
|
|
|
FThumbList := TJvThumbList.Create;
|
|
|
|
FThumbList.Sorted := Sorted;
|
|
|
|
FFileList := TStringList.Create;
|
|
|
|
FFileList.Clear;
|
|
|
|
FFileListSorted := TStringList.Create;
|
|
|
|
FFileListSorted.Clear;
|
2018-03-25 00:04:05 +00:00
|
|
|
FThumbBevelInner := bvNone;
|
|
|
|
FThumbBevelOuter := bvRaised;
|
|
|
|
FThumbBorderStyle := bsNone;
|
2018-03-23 23:59:33 +00:00
|
|
|
FThumbColor := clDefault;
|
2018-03-25 00:04:05 +00:00
|
|
|
FThumbTitleColor := clDefault;
|
|
|
|
FThumbTitleBevelInner := bvNone;
|
|
|
|
FThumbTitleBevelOuter := bvLowered;
|
|
|
|
FThumbTitleBorderStyle := bsNone;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
destructor TJvThumbView.Destroy;
|
|
|
|
begin
|
|
|
|
FreeAndNil(FFileListSorted);
|
|
|
|
FreeAndNil(FFileList);
|
|
|
|
FreeAndNil(FThumbList);
|
|
|
|
//FreeAndNil(FFilter);
|
|
|
|
inherited Destroy;
|
|
|
|
end;
|
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
function TJvThumbView.AddFromFile(AFile: string) : Integer;
|
|
|
|
var
|
|
|
|
ThumbnailTitle: string;
|
|
|
|
FFont: TFont;
|
|
|
|
FColor: TColor;
|
|
|
|
Thb: TJvThumbnail;
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
Thb := TJvThumbnail.Create(Self);
|
2020-01-17 23:29:41 +00:00
|
|
|
Thb.AutoAdjustlayout(lapAutoAdjustForDPI, 96, Font.PixelsPerInch, 0, 0);
|
2018-03-24 22:02:34 +00:00
|
|
|
if Assigned(FOnGetTitle) then
|
|
|
|
begin
|
|
|
|
ThumbnailTitle := ExtractFilename(AFile);
|
|
|
|
FFont := TFont.Create;
|
|
|
|
FColor := clBtnFace;
|
|
|
|
if Assigned(FOnGetTitle) then
|
|
|
|
FOnGetTitle(Self, AFile, ThumbnailTitle, FFont, FColor);
|
|
|
|
Thb.SetTitlePanel(ThumbnailTitle, FFont, FColor);
|
|
|
|
FreeAndNil(FFont);
|
|
|
|
end;
|
|
|
|
Thb.OnClick := OnClick;
|
|
|
|
Thb.Photo.OnClick := OnClick;
|
|
|
|
Thb.OnDblClick := OnDblClick;
|
|
|
|
Thb.Photo.OnDblClick := OnDblClick;
|
|
|
|
Thb.MinimizeMemory := MinMemory;
|
2019-11-20 10:54:57 +00:00
|
|
|
Thb.BevelInner := ThumbBevelInner;
|
|
|
|
Thb.BevelOuter := ThumbBevelouter;
|
|
|
|
Thb.BorderStyle := ThumbBorderStyle;
|
|
|
|
Thb.TitleBevelOuter := ThumbTitleBevelOuter;
|
|
|
|
Thb.TitleBevelInner := ThumbTitleBevelInner;
|
|
|
|
Thb.TitleBorderStyle := ThumbTitleBorderStyle;
|
2018-03-24 22:02:34 +00:00
|
|
|
if FThumbColor = clDefault then
|
|
|
|
begin
|
|
|
|
Thb.Color := Self.Color;
|
|
|
|
Thb.ParentColor := True;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
Thb.Color := FThumbColor;
|
|
|
|
if FThumbTitleColor = clDefault then
|
|
|
|
Thb.TitleColor := Self.Color
|
|
|
|
else
|
|
|
|
Thb.TitleColor := FThumbTitleColor;
|
|
|
|
|
|
|
|
// Thb.Buffer := VBuffer;
|
|
|
|
FThumbList.AddObject(AFile, Thb);
|
|
|
|
InsertControl(Thb);
|
2018-03-23 00:10:05 +00:00
|
|
|
CalculateSize;
|
2018-03-24 22:02:34 +00:00
|
|
|
Reposition(0);
|
|
|
|
TJvThumbnail(FThumbList.Objects[FThumbList.IndexOf(AFile)]).FileName := AFile;
|
|
|
|
result := FThumbList.IndexOf(AFile);
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure TJvThumbView.AddFromStream(AStream: TStream; AType: TGRFKind);
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
AddFromStream(AStream, AType, '');
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TJvThumbView.AddFromStream(AStream: TStream; AType: TGRFKind;
|
|
|
|
const ATitle: string): Integer;
|
|
|
|
var
|
|
|
|
Thb: TJvThumbnail;
|
|
|
|
begin
|
|
|
|
Thb := TJvThumbnail.Create(Self);
|
|
|
|
Thb.StreamFileType := AType;
|
|
|
|
Thb.Left := CalculateXPos(Count + 1);
|
|
|
|
Thb.Top := CalculateYPos(Count + 1);
|
|
|
|
Thb.Width := FThumbSize.X;
|
|
|
|
Thb.Height := FThumbSize.Y;
|
|
|
|
Thb.OnClick := OnClick;
|
|
|
|
Thb.Photo.OnClick := OnClick;
|
|
|
|
Thb.OnDblClick := OnDblClick;
|
2019-11-20 10:54:57 +00:00
|
|
|
Thb.MinimizeMemory := MinMemory;
|
2018-03-24 22:02:34 +00:00
|
|
|
Thb.Title := aTitle;
|
|
|
|
Thb.Photo.OnDblClick := OnDblClick;
|
2019-11-20 10:54:57 +00:00
|
|
|
Thb.BevelInner := ThumbBevelInner;
|
|
|
|
Thb.BevelOuter := ThumbBevelouter;
|
|
|
|
Thb.BorderStyle := ThumbBorderStyle;
|
|
|
|
Thb.TitleBevelOuter := ThumbTitleBevelOuter;
|
|
|
|
Thb.TitleBevelInner := ThumbTitleBevelInner;
|
|
|
|
Thb.TitleBorderStyle := ThumbTitleBorderStyle;
|
2018-03-24 22:02:34 +00:00
|
|
|
if FThumbColor = clDefault then
|
|
|
|
begin
|
|
|
|
Thb.Color := Self.Color;
|
|
|
|
Thb.ParentColor := True;
|
|
|
|
end else
|
|
|
|
Thb.Color := FThumbColor;
|
|
|
|
if FThumbTitleColor = clDefault then
|
|
|
|
Thb.TitleColor := Self.Color
|
|
|
|
else
|
|
|
|
Thb.TitleColor := FThumbTitleColor;
|
|
|
|
// Thb.Buffer := Vbuffer;
|
|
|
|
Thb.Photo.LoadFromStream(AStream, Thb.StreamFileType);
|
|
|
|
Result := FThumbList.AddObject(Thb.Title, Thb);
|
|
|
|
InsertControl(Thb);
|
|
|
|
CalculateSize;
|
|
|
|
Reposition(Result);
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TJvThumbView.AddThumb(ATitle: string; Redraw: Boolean);
|
|
|
|
var
|
|
|
|
Thb: TJvThumbnail;
|
|
|
|
begin
|
|
|
|
Thb := TJvThumbnail.Create(Self);
|
|
|
|
Thb.Left := CalculateXPos(Count + 1);
|
|
|
|
Thb.Top := CalculateYPos(Count + 1);
|
|
|
|
Thb.Width := FThumbSize.X;
|
|
|
|
Thb.Height := FThumbSize.Y;
|
|
|
|
Thb.AsButton := FAsButtons;
|
|
|
|
Thb.TitlePlacement := FTitlePlacement;
|
|
|
|
Thb.ShadowColor := FShadowColor;
|
|
|
|
Thb.ShowShadow := FShowShadow;
|
|
|
|
Thb.OnClick := OnClick;
|
|
|
|
Thb.Photo.OnClick := OnClick;
|
|
|
|
Thb.Photo.OnInvalidImage := @DoInvalidImage;
|
|
|
|
Thb.OnDblClick := OnDblClick;
|
|
|
|
Thb.Photo.OnDblClick := OnDblClick;
|
|
|
|
Thb.MinimizeMemory := MinMemory;
|
|
|
|
Thb.Title := ATitle;
|
2019-11-20 10:54:57 +00:00
|
|
|
Thb.BevelInner := ThumbBevelInner;
|
|
|
|
Thb.BevelOuter := ThumbBevelouter;
|
|
|
|
Thb.BorderStyle := ThumbBorderStyle;
|
|
|
|
Thb.TitleBevelOuter := ThumbTitleBevelOuter;
|
|
|
|
Thb.TitleBevelInner := ThumbTitleBevelInner;
|
|
|
|
Thb.TitleBorderStyle := ThumbTitleBorderStyle;
|
2018-03-23 23:59:33 +00:00
|
|
|
if FThumbColor = clDefault then
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
|
|
|
Thb.Color := Self.Color;
|
|
|
|
Thb.ParentColor := True;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
Thb.Color := FThumbColor;
|
2018-03-23 23:59:33 +00:00
|
|
|
if FThumbTitleColor = clDefault then
|
|
|
|
Thb.TitleColor := Self.Color
|
|
|
|
else
|
|
|
|
Thb.TitleColor := FThumbTitleColor;
|
2018-03-23 00:10:05 +00:00
|
|
|
FThumbList.AddObject(Thb.Title, Thb);
|
|
|
|
Thb.Parent := Self;
|
|
|
|
if Redraw then
|
|
|
|
begin
|
|
|
|
CalculateSize;
|
|
|
|
Reposition(0);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure TJvThumbView.CalculateMaxX;
|
2018-03-23 00:10:05 +00:00
|
|
|
var
|
2018-03-24 22:02:34 +00:00
|
|
|
A: Longint;
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
case FScrollMode of
|
|
|
|
smVertical:
|
|
|
|
A := (Width - 20) div (FThumbSize.X + FThumbGap);
|
|
|
|
smHorizontal:
|
|
|
|
A := (Height - 20) div (FThumbSize.Y + FThumbGap);
|
|
|
|
smBoth:
|
|
|
|
A := JkCeil(Sqrt(FThumbList.Count));
|
2020-01-17 23:29:41 +00:00
|
|
|
else
|
|
|
|
A := 1;
|
2018-03-24 22:02:34 +00:00
|
|
|
end;
|
|
|
|
if A < 1 then
|
|
|
|
A := 1;
|
|
|
|
if A <> FMaxX then
|
|
|
|
FMaxX := A;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TJvThumbView.CalculateSize;
|
|
|
|
begin
|
|
|
|
FThumbSize.X := Trunc((MaxWidth / 100.0) * Size);
|
|
|
|
FThumbSize.Y := Trunc((MaxHeight / 100.0) * Size);
|
|
|
|
CalculateMaxX;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TJvThumbView.CalculateXPos(Num: Word): Longint;
|
|
|
|
var
|
|
|
|
VPos, HPos: Longint;
|
|
|
|
Temp: Longint;
|
|
|
|
Tmp: Longint;
|
|
|
|
Spact: Longint;
|
|
|
|
begin
|
|
|
|
if Num > 0 then
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
Spact := FThumbGap;
|
|
|
|
case FScrollMode of
|
|
|
|
smVertical, smBoth:
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
if (FAlignView = vtFitToScreen) and (FScrollMode = smVertical) then
|
|
|
|
Spact := ((Width - 20) - (FThumbSize.X * FMaxX)) div (FMaxX + 1);
|
|
|
|
VPos := JkCeil(Num / FMaxX);
|
|
|
|
HPos := (Num - (VPos * FMaxX)) + FMaxX;
|
|
|
|
Temp := (FThumbSize.X * (HPos - 1)) + (HPos * Spact);
|
|
|
|
if (FAlignView = vtCenter) and (FScrollMode = smVertical) then
|
|
|
|
begin
|
|
|
|
Tmp := ((Width - 20) div 2) - (((FThumbSize.X + FThumbGap) * FMaxX) div 2);
|
|
|
|
Temp := Temp + Tmp;
|
|
|
|
end;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
2018-03-24 22:02:34 +00:00
|
|
|
smHorizontal:
|
|
|
|
begin
|
|
|
|
VPos := JkCeil(Num / FMaxX);
|
|
|
|
Temp := (FThumbSize.Y * (VPos - 1)) + (VPos * Spact);
|
|
|
|
end
|
|
|
|
else
|
|
|
|
Temp := 0
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
2018-03-24 22:02:34 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
Temp := 0;
|
|
|
|
Result := Temp;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
function TJvThumbView.CalculateYPos(Num: Word): Longint;
|
|
|
|
var
|
|
|
|
VPos, HPos: Longint;
|
|
|
|
Temp: Longint;
|
|
|
|
Tmp: Longint;
|
|
|
|
Spact: Longint;
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
if Num > 0 then
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
Spact := FThumbGap;
|
|
|
|
case FScrollMode of
|
|
|
|
smVertical, smBoth:
|
|
|
|
begin
|
|
|
|
VPos := JkCeil(Num / FMaxX);
|
|
|
|
Temp := (FThumbSize.Y * (VPos - 1)) + (VPos * Spact);
|
|
|
|
end;
|
|
|
|
smHorizontal:
|
|
|
|
begin
|
|
|
|
if FAlignView = vtFitToScreen then
|
|
|
|
Spact := ((Height - 20) - ((FThumbSize.Y + FThumbGap) * FMaxX)) div (FMaxX + 1);
|
|
|
|
HPos := JkCeil(Num / FMaxX);
|
|
|
|
VPos := (Num - (HPos * FMaxX)) + FMaxX;
|
|
|
|
Temp := (FThumbSize.X * (VPos - 1)) + (VPos * Spact);
|
|
|
|
if FAlignView = vtCenter then
|
|
|
|
begin
|
|
|
|
Tmp := ((Height - 20) div 2) - ((FThumbSize.Y * FMaxX) div 2);
|
|
|
|
Temp := Temp + Tmp;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
else
|
|
|
|
Temp := 0;
|
|
|
|
end;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
Temp := 0;
|
|
|
|
Result := Temp;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure TJvThumbView.CreateHandle;
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
CalculateSize;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TJvThumbView.CreateFilter: string;
|
|
|
|
//var
|
|
|
|
// Res: string;
|
|
|
|
// Pos: Longint;
|
|
|
|
begin
|
|
|
|
Result := GraphicFilter(TGraphic);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TJvThumbView.Delete(No: Longint);
|
2018-03-23 00:10:05 +00:00
|
|
|
var
|
2018-03-24 22:02:34 +00:00
|
|
|
Dummy: Longint;
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
if No >= FThumbList.Count then
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
end //Raise an exception
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
Dummy := FFileList.IndexOf(SelectedFile);
|
|
|
|
if Dummy >= 0 then
|
|
|
|
FFileList.Delete(Dummy);
|
|
|
|
Dummy := FFileListSorted.IndexOf(SelectedFile);
|
|
|
|
if Dummy >= 0 then
|
|
|
|
FFileListSorted.Delete(Dummy);
|
|
|
|
TJvThumbnail(FThumbList.Objects[No]).Free;
|
|
|
|
FThumbList.Delete(No);
|
|
|
|
FSelected := -1;
|
|
|
|
//CalculateSize;
|
|
|
|
Dec(No, 1);
|
|
|
|
if No < 0 then
|
|
|
|
No := 0;
|
|
|
|
Reposition(No);
|
|
|
|
Refresh;
|
|
|
|
Repaint;
|
|
|
|
end
|
|
|
|
end;
|
|
|
|
|
2020-01-17 23:29:41 +00:00
|
|
|
procedure TJvThumbView.DoAutoAdjustLayout(
|
|
|
|
const AMode: TLayoutAdjustmentPolicy;
|
|
|
|
const AXProportion, AYProportion: Double);
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
|
|
|
|
begin
|
|
|
|
FMaxSize.X := round(FMaxSize.X * AXProportion);
|
|
|
|
FMaxSize.Y := round(FMaxSize.Y * AYProportion);
|
|
|
|
FThumbGap := round(FThumbGap * AXProportion);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure TJvThumbView.DoInvalidImage(Sender: TObject; const FileName: string);
|
|
|
|
begin
|
|
|
|
if Assigned(FOnInvalidImage) then
|
|
|
|
FOnInvalidImage(Sender, FileName);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TJvThumbView.EmptyList;
|
|
|
|
var
|
|
|
|
Metr: Integer;
|
|
|
|
begin
|
|
|
|
for Metr := Count - 1 downto 0 do
|
|
|
|
if FThumbList.Objects[Metr] <> nil then
|
|
|
|
begin
|
|
|
|
TJvThumbnail(FThumbList.Objects[Metr]).Parent := nil;
|
|
|
|
TJvThumbnail(FThumbList.Objects[Metr]).Free;
|
|
|
|
FThumbList.Delete(Metr);
|
|
|
|
end;
|
|
|
|
FSelected := -1; // Mantis #5140
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
(*
|
|
|
|
function TJvThumbView.GetBufferName(AName: string): string;
|
|
|
|
var
|
|
|
|
tst: string;
|
|
|
|
FN: string;
|
|
|
|
Res: string;
|
|
|
|
begin
|
|
|
|
tst := completepath(extractFiledir(AName));
|
|
|
|
if tst = AName then
|
|
|
|
begin // No FileName included only A Directory;
|
|
|
|
// the user wants us to Create A seperate file for each
|
|
|
|
// Directory it opens in A pre-specified path
|
|
|
|
FN := ReplaceChar(FDirectory, '\', '_', 0, False); //Create the FileName from the path
|
|
|
|
FN := ReplaceChar(FN, ':', '_', 0, False); //Create the FileName from the path
|
|
|
|
Res := AName + fn;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin // the user has specified either A full path and A name or just A name
|
|
|
|
if tst = '' then
|
|
|
|
// the user has specified only A name to use
|
|
|
|
// in each Directory that is opened by the component there will be created
|
|
|
|
// A file with name <ANAME> where the thumbs are been saved;
|
|
|
|
Res := CompletePath(FDirectory) + AName
|
|
|
|
else
|
|
|
|
// the user has specified A full path and A file name weach is the same
|
|
|
|
// for all the directories he/she opens.
|
|
|
|
Res := AName;
|
|
|
|
end;
|
|
|
|
Result := Res;
|
|
|
|
end;
|
|
|
|
*)
|
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
function TJvThumbView.GetCount: Word;
|
|
|
|
begin
|
|
|
|
Result := FThumbList.Count;
|
|
|
|
end;
|
2018-03-23 00:10:05 +00:00
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
(************* NOT CONVERTED
|
|
|
|
procedure TJvThumbView.GetDlgCode(var Code: TDlgCodes);
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
Code := [dcWantArrows, dcWantAllKeys];
|
|
|
|
end;
|
|
|
|
************)
|
2018-03-23 00:10:05 +00:00
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure TJvThumbView.GetFiles(ADirectory: string);
|
|
|
|
var
|
|
|
|
SearchRec: TSearchRec;
|
|
|
|
FResult: Integer;
|
|
|
|
NumExtensions: Integer;
|
|
|
|
|
|
|
|
function FindFirstGraphic(AExtension: string): Integer;
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
// (rom) strange flag faArchive
|
|
|
|
FindFirstGraphic :=
|
|
|
|
FindFirst(ADirectory + AExtension, faArchive, SearchRec);
|
|
|
|
end;
|
|
|
|
|
|
|
|
begin
|
|
|
|
FFileList.Clear;
|
|
|
|
FFileListSorted.Clear;
|
|
|
|
SetFilters;
|
|
|
|
if not DirectoryExists(ADirectory) then
|
|
|
|
Exit;
|
|
|
|
if ADirectory[Length(ADirectory)] <> PathDelim then
|
|
|
|
ADirectory := ADirectory + PathDelim;
|
|
|
|
for NumExtensions := 0 to FGraphicExtensions.Count - 1 do
|
|
|
|
begin
|
|
|
|
if (FindFirstGraphic(FGraphicExtensions[NumExtensions]) = 0) then
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
try
|
|
|
|
if (FFileList.IndexOf(ADirectory + SearchRec.Name) < 0) then
|
|
|
|
begin
|
|
|
|
FFileList.Add(ADirectory + SearchRec.Name);
|
|
|
|
FFileListSorted.Add(ADirectory + SearchRec.Name);
|
|
|
|
repeat
|
|
|
|
FResult := FindNext(SearchRec);
|
|
|
|
if (FResult = 0) and (FFileList.IndexOf(ADirectory + SearchRec.Name) < 0) then
|
|
|
|
begin
|
|
|
|
FFileList.Add(ADirectory + SearchRec.Name);
|
|
|
|
FFileListSorted.Add(ADirectory + SearchRec.Name);
|
|
|
|
end;
|
|
|
|
until FResult <> 0;
|
|
|
|
end;
|
|
|
|
finally
|
|
|
|
FindClose(SearchRec);
|
|
|
|
end;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
2018-03-24 22:02:34 +00:00
|
|
|
end;
|
|
|
|
FFileListSorted.Sort;
|
|
|
|
if Assigned(FGraphicExtensions) then
|
|
|
|
FreeAndNil(FGraphicExtensions);
|
|
|
|
end;
|
2018-03-23 00:10:05 +00:00
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
function TJvThumbView.GetMaxHeight: Longint;
|
|
|
|
begin
|
|
|
|
Result := FMaxSize.Y;
|
|
|
|
end;
|
2018-03-23 00:10:05 +00:00
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
function TJvThumbView.GetMaxWidth: Longint;
|
|
|
|
begin
|
|
|
|
Result := FMaxSize.X;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TJvThumbView.GetSelectedFile: String;
|
|
|
|
begin
|
|
|
|
if Selected <> -1 then
|
|
|
|
Result := TJvThumbnail(FThumbList.Objects[Selected]).FileName;
|
|
|
|
end;
|
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure TJvThumbView.GoDown;
|
2018-03-23 00:10:05 +00:00
|
|
|
var
|
2018-03-24 22:02:34 +00:00
|
|
|
Actual: Longint;
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
Actual := 0;
|
|
|
|
if ScrollMode = smHorizontal then
|
|
|
|
Actual := Selected + 1;
|
|
|
|
if (ScrollMode = smVertical) or (ScrollMode = smBoth) then
|
|
|
|
Actual := Selected + FMaxX;
|
|
|
|
if (Actual > Count - 1) or (Actual < 0) then
|
|
|
|
Actual := Selected;
|
|
|
|
Selected := Actual;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure TJvThumbView.GoLeft;
|
2018-03-23 00:10:05 +00:00
|
|
|
var
|
2018-03-24 22:02:34 +00:00
|
|
|
Actual: Longint;
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
Actual := 0;
|
|
|
|
if ScrollMode = smHorizontal then
|
|
|
|
Actual := Selected - FMaxX;
|
|
|
|
if (ScrollMode = smVertical) or (ScrollMode = smBoth) then
|
|
|
|
Actual := Selected - 1;
|
|
|
|
if (Actual > Count - 1) or (Actual < 0) then
|
|
|
|
Actual := Selected;
|
|
|
|
Selected := Actual;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure TJvThumbView.GoRight;
|
2018-03-23 00:10:05 +00:00
|
|
|
var
|
2018-03-24 22:02:34 +00:00
|
|
|
Actual: Longint;
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
Actual := 0;
|
|
|
|
if ScrollMode = smHorizontal then
|
|
|
|
Actual := Selected + FMaxX;
|
|
|
|
if (ScrollMode = smVertical) or (ScrollMode = smBoth) then
|
|
|
|
Actual := Selected + 1;
|
|
|
|
if (Actual > Count - 1) or (Actual < 0) then
|
|
|
|
Actual := Selected;
|
|
|
|
Selected := Actual;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure TJvThumbView.GoUp;
|
2018-03-23 00:10:05 +00:00
|
|
|
var
|
2018-03-24 22:02:34 +00:00
|
|
|
Actual: Longint;
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
Actual := 0;
|
|
|
|
if ScrollMode = smHorizontal then
|
|
|
|
Actual := Selected - 1;
|
|
|
|
if (ScrollMode = smVertical) or (ScrollMode = smBoth) then
|
|
|
|
Actual := Selected - FMaxX;
|
|
|
|
if (Actual > Count - 1) or (Actual < 0) then
|
|
|
|
Actual := Selected;
|
|
|
|
Selected := Actual;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure TJvThumbView.KeyDown(var Key: Word; Shift: TShiftState);
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
if AutoHandleKeyb and (FThumbList.Count > 0) then
|
|
|
|
case Key of
|
|
|
|
VK_RIGHT:
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
GoRight;
|
|
|
|
ScrollTo(Selected);
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
2018-03-24 22:02:34 +00:00
|
|
|
VK_DOWN:
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
GoDown;
|
|
|
|
ScrollTo(Selected);
|
|
|
|
end;
|
|
|
|
VK_LEFT:
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
GoLeft;
|
|
|
|
ScrollTo(Selected);
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
2018-03-24 22:02:34 +00:00
|
|
|
VK_UP:
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
GoUp;
|
|
|
|
ScrollTo(Selected);
|
|
|
|
end;
|
|
|
|
VK_DELETE:
|
|
|
|
begin
|
|
|
|
end;
|
|
|
|
VK_PRIOR:
|
|
|
|
begin
|
|
|
|
end;
|
|
|
|
VK_NEXT:
|
|
|
|
begin
|
|
|
|
end;
|
|
|
|
VK_END:
|
|
|
|
begin
|
|
|
|
Selected := Count - 1;
|
|
|
|
ScrollTo(Selected);
|
|
|
|
end;
|
|
|
|
VK_HOME:
|
|
|
|
begin
|
|
|
|
Selected := 0;
|
|
|
|
ScrollTo(Selected);
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
end;
|
2018-03-24 22:02:34 +00:00
|
|
|
inherited KeyDown(Key, Shift);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TJvThumbView.KeyPress(var Key: Char);
|
|
|
|
begin
|
|
|
|
if Assigned(FOnKeyPress) then
|
|
|
|
FOnKeyPress(Self, Key);
|
|
|
|
inherited KeyPress(Key);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TJvThumbView.KeyUp(var Key: Word; Shift: TShiftState);
|
|
|
|
begin
|
|
|
|
if Assigned(FOnKeyUp) then
|
|
|
|
FOnKeyUp(Self, Key, Shift);
|
|
|
|
inherited KeyUp(Key, Shift);
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TJvThumbView.MouseDown(Button: TMouseButton; Shift: TShiftState;
|
|
|
|
X, Y: Integer);
|
|
|
|
var
|
2018-08-26 14:25:44 +00:00
|
|
|
SelNo, No: Integer;
|
2018-03-23 00:10:05 +00:00
|
|
|
TempX, TempY: Longint;
|
2018-03-23 18:43:14 +00:00
|
|
|
thumb: TJvThumbnail;
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
|
|
|
// Check to see if there are any problems removing the following
|
|
|
|
// For sure it solves A focus problem I'm having in an application
|
2018-03-23 18:43:14 +00:00
|
|
|
// setfocus;
|
|
|
|
if Count > 0 then begin
|
|
|
|
SelNo := -1;
|
2018-04-21 14:46:46 +00:00
|
|
|
No := -1;
|
2018-03-23 00:10:05 +00:00
|
|
|
case ScrollMode of
|
|
|
|
smVertical, smBoth:
|
|
|
|
begin
|
2018-03-23 18:43:14 +00:00
|
|
|
TempX := trunc(X / (FThumbSize.X + FThumbGap));
|
|
|
|
TempY := trunc(Y / (FThumbSize.Y + FThumbGap));
|
|
|
|
if TempX >= FMaxX then TempX := FMaxX - 1;
|
|
|
|
if TempY < 0 then TempY := 0;
|
|
|
|
No := TempY * FMaxX + TempX;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
smHorizontal:
|
|
|
|
begin
|
2018-03-23 18:43:14 +00:00
|
|
|
TempX := trunc(X / (FThumbSize.X + FThumbGap));
|
|
|
|
TempY := trunc(Y / (FThumbSize.Y + FThumbGap));
|
|
|
|
if TempY >= FMaxX then TempY := FMaxX - 1;
|
|
|
|
if TempX < 0 then TempX := 0;
|
2018-03-24 22:02:34 +00:00
|
|
|
No := TempX * FMaxX + TempY;
|
|
|
|
end;
|
|
|
|
end;
|
2018-04-21 14:46:46 +00:00
|
|
|
if (No > -1) and (No < Count) then begin
|
|
|
|
thumb := FThumblist.Thumbnail[No];
|
|
|
|
if thumb <> nil then
|
|
|
|
if InRange(thumb.Left, thumb.Left + thumb.Width, X) and
|
|
|
|
InRange(thumb.Top, thumb.Top + thumb.Height, Y)
|
|
|
|
then
|
|
|
|
SelNo := No;
|
|
|
|
end;
|
2018-03-24 22:02:34 +00:00
|
|
|
SetSelected(SelNo);
|
|
|
|
end;
|
|
|
|
inherited MouseDown(Button, Shift, X, Y);
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TJvThumbView.Refresh;
|
|
|
|
var
|
|
|
|
I: Longint;
|
|
|
|
begin
|
|
|
|
CalculateSize;
|
|
|
|
Reposition(0);
|
|
|
|
for I := 0 to FThumbList.Count - 1 do
|
|
|
|
FThumbList.Thumbnail[I].Refresh;
|
|
|
|
inherited Refresh;
|
|
|
|
end;
|
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure TJvThumbView.Reposition(Start: Integer);
|
2018-03-23 00:10:05 +00:00
|
|
|
var
|
2018-03-24 22:02:34 +00:00
|
|
|
I: Integer;
|
|
|
|
Tmp1: Longint;
|
|
|
|
Tmp2: Longint;
|
|
|
|
thumb: TJvThumbnail;
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
if FThumbList = nil then
|
|
|
|
exit;
|
|
|
|
|
|
|
|
Tmp2 := HorzScrollBar.Position;
|
|
|
|
HorzScrollBar.Position := 0;
|
|
|
|
Tmp1 := VertScrollBar.Position;
|
|
|
|
VertScrollBar.Position := 0;
|
|
|
|
for I := Start to FThumbList.Count - 1 do
|
|
|
|
begin
|
|
|
|
thumb := FThumbList.Thumbnail[I]; //TJvThumbnail(FThumbList.Objects[I]);
|
|
|
|
if thumb <> nil then
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2019-11-20 10:54:57 +00:00
|
|
|
thumb.SetBounds(CalculateXPos(I + 1), CalculateYPos(I + 1), FThumbSize.X, FThumbSize.Y);
|
|
|
|
{
|
2018-03-24 22:02:34 +00:00
|
|
|
thumb.Left := CalculateXPos(I + 1);
|
|
|
|
thumb.Top := CalculateYPos(I + 1);
|
|
|
|
thumb.Width := FThumbSize.X;
|
|
|
|
thumb.Height := FThumbSize.Y;
|
2019-11-20 10:54:57 +00:00
|
|
|
}
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
2018-03-24 22:02:34 +00:00
|
|
|
end;
|
|
|
|
HorzScrollBar.Position := Tmp2;
|
|
|
|
VertScrollBar.Position := Tmp1;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TJvThumbView.Resize;
|
|
|
|
begin
|
2020-01-17 23:29:41 +00:00
|
|
|
if HandleAllocated then
|
|
|
|
begin
|
|
|
|
CalculateMaxX;
|
|
|
|
Reposition(0);
|
|
|
|
end;
|
2018-03-23 00:10:05 +00:00
|
|
|
inherited Resize;
|
|
|
|
end;
|
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure TJvThumbView.ScrollTo(const Number: Longint);
|
|
|
|
var
|
|
|
|
TN: TJvThumbnail;
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
// if AutoScrolling then
|
|
|
|
if (Number < 0) or (Number >= FThumbList.Count) then
|
|
|
|
Exit;
|
|
|
|
TN := FThumbList.Thumbnail[Number];
|
|
|
|
case ScrollMode of
|
|
|
|
smVertical:
|
|
|
|
begin
|
|
|
|
if TN.Top - VertScrollbar.Position < 0 then
|
|
|
|
VertScrollBar.Position := TN.Top - TN.Width div 2;
|
|
|
|
if TN.Top + TN.Height - VertScrollbar.Position > Height then
|
|
|
|
VertScrollBar.Position := TN.Top + TN.Height - (Height - TN.Height div 2);
|
|
|
|
end;
|
|
|
|
smHorizontal:
|
|
|
|
begin
|
|
|
|
if TN.Left - HorzScrollbar.Position < 0 then
|
|
|
|
HorzScrollBar.Position := TN.Left - TN.Width div 2;
|
|
|
|
if TN.Left + TN.Width - HorzScrollbar.Position > Width then
|
|
|
|
HorzScrollBar.Position := TN.Left + TN.Width - (Width - TN.Width div 2);
|
|
|
|
end;
|
|
|
|
smBoth:
|
|
|
|
begin
|
|
|
|
if TN.Top < VertScrollbar.Position then
|
|
|
|
VertScrollBar.Position := TN.Top - TN.Width div 2;
|
|
|
|
if TN.Top + TN.Height > VertScrollbar.Position + Height then
|
|
|
|
VertScrollBar.Position := TN.Top + TN.Height - (Height - TN.Height div 2);
|
|
|
|
if TN.Left - HorzScrollbar.Position < 0 then
|
|
|
|
HorzScrollBar.Position := TN.Left - TN.Width div 2;
|
|
|
|
if TN.Left + TN.Width - HorzScrollbar.Position > Width then
|
|
|
|
HorzScrollBar.Position := TN.Left + TN.Width - (Width - (TN.Width div 2));
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
if FSelected <> Number then
|
|
|
|
begin
|
|
|
|
FSelected := Number;
|
|
|
|
if Assigned(OnClick) then
|
|
|
|
OnClick(Self);
|
|
|
|
end;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure TJvThumbView.SetAlignView(AType: TViewType);
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
if AType <> FAlignView then
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
FAlignView := AType;
|
|
|
|
Reposition(0);
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure TJvThumbView.SetAsButton(const NewVal: Boolean);
|
|
|
|
var
|
|
|
|
I: Longint;
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
if NewVal <> FAsButtons then
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
for I := 0 to FThumbList.Count - 1 do
|
|
|
|
FThumbList.Thumbnail[I].AsButton := NewVal;
|
|
|
|
FAsButtons := NewVal;
|
|
|
|
end;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
{
|
|
|
|
Procedure TJvThumbView.SetBufferFile(NewName: string);
|
|
|
|
var
|
|
|
|
tst: string;
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
If NewName <> FBufferFile then
|
|
|
|
tst := GetBufferName(NewName);
|
|
|
|
End;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
2018-03-24 22:02:34 +00:00
|
|
|
}
|
2018-03-23 00:10:05 +00:00
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure TJvThumbView.SetDirectory(Value: string);
|
|
|
|
var
|
|
|
|
Counter1, FStartTime: DWORD;
|
|
|
|
Cancel: Boolean;
|
|
|
|
ReadFileList: TStringList;
|
|
|
|
OldCursor: TCursor;
|
|
|
|
// Pic: TPicture;
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
FSelected := -1;
|
|
|
|
// if not FPainted then
|
|
|
|
// begin
|
|
|
|
// postMessage(Self.Handle, WM_LOADWHENREADY, 0, 0);
|
|
|
|
// Exit;
|
|
|
|
// end;
|
|
|
|
FDiskSize := 0;
|
|
|
|
if FFilling then
|
|
|
|
Exit;
|
|
|
|
if Value <> '' then
|
|
|
|
begin
|
|
|
|
ReadFileList := TStringList.Create;
|
|
|
|
OldCursor := Cursor;
|
|
|
|
try
|
|
|
|
FFilling := True;
|
|
|
|
// if Assigned(ReadFileList) then FreeAndNil(ReadFileList);
|
2018-08-26 14:25:44 +00:00
|
|
|
FStartTime := GetTickCount64;
|
2018-03-24 22:02:34 +00:00
|
|
|
GetFiles(Value);
|
|
|
|
if FSorted then
|
|
|
|
ReadFileList.Assign(FFileListSorted)
|
|
|
|
else
|
|
|
|
ReadFileList.Assign(FFileList);
|
|
|
|
EmptyList;
|
|
|
|
FDirectory := Value;
|
|
|
|
if Assigned(FOnStartScanning) then
|
|
|
|
FOnStartScanning(Self, ReadFileList.Count - 1);
|
|
|
|
if ReadFileList.Count > 0 then
|
|
|
|
begin
|
|
|
|
Cancel := False;
|
|
|
|
for Counter1 := 0 to ReadFileList.Count - 1 do
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
if Assigned(FOnScanProgress) then
|
|
|
|
FOnScanProgress(Self, Counter1 + 1, Cancel);
|
|
|
|
if Cancel then
|
|
|
|
Break;
|
|
|
|
AddThumb(ExtractFilename(ReadFileList.Strings[Counter1]), True);
|
|
|
|
TJvThumbnail(FThumbList.Objects[Counter1]).FileName := ReadFileList.Strings[Counter1];
|
|
|
|
Inc(FDiskSize, TJvThumbnail(FThumbList.Objects[Counter1]).FileSize);
|
2018-08-26 14:25:44 +00:00
|
|
|
if (Cursor <> crHourGlass) and (GetTickCount64 - FStartTime > 1000) then
|
2018-03-24 22:02:34 +00:00
|
|
|
Cursor := crHourGlass;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
2018-03-24 22:02:34 +00:00
|
|
|
end;
|
|
|
|
if Assigned(FOnStopScanning) then
|
|
|
|
FOnStopScanning(Self);
|
|
|
|
finally
|
|
|
|
FreeAndNil(ReadFileList);
|
|
|
|
FFilling := False;
|
|
|
|
Cursor := OldCursor;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
EmptyList;
|
|
|
|
FDirectory := Value;
|
|
|
|
if (FThumbList.Count > 0) and (Selected < 0) then
|
|
|
|
SetSelected(0);
|
|
|
|
Invalidate;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure TJvThumbView.SetFilters;
|
|
|
|
var
|
|
|
|
Cp1 {, CP2}: Integer; // CurrentPosition;
|
|
|
|
// Md: Byte; // Mode
|
|
|
|
Res: string;
|
|
|
|
// Sub: string;
|
|
|
|
Final: string;
|
|
|
|
begin
|
|
|
|
if not Assigned(FGraphicExtensions) then
|
|
|
|
FGraphicExtensions := TStringList.Create;
|
|
|
|
// Cp1 := 0;
|
|
|
|
// CP2 := 0;
|
|
|
|
Res := FFilter;
|
|
|
|
Final := '';
|
|
|
|
repeat
|
|
|
|
Cp1 := Pos('|', Res);
|
|
|
|
if Cp1 > 0 then
|
|
|
|
begin
|
|
|
|
System.Delete(Res, 1, Cp1);
|
|
|
|
Cp1 := Pos('|', Res);
|
|
|
|
if Cp1 > 0 then
|
|
|
|
begin
|
|
|
|
Final := Final + ';' + Copy(Res, 1, Cp1 - 1);
|
|
|
|
System.Delete(Res, 1, Cp1);
|
|
|
|
end
|
|
|
|
else
|
|
|
|
Final := Final + ';' + Res;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
Final := Final + ';' + Res;
|
|
|
|
until Cp1 = 0;
|
|
|
|
Final := ReplaceAllstr(Final, ';', sLineBreak, False);
|
|
|
|
FGraphicExtensions.Text := Final;
|
|
|
|
|
|
|
|
Cp1 := 0;
|
|
|
|
repeat
|
|
|
|
if FGraphicExtensions[Cp1] = '' then
|
|
|
|
FGraphicExtensions.Delete(Cp1)
|
|
|
|
else
|
|
|
|
Inc(Cp1);
|
|
|
|
until Cp1 = FGraphicExtensions.Count;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure TJvThumbView.SetMaxHeight(H: Longint);
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
// if FMaxSize.Y<H then
|
|
|
|
FMaxSize.Y := H;
|
|
|
|
CalculateSize;
|
|
|
|
Reposition(0);
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure TJvThumbView.SetMaxWidth(W: Longint);
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
FMaxSize.X := W;
|
|
|
|
CalculateSize;
|
|
|
|
Reposition(0);
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure TJvThumbView.SetPercent(P: TPercent);
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
FPercent := P;
|
|
|
|
CalculateSize;
|
|
|
|
Reposition(0);
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure TJvThumbView.SetScrollMode(AMode: TScrollMode);
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
if FScrollMode <> AMode then
|
|
|
|
begin
|
|
|
|
FScrollMode := AMode;
|
|
|
|
CalculateSize;
|
|
|
|
Reposition(0);
|
|
|
|
if Selected > -1 then
|
|
|
|
ScrollTo(Selected);
|
|
|
|
end
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure TJvThumbView.SetSelected(Number: Longint);
|
2018-03-23 00:10:05 +00:00
|
|
|
var
|
2018-03-24 22:02:34 +00:00
|
|
|
TN: TJvThumbnail;
|
2018-04-21 14:46:46 +00:00
|
|
|
scrolled: Boolean = false;
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
if (Number < 0) or (Number >= FThumbList.Count) then
|
|
|
|
Number := -1;
|
|
|
|
|
|
|
|
if FThumbList.Count > 0 then
|
|
|
|
begin
|
|
|
|
if FSelected <> -1 then
|
|
|
|
begin
|
|
|
|
TN := TJvThumbnail(FThumbList.Objects[FSelected]);
|
|
|
|
TN.TitleColor := TN.Color;
|
|
|
|
TN.TitleFont.Color := TN.Font.Color;
|
|
|
|
end;
|
|
|
|
if Number <> -1 then
|
|
|
|
begin
|
|
|
|
TN := TJvThumbnail(FThumbList.Objects[Number]);
|
|
|
|
TN.TitleColor := clHighlight;
|
|
|
|
TN.TitleFont.Color := clHighlightText;
|
|
|
|
if AutoScrolling then
|
|
|
|
begin
|
2018-04-21 14:46:46 +00:00
|
|
|
if (TN.Top + TN.Height > Height) or (TN.Top < 0) then begin
|
2018-03-24 22:02:34 +00:00
|
|
|
ScrollTo(Number);
|
2018-04-21 14:46:46 +00:00
|
|
|
scrolled := true;
|
|
|
|
end;
|
|
|
|
if (TN.Left + TN.Width > Width) or (TN.Left < 0) then begin
|
2018-03-24 22:02:34 +00:00
|
|
|
ScrollTo(Number);
|
2018-04-21 14:46:46 +00:00
|
|
|
scrolled := true;
|
|
|
|
end;
|
2018-03-24 22:02:34 +00:00
|
|
|
end
|
|
|
|
end;
|
2018-04-21 14:46:46 +00:00
|
|
|
if (FSelected <> Number) or scrolled then
|
2018-03-24 22:02:34 +00:00
|
|
|
begin
|
|
|
|
if Assigned(FOnChanging) then
|
|
|
|
FOnChanging(Self);
|
|
|
|
FSelected := Number;
|
|
|
|
if Assigned(FOnChange) then
|
|
|
|
FOnChange(Self);
|
|
|
|
end;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
FSelected := -1;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure TJvThumbView.SetSelectedFile(AFile: string);
|
2018-03-23 00:10:05 +00:00
|
|
|
var
|
2018-03-24 22:02:34 +00:00
|
|
|
I: Longint;
|
|
|
|
Dir: string;
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
Dir := ExtractFileDir(AFile);
|
|
|
|
if Dir[Length(Dir)] = PathDelim then
|
|
|
|
Dir := Copy(Dir, 0, Length(Dir) - 1);
|
|
|
|
Directory := Dir;
|
|
|
|
for I := 0 to FThumbList.Count - 1 do
|
|
|
|
if TJvThumbnail(FThumbList.Objects[I]).FileName = AFile then
|
|
|
|
begin
|
|
|
|
Selected := I;
|
|
|
|
if not FAutoScrolling then
|
|
|
|
ScrollTo(I);
|
|
|
|
Exit;
|
|
|
|
end;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure TJvThumbView.SetSorted(const Value: Boolean);
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
if Value <> FSorted then
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
FSorted := Value;
|
2019-11-20 10:54:57 +00:00
|
|
|
FThumbList.Sorted := FSorted;
|
2018-03-24 22:02:34 +00:00
|
|
|
if not FPainted then
|
|
|
|
Exit;
|
|
|
|
SetDirectory(FDirectory); // force reread
|
|
|
|
Invalidate;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2018-03-25 00:04:05 +00:00
|
|
|
procedure TJvThumbView.SetThumbBevelInner(const AValue: TPanelBevel);
|
|
|
|
var
|
|
|
|
i: Integer;
|
|
|
|
begin
|
|
|
|
if AValue = FThumbBevelInner then exit;
|
|
|
|
FThumbBevelInner := AValue;
|
|
|
|
for i:=0 to FThumbList.Count-1 do
|
|
|
|
FThumbList.Thumbnail[i].BevelInner := FThumbBevelInner;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TJvThumbView.SetThumbBevelOuter(const AValue: TPanelBevel);
|
|
|
|
var
|
|
|
|
i: Integer;
|
|
|
|
begin
|
|
|
|
if AValue = FThumbBevelOuter then exit;
|
|
|
|
FThumbBevelOuter := AValue;
|
|
|
|
for i:=0 to FThumbList.Count-1 do
|
|
|
|
FThumbList.Thumbnail[i].BevelOuter := FThumbBevelOuter;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TJvThumbView.SetThumbBorderStyle(const AValue: TBorderStyle);
|
|
|
|
var
|
|
|
|
i: Integer;
|
|
|
|
begin
|
|
|
|
if AValue = FThumbBorderStyle then exit;
|
|
|
|
FThumbBorderStyle := AValue;
|
|
|
|
for i:=0 to FThumbList.Count-1 do
|
|
|
|
FThumbList.Thumbnail[i].BorderStyle := FThumbBorderStyle;
|
|
|
|
end;
|
|
|
|
|
2018-03-23 23:59:33 +00:00
|
|
|
procedure TJvThumbView.SetThumbColor(const AValue: TColor);
|
|
|
|
var
|
|
|
|
i: Integer;
|
|
|
|
begin
|
|
|
|
if AValue = FThumbColor then exit;
|
|
|
|
FThumbColor := AValue;
|
|
|
|
for i:=0 to FThumbList.Count-1 do
|
|
|
|
FThumbList.Thumbnail[i].Color := FThumbColor;
|
|
|
|
end;
|
|
|
|
|
2020-01-17 23:29:41 +00:00
|
|
|
procedure TJvThumbView.SetThumbGap(Sp: Integer);
|
2018-03-24 22:02:34 +00:00
|
|
|
begin
|
|
|
|
case FAlignView of
|
|
|
|
vtNormal, vtCenter:
|
|
|
|
begin
|
|
|
|
FThumbGap := Sp;
|
|
|
|
CalculateMaxX;
|
|
|
|
Reposition(0);
|
|
|
|
end;
|
|
|
|
vtFitToScreen:
|
|
|
|
FThumbGap := Sp;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2018-03-25 00:04:05 +00:00
|
|
|
procedure TJvThumbView.SetThumbTitleBevelInner(const AValue: TPanelBevel);
|
|
|
|
var
|
|
|
|
i: Integer;
|
|
|
|
begin
|
|
|
|
if AValue = FThumbTitleBevelInner then exit;
|
|
|
|
FThumbTitleBevelInner := AValue;
|
|
|
|
for i:=0 to FThumbList.Count-1 do
|
|
|
|
FThumbList.Thumbnail[i].TitleBevelInner := FThumbTitleBevelInner;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TJvThumbView.SetThumbTitleBevelOuter(const AValue: TPanelBevel);
|
|
|
|
var
|
|
|
|
i: Integer;
|
|
|
|
begin
|
|
|
|
if AValue = FThumbTitleBevelOuter then exit;
|
|
|
|
FThumbTitleBevelOuter := AValue;
|
|
|
|
for i:=0 to FThumbList.Count-1 do
|
|
|
|
FThumbList.Thumbnail[i].TitleBevelOuter := FThumbTitleBevelOuter;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TJvThumbView.SetThumbTitleBorderStyle(const AValue: TBorderStyle);
|
|
|
|
var
|
|
|
|
i: Integer;
|
|
|
|
begin
|
|
|
|
if AValue = FThumbTitleBorderStyle then exit;
|
|
|
|
FThumbTitleBorderStyle := AValue;
|
|
|
|
for i:=0 to FThumbList.Count-1 do
|
|
|
|
FThumbList.Thumbnail[i].TitleBorderStyle := FThumbTitleBorderStyle;
|
|
|
|
end;
|
|
|
|
|
2018-03-23 23:59:33 +00:00
|
|
|
procedure TJvThumbView.SetThumbTitleColor(const AValue: TColor);
|
|
|
|
var
|
|
|
|
i: Integer;
|
|
|
|
begin
|
|
|
|
if AValue = FThumbTitleColor then exit;
|
|
|
|
FThumbTitleColor := AValue;
|
|
|
|
for i:=0 to FThumbList.Count-1 do
|
|
|
|
FThumbList.Thumbnail[i].TitleColor := FThumbTitleColor;
|
|
|
|
end;
|
|
|
|
|
2018-03-23 00:10:05 +00:00
|
|
|
procedure TJvThumbView.SetTitlePos(const NewVal: TTitlePos);
|
|
|
|
var
|
|
|
|
I: Longint;
|
|
|
|
begin
|
|
|
|
if NewVal <> FTitlePlacement then
|
|
|
|
begin
|
|
|
|
for I := 0 to FThumbList.Count - 1 do
|
|
|
|
FThumbList.Thumbnail[I].TitlePlacement := NewVal;
|
|
|
|
FTitlePlacement := NewVal;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure TJvThumbView.SortList;
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
// add code to resort the list
|
|
|
|
FThumbList.Sort;
|
|
|
|
CalculateSize;
|
|
|
|
Reposition(0);
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
procedure TJvThumbView.WMPaint(var Msg: TLMPaint);
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
inherited;
|
|
|
|
if not FPainted then
|
|
|
|
begin
|
|
|
|
FPainted := True;
|
|
|
|
SetDirectory(FDirectory);
|
|
|
|
end;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
{ TJvThumbList }
|
2018-03-23 00:10:05 +00:00
|
|
|
|
2018-03-24 22:02:34 +00:00
|
|
|
function TJvThumbList.GetThumbnail(Index: Longint): TJvThumbnail;
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-24 22:02:34 +00:00
|
|
|
Result := TJvThumbnail(Objects[Index]);
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end.
|