diff --git a/components/jvcllaz/examples/JvThumbnail/JvThumbnailMainFormU.pas b/components/jvcllaz/examples/JvThumbnail/JvThumbnailMainFormU.pas index f340e3f0a..ae05bae3f 100644 --- a/components/jvcllaz/examples/JvThumbnail/JvThumbnailMainFormU.pas +++ b/components/jvcllaz/examples/JvThumbnail/JvThumbnailMainFormU.pas @@ -222,8 +222,8 @@ end; procedure TJvThumbnailMainForm.FormShow(Sender: TObject); begin - CbThumbColor.ButtonColor := ColorToRGB(ThumbVIew.ThumbColor); - CbTitleColor.ButtonColor := ColorToRGB(ThumbVIew.ThumbColor); + CbThumbColor.ButtonColor := ThumbView.ThumbColor; //ColorToRGB(ThumbVIew.ThumbColor); + CbTitleColor.ButtonColor := ThumbView.ThumbTitleColor; //ColorToRGB(ThumbVIew.ThumbColor); CbAutoScrolling.Checked := ThumbView.AutoScrolling; CbAutoHandleKeyboard.Checked := ThumbView.AutoHandleKeyb; CbSorted.Checked := ThumbView.Sorted; diff --git a/components/jvcllaz/run/JvCustomControls/JvThumbViews.pas b/components/jvcllaz/run/JvCustomControls/JvThumbViews.pas index 41f1ad59e..c35d57938 100644 --- a/components/jvcllaz/run/JvCustomControls/JvThumbViews.pas +++ b/components/jvcllaz/run/JvCustomControls/JvThumbViews.pas @@ -57,150 +57,154 @@ type TJvThumbView = class(TJvBaseThumbView) private - FMaxSize: TPoint; - FThumbSize: TPoint; -// Dummy: string; - FPercent: TPercent; - FDirectory: string; - FScrollMode: TScrollMode; - FAutoScrolling: Boolean; - FSelected: Longint; FAlignView: TViewType; - FThumbGap: Byte; - FMaxX: Word; - FMinMemory: Boolean; - FOnGetTitle: TTitleNotify; - FOnChanging: TNotifyEvent; - FOnChange: TNotifyEvent; - FOnStartScanning: TProgressStartNotify; - FOnStopScanning: TNotifyEvent; - FOnScanProgress: TProgressNotify; - FWaitUntilFull: Boolean; - FPainted: Boolean; + FAsButtons: Boolean; + FAutoHandleKeyb: Boolean; + FAutoScrolling: Boolean; + FDirectory: string; + FDiskSize: DWORD; FFileList: TStringList; FFileListSorted: TStringList; - FSorted: Boolean; FFilling: Boolean; FFilter: string; -// FBufferFile: string; - FThumbColor: TColor; - FThumbTitleColor: TColor; - FAsButtons: Boolean; - FTitlePlacement: TTitlePos; - FOnKeyDown: TKeyEvent; - FOnKeyUp: TKeyEvent; - FOnKeyPress: TKeyPressEvent; - FAutoHandleKeyb: Boolean; FGraphicExtensions: TStringList; - FShowShadow: Boolean; + FMaxSize: TPoint; + FMaxX: Word; + FMinMemory: Boolean; + FPainted: Boolean; + FPercent: TPercent; + FScrollMode: TScrollMode; + FSelected: Longint; FShadowColor: TColor; + FShowShadow: Boolean; + FSorted: Boolean; + FThumbColor: TColor; + FThumbGap: Byte; FThumbList: TJvThumbList; + FThumbSize: TPoint; + FThumbTitleColor: TColor; + FTitlePlacement: TTitlePos; + FWaitUntilFull: Boolean; + FOnChanging: TNotifyEvent; + FOnChange: TNotifyEvent; + FOnGetTitle: TTitleNotify; FOnInvalidImage: TInvalidImageEvent; - FDiskSize: DWORD; - FTopLeft: Integer; // Index of thumbnail at top/left corner - procedure WMPaint(var Msg: TLMPaint); message LM_PAINT; - procedure GetFiles(ADirectory: string); - procedure SetSorted(const Value: Boolean); + FOnKeyDown: TKeyEvent; + FOnKeyPress: TKeyPressEvent; + FOnKeyUp: TKeyEvent; + FOnScanProgress: TProgressNotify; + FOnStartScanning: TProgressStartNotify; + FOnStopScanning: TNotifyEvent; + //FBufferFile: string; + //Dummy: string; + procedure CalculateMaxX; procedure CalculateSize; function CalculateXPos(Num: Word): Longint; function CalculateYPos(Num: Word): Longint; - procedure ScrollTo(const Number: Longint); - procedure SetAlignView(AType: TViewType); - procedure Reposition(Start: Integer); + function CreateFilter: string; + procedure DoInvalidImage(Sender: TObject; const FileName: string); + function GetCount: Word; + procedure GetFiles(ADirectory: string); + function GetMaxHeight: Longint; + function GetMaxWidth: Longint; procedure GoLeft; procedure GoRight; procedure GoDown; procedure GoUp; + procedure Reposition(Start: Integer); + procedure ScrollTo(const Number: Longint); + procedure SetAlignView(AType: TViewType); procedure SetAsButton(const NewVal: Boolean); + procedure SetFilters; + procedure SetPercent(P: TPercent); + procedure SetScrollMode(AMode: TScrollMode); + procedure SetSorted(const Value: Boolean); procedure SetThumbColor(const AValue: TColor); + procedure SetThumbGap(Sp: Byte); procedure SetThumbTitleColor(const AValue: TColor); procedure SetTitlePos(const NewVal: TTitlePos); - function CreateFilter: string; - procedure SetFilters; + procedure WMPaint(var Msg: TLMPaint); message LM_PAINT; //function GetBufferName(AName: string): string; - function GetMaxHeight: Longint; - function GetMaxWidth: Longint; - procedure DoInvalidImage(Sender: TObject; const FileName: string); - // procedure WMLoadWhenReady(var Msg: TMessage); message WM_LOADWHENREADY; + //procedure WMLoadWhenReady(var Msg: TMessage); message WM_LOADWHENREADY; + protected procedure CreateHandle; override; (*********** NOT CONVERTED ** procedure GetDlgCode(var Code: TDlgCodes); override; *****) - procedure SetScrollMode(AMode: TScrollMode); - procedure SetSelected(Number: Longint); - // procedure SetBufferFile(NewName: string); - procedure Resize; override; - procedure SetMaxWidth(W: Longint); - procedure SetDirectory(Value: string); - procedure SetMaxHeight(H: Longint); - procedure KeyPress(var Key: Char); override; - procedure KeyDown(var Key: Word; Shift: TShiftState); override; - procedure KeyUp(var Key: Word; Shift: TShiftState); override; - procedure SetThumbGap(Sp: Byte); - procedure SetPercent(P: TPercent); - procedure SetSelectedFile(AFile: string); function GetSelectedFile: string; + procedure KeyDown(var Key: Word; Shift: TShiftState); override; + procedure KeyPress(var Key: Char); override; + procedure KeyUp(var Key: Word; Shift: TShiftState); override; procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override; - // function GetBufferFile: string; + 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); + public constructor Create(AOwner: TComponent); override; destructor Destroy; override; - procedure AddThumb(ATitle: string; Redraw: Boolean); function AddFromFile(AFile: string) : Integer; procedure AddFromStream(AStream: TStream; AType: TGRFKind); overload; function AddFromStream(AStream: TStream; AType: TGRFKind; const aTitle: string): Integer; overload; + procedure AddThumb(ATitle: string; Redraw: Boolean); procedure Delete(No: Longint); procedure EmptyList; - procedure SortList; procedure Refresh; - function GetCount: Word; + procedure SortList; property ThumbList: TJvThumbList read FThumbList write FThumbList; published - property SelectedFile: string read GetSelectedFile write SetSelectedFile; property AlignView: TViewType read FAlignView write SetAlignView; - property AutoScrolling: Boolean read FAutoScrolling write FAutoScrolling; - property ThumbGap: Byte read FThumbGap write SetThumbGap; + property AsButtons: Boolean read FAsButtons write SetAsButton; property AutoHandleKeyb: Boolean read FAutoHandleKeyb write FAutoHandleKeyb; - property MinMemory: Boolean read FMinMemory write FMinMemory; + property AutoScrolling: Boolean read FAutoScrolling write FAutoScrolling; + //property BufferFile : String Read FBufferFile write SetBufferFile; property Count: Word read GetCount default 0; - property MaxWidth: Longint read GetMaxWidth write SetMaxWidth; - property MaxHeight: Longint read GetMaxHeight write SetMaxHeight; - property Size: TPercent read FPercent write SetPercent; - property ScrollMode: TScrollMode read FScrollMode write SetScrollMode; property Directory: string read FDirectory write SetDirectory; - property Sorted: Boolean read FSorted write SetSorted; + property Filter: string read FFilter write FFilter; + property MaxHeight: Longint read GetMaxHeight write SetMaxHeight; + property MaxWidth: Longint read GetMaxWidth write SetMaxWidth; + property MinMemory: Boolean read FMinMemory write FMinMemory; + property ScrollMode: TScrollMode read FScrollMode write SetScrollMode; property Selected: Longint read FSelected write SetSelected default -1; - property OnStartScanning: TProgressStartNotify read FOnStartScanning write FOnStartScanning; - property OnStopScanning: TNotifyEvent read FOnStopScanning write FOnStopScanning; - property OnScanProgress: TProgressNotify read FOnScanProgress write FOnScanProgress; - property OnGetTitle: TTitleNotify read FOnGetTitle write FOnGetTitle; - property OnInvalidImage: TInvalidImageEvent read FOnInvalidImage write FOnInvalidImage; + property SelectedFile: string read GetSelectedFile write SetSelectedFile; + property ShadowColor: TColor read FShadowColor write FShadowColor; + property ShowShadow: Boolean read FShowShadow write FShowShadow; + property Size: TPercent read FPercent write SetPercent; + property Sorted: Boolean read FSorted write SetSorted; + property ThumbColor: TColor read FThumbColor write SetThumbColor default clDefault; + property ThumbGap: Byte read FThumbGap write SetThumbGap; + property ThumbTitleColor: TColor read FThumbTitleColor write SetThumbTitleColor default clDefault; + property TitlePlacement: TTitlePos read FTitlePlacement write SetTitlePos default tpUp; + property OnChange: TNotifyEvent read FOnChange write FOnChange; property OnChanging: TNotifyEvent read FOnChanging write FOnChanging; - property OnKeyUp: TKeyEvent read FOnKeyUp write FOnKeyUp; + property OnGetTitle: TTitleNotify read FOnGetTitle write FOnGetTitle; + property OnInvalidImage: TInvalidImageEvent read FOnInvalidImage write FOnInvalidImage; property OnKeyDown: TKeyEvent read FOnKeyDown write FOnKeyDown; property OnKeyPress: TKeyPressEvent read FOnKeyPress write FOnKeyPress; - property AsButtons: Boolean read FAsButtons write SetAsButton; - property TitlePlacement: TTitlePos read FTitlePlacement write SetTitlePos default tpUp; - property Filter: string read FFilter write FFilter; - // Property BufferFile : String Read FBufferFile write SetBufferFile; - property ThumbColor: TColor read FThumbColor write SetThumbColor default clDefault; - property ThumbTitleColor: TColor read FThumbTitleColor write SetThumbTitleColor default clDefault; - property ShowShadow: Boolean read FShowShadow write FShowShadow; - property ShadowColor: TColor read FShadowColor write FShadowColor; - property AutoScroll; - property PopupMenu; - property BorderStyle; + 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; + property AutoScroll; + property BorderStyle; property Color; property Cursor; property DragCursor; property DragMode; property Enabled; + property PopupMenu; end; @@ -214,6 +218,8 @@ uses '*.ICO','*.GIF','*.PCX', '*.TGA','*.PNG'); } +{ TJvThumbView } + constructor TJvThumbView.Create(AOwner: TComponent); begin FMaxSize.X := 200; @@ -260,16 +266,87 @@ begin inherited Destroy; end; -procedure TJvThumbView.CreateHandle; +function TJvThumbView.AddFromFile(AFile: string) : Integer; +var + ThumbnailTitle: string; + FFont: TFont; + FColor: TColor; + Thb: TJvThumbnail; begin - inherited; + Thb := TJvThumbnail.Create(Self); + 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; + 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); CalculateSize; + Reposition(0); + TJvThumbnail(FThumbList.Objects[FThumbList.IndexOf(AFile)]).FileName := AFile; + result := FThumbList.IndexOf(AFile); end; -procedure TJvThumbView.DoInvalidImage(Sender: TObject; const FileName: string); +procedure TJvThumbView.AddFromStream(AStream: TStream; AType: TGRFKind); begin - if Assigned(FOnInvalidImage) then - FOnInvalidImage(Sender, FileName); + 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; + Thb.Title := aTitle; + Thb.Photo.OnDblClick := OnDblClick; + 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); end; procedure TJvThumbView.AddThumb(ATitle: string; Redraw: Boolean); @@ -312,311 +389,6 @@ begin end; end; -procedure TJvThumbView.GetFiles(ADirectory: string); -var - SearchRec: TSearchRec; - FResult: Integer; - NumExtensions: Integer; - - function FindFirstGraphic(AExtension: string): Integer; - begin - // (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 - begin - 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; - end; - end; - FFileListSorted.Sort; - if Assigned(FGraphicExtensions) then - FreeAndNil(FGraphicExtensions); -end; - -procedure TJvThumbView.SetAlignView(AType: TViewType); -begin - if AType <> FAlignView then - begin - FAlignView := AType; - Reposition(0); - end; -end; - -procedure TJvThumbView.ScrollTo(const Number: Longint); -var - TN: TJvThumbnail; -begin -// 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; -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 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; -*) - -//Procedure TJvThumbView.SetBufferFile(NewName: string); -//var -// tst: string; -//begin -// If NewName <> FBufferFile then -// tst := GetBufferName(NewName); -// End; -//end; - -procedure TJvThumbView.SetSelected(Number: Longint); -var - TN: TJvThumbnail; -begin - 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 - if (TN.Top + TN.Height > Height) or (TN.Top < 0) then - ScrollTo(Number); - if (TN.Left + TN.Width > Width) or (TN.Left < 0) then - ScrollTo(Number); - end - end; - if FSelected <> Number then - begin - if Assigned(FOnChanging) then - FOnChanging(Self); - - FSelected := Number; - - if Assigned(FOnChange) then - FOnChange(Self); - end; - end - else - FSelected := -1; -end; - -function TJvThumbView.GetSelectedFile: String; -begin - if Selected <> -1 then - Result := TJvThumbnail(FThumbList.Objects[Selected]).FileName; -end; - -procedure TJvThumbView.SetSelectedFile(AFile: string); -var - I: Longint; - Dir: string; -begin - 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; -end; - -procedure TJvThumbView.SetDirectory(Value: string); -var - Counter1, FStartTime: DWORD; - Cancel: Boolean; - ReadFileList: TStringList; - OldCursor: TCursor; -// Pic: TPicture; -begin - 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); - FStartTime := GetTickCount; - 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 - begin - 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); - if (Cursor <> crHourGlass) and (GetTickCount - FStartTime > 1000) then - Cursor := crHourGlass; - end; - 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; -end; - -procedure TJvThumbView.Reposition(Start: Integer); -var - I: Integer; - Tmp1: Longint; - Tmp2: Longint; - thumb: TJvThumbnail; -begin - 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 - begin - thumb.Left := CalculateXPos(I + 1); - thumb.Top := CalculateYPos(I + 1); - thumb.Width := FThumbSize.X; - thumb.Height := FThumbSize.Y; - end; - end; - HorzScrollBar.Position := Tmp2; - VertScrollBar.Position := Tmp1; -end; - procedure TJvThumbView.CalculateMaxX; var A: Longint; @@ -723,133 +495,18 @@ begin Result := Temp; end; -procedure TJvThumbView.MouseDown(Button: TMouseButton; Shift: TShiftState; - X, Y: Integer); -var - SelNo, No: Word; - TempX, TempY: Longint; - thumb: TJvThumbnail; +procedure TJvThumbView.CreateHandle; 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 - // setfocus; - if Count > 0 then begin - SelNo := -1; - case ScrollMode of - smVertical, smBoth: - begin - 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; - if 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; - end; - smHorizontal: - begin - 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; - No := TempX * FMaxX + TempY; - if No < Count then begin - thumb := TJvThumbnail(FThumbList.Objects[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; - end; - end; - SetSelected(SelNo); - end; - inherited MouseDown(Button, Shift, X, Y); -end; - -procedure TJvThumbView.AddFromStream(AStream: TStream; AType: TGRFKind); -begin - 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; - Thb.Title := aTitle; - Thb.Photo.OnDblClick := OnDblClick; - 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); + inherited; CalculateSize; - Reposition(Result); end; -function TJvThumbView.AddFromFile(AFile: string) : Integer; -var - ThumbnailTitle: string; - FFont: TFont; - FColor: TColor; - Thb: TJvThumbnail; +function TJvThumbView.CreateFilter: string; +//var +// Res: string; +// Pos: Longint; begin - Thb := TJvThumbnail.Create(Self); - 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; - 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); - CalculateSize; - Reposition(0); - TJvThumbnail(FThumbList.Objects[FThumbList.IndexOf(AFile)]).FileName := AFile; - result := FThumbList.IndexOf(AFile); + Result := GraphicFilter(TGraphic); end; procedure TJvThumbView.Delete(No: Longint); @@ -880,42 +537,10 @@ begin end end; -procedure TJvThumbView.SetThumbGap(Sp: Byte); +procedure TJvThumbView.DoInvalidImage(Sender: TObject; const FileName: string); begin - case FAlignView of - vtNormal, vtCenter: - begin - FThumbGap := Sp; - CalculateMaxX; - Reposition(0); - end; - vtFitToScreen: - FThumbGap := Sp; - end; -end; - -function TJvThumbView.GetCount: Word; -begin - Result := FThumbList.Count; -end; - -procedure TJvThumbView.SortList; -begin - // add code to resort the list - FThumbList.Sort; - CalculateSize; - Reposition(0); -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; + if Assigned(FOnInvalidImage) then + FOnInvalidImage(Sender, FileName); end; procedure TJvThumbView.EmptyList; @@ -932,62 +557,169 @@ begin FSelected := -1; // Mantis #5140 end; -procedure TJvThumbView.SetMaxWidth(W: Longint); +(* +function TJvThumbView.GetBufferName(AName: string): string; +var + tst: string; + FN: string; + Res: string; begin - FMaxSize.X := W; - CalculateSize; - Reposition(0); -end; - -procedure TJvThumbView.SetMaxHeight(H: Longint); -begin - // if FMaxSize.Y AMode then - begin - FScrollMode := AMode; - CalculateSize; - Reposition(0); - if Selected > -1 then - ScrollTo(Selected); + 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 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; +*) + +function TJvThumbView.GetCount: Word; +begin + Result := FThumbList.Count; end; -procedure TJvThumbView.KeyUp(var Key: Word; Shift: TShiftState); +(************* NOT CONVERTED +procedure TJvThumbView.GetDlgCode(var Code: TDlgCodes); begin - if Assigned(FOnKeyUp) then - FOnKeyUp(Self, Key, Shift); - inherited KeyUp(Key, Shift); + Code := [dcWantArrows, dcWantAllKeys]; +end; +************) + +procedure TJvThumbView.GetFiles(ADirectory: string); +var + SearchRec: TSearchRec; + FResult: Integer; + NumExtensions: Integer; + + function FindFirstGraphic(AExtension: string): Integer; + begin + // (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 + begin + 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; + end; + end; + FFileListSorted.Sort; + if Assigned(FGraphicExtensions) then + FreeAndNil(FGraphicExtensions); +end; + +function TJvThumbView.GetMaxHeight: Longint; +begin + Result := FMaxSize.Y; +end; + +function TJvThumbView.GetMaxWidth: Longint; +begin + Result := FMaxSize.X; +end; + +function TJvThumbView.GetSelectedFile: String; +begin + if Selected <> -1 then + Result := TJvThumbnail(FThumbList.Objects[Selected]).FileName; +end; + +procedure TJvThumbView.GoDown; +var + Actual: Longint; +begin + 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; +end; + +procedure TJvThumbView.GoLeft; +var + Actual: Longint; +begin + 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; +end; + +procedure TJvThumbView.GoRight; +var + Actual: Longint; +begin + 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; +end; + +procedure TJvThumbView.GoUp; +var + Actual: Longint; +begin + 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; end; procedure TJvThumbView.KeyDown(var Key: Word; Shift: TShiftState); @@ -1044,80 +776,157 @@ begin inherited KeyPress(Key); end; -procedure TJvThumbView.SetSorted(const Value: Boolean); +procedure TJvThumbView.KeyUp(var Key: Word; Shift: TShiftState); begin - if Value <> FSorted then + if Assigned(FOnKeyUp) then + FOnKeyUp(Self, Key, Shift); + inherited KeyUp(Key, Shift); +end; + +procedure TJvThumbView.MouseDown(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); +var + SelNo, No: Word; + TempX, TempY: Longint; + thumb: TJvThumbnail; +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 + // setfocus; + if Count > 0 then begin + SelNo := -1; + case ScrollMode of + smVertical, smBoth: + begin + 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; + if 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; + end; + smHorizontal: + begin + 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; + No := TempX * FMaxX + TempY; + if No < Count then begin + thumb := TJvThumbnail(FThumbList.Objects[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; + end; + end; + SetSelected(SelNo); + end; + inherited MouseDown(Button, Shift, X, Y); +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; + +procedure TJvThumbView.Reposition(Start: Integer); +var + I: Integer; + Tmp1: Longint; + Tmp2: Longint; + thumb: TJvThumbnail; +begin + 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 - FSorted := Value; - if not FPainted then - Exit; - FThumbList.Sorted := FSorted; - SetDirectory(FDirectory); // force reread - Invalidate; + thumb := FThumbList.Thumbnail[I]; //TJvThumbnail(FThumbList.Objects[I]); + if thumb <> nil then + begin + thumb.Left := CalculateXPos(I + 1); + thumb.Top := CalculateYPos(I + 1); + thumb.Width := FThumbSize.X; + thumb.Height := FThumbSize.Y; + end; + end; + HorzScrollBar.Position := Tmp2; + VertScrollBar.Position := Tmp1; +end; + +procedure TJvThumbView.Resize; +begin + CalculateMaxX; + Reposition(0); + inherited Resize; +end; + +procedure TJvThumbView.ScrollTo(const Number: Longint); +var + TN: TJvThumbnail; +begin +// 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; end; -(************* NOT CONVERTED -procedure TJvThumbView.GetDlgCode(var Code: TDlgCodes); +procedure TJvThumbView.SetAlignView(AType: TViewType); begin - Code := [dcWantArrows, dcWantAllKeys]; -end; -************) - -procedure TJvThumbView.GoRight; -var - Actual: Longint; -begin - 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; -end; - -procedure TJvThumbView.GoLeft; -var - Actual: Longint; -begin - 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; -end; - -procedure TJvThumbView.GoDown; -var - Actual: Longint; -begin - 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; -end; - -procedure TJvThumbView.GoUp; -var - Actual: Longint; -begin - 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; + if AType <> FAlignView then + begin + FAlignView := AType; + Reposition(0); + end; end; procedure TJvThumbView.SetAsButton(const NewVal: Boolean); @@ -1132,44 +941,81 @@ begin end; end; -procedure TJvThumbView.SetThumbColor(const AValue: TColor); +{ +Procedure TJvThumbView.SetBufferFile(NewName: string); var - i: Integer; + tst: string; begin - if AValue = FThumbColor then exit; - FThumbColor := AValue; - for i:=0 to FThumbList.Count-1 do - FThumbList.Thumbnail[i].Color := FThumbColor; + If NewName <> FBufferFile then + tst := GetBufferName(NewName); + End; end; +} -procedure TJvThumbView.SetThumbTitleColor(const AValue: TColor); +procedure TJvThumbView.SetDirectory(Value: string); var - i: Integer; + Counter1, FStartTime: DWORD; + Cancel: Boolean; + ReadFileList: TStringList; + OldCursor: TCursor; +// Pic: TPicture; begin - if AValue = FThumbTitleColor then exit; - FThumbTitleColor := AValue; - for i:=0 to FThumbList.Count-1 do - FThumbList.Thumbnail[i].TitleColor := FThumbTitleColor; -end; - -procedure TJvThumbView.SetTitlePos(const NewVal: TTitlePos); -var - I: Longint; -begin - if NewVal <> FTitlePlacement then + 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 - for I := 0 to FThumbList.Count - 1 do - FThumbList.Thumbnail[I].TitlePlacement := NewVal; - FTitlePlacement := NewVal; - end; -end; - -function TJvThumbView.CreateFilter: string; -//var -// Res: string; -// Pos: Longint; -begin - Result := GraphicFilter(TGraphic); + ReadFileList := TStringList.Create; + OldCursor := Cursor; + try + FFilling := True; + // if Assigned(ReadFileList) then FreeAndNil(ReadFileList); + FStartTime := GetTickCount; + 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 + begin + 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); + if (Cursor <> crHourGlass) and (GetTickCount - FStartTime > 1000) then + Cursor := crHourGlass; + end; + 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; end; procedure TJvThumbView.SetFilters; @@ -1215,27 +1061,187 @@ begin until Cp1 = FGraphicExtensions.Count; end; +procedure TJvThumbView.SetMaxHeight(H: Longint); +begin + // if FMaxSize.Y AMode then + begin + FScrollMode := AMode; + CalculateSize; + Reposition(0); + if Selected > -1 then + ScrollTo(Selected); + end +end; + +procedure TJvThumbView.SetSelected(Number: Longint); +var + TN: TJvThumbnail; +begin + 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 + if (TN.Top + TN.Height > Height) or (TN.Top < 0) then + ScrollTo(Number); + if (TN.Left + TN.Width > Width) or (TN.Left < 0) then + ScrollTo(Number); + end + end; + if FSelected <> Number then + begin + if Assigned(FOnChanging) then + FOnChanging(Self); + + FSelected := Number; + + if Assigned(FOnChange) then + FOnChange(Self); + end; + end + else + FSelected := -1; +end; + +procedure TJvThumbView.SetSelectedFile(AFile: string); +var + I: Longint; + Dir: string; +begin + 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; +end; + +procedure TJvThumbView.SetSorted(const Value: Boolean); +begin + if Value <> FSorted then + begin + FSorted := Value; + if not FPainted then + Exit; + FThumbList.Sorted := FSorted; + SetDirectory(FDirectory); // force reread + Invalidate; + end; +end; + +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; + +procedure TJvThumbView.SetThumbGap(Sp: Byte); +begin + case FAlignView of + vtNormal, vtCenter: + begin + FThumbGap := Sp; + CalculateMaxX; + Reposition(0); + end; + vtFitToScreen: + FThumbGap := Sp; + end; +end; + +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; + +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; + +procedure TJvThumbView.SortList; +begin + // add code to resort the list + FThumbList.Sort; + CalculateSize; + Reposition(0); +end; + +procedure TJvThumbView.WMPaint(var Msg: TLMPaint); +begin + inherited; + if not FPainted then + begin + FPainted := True; + SetDirectory(FDirectory); + end; +end; + + +{ TJvThumbList } + function TJvThumbList.GetThumbnail(Index: Longint): TJvThumbnail; begin Result := TJvThumbnail(Objects[Index]); end; -function TJvThumbView.GetMaxHeight: Longint; -begin - Result := FMaxSize.Y; -end; -function TJvThumbView.GetMaxWidth: Longint; -begin - Result := FMaxSize.X; -end; - -{$IFDEF UNITVERSIONING} -initialization - RegisterUnitVersion(HInstance, UnitVersioning); - -finalization - UnregisterUnitVersion(HInstance); -{$ENDIF UNITVERSIONING} end.