From fc5c3f8c5d2ed124cde7a1a82214df3401cc1438 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sat, 21 Apr 2018 14:46:46 +0000 Subject: [PATCH] jvcllaz: Activate file info in JvThumbnail. Update demo. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6333 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../JvThumbnail/JvThumbnailChildFormU.lfm | 5 +- .../examples/JvThumbnail/JvThumbnailDemo.lpi | 2 - .../JvThumbnail/JvThumbnailMainFormU.lfm | 320 +++++++++++++----- .../JvThumbnail/JvThumbnailMainFormU.pas | 133 ++++---- .../run/JvCustomControls/JvBaseThumbnail.pas | 76 +++-- .../run/JvCustomControls/JvThumbViews.pas | 34 +- .../run/JvCustomControls/JvThumbnails.pas | 91 +++-- 7 files changed, 431 insertions(+), 230 deletions(-) diff --git a/components/jvcllaz/examples/JvThumbnail/JvThumbnailChildFormU.lfm b/components/jvcllaz/examples/JvThumbnail/JvThumbnailChildFormU.lfm index 6a56f16b4..7d19fd282 100644 --- a/components/jvcllaz/examples/JvThumbnail/JvThumbnailChildFormU.lfm +++ b/components/jvcllaz/examples/JvThumbnail/JvThumbnailChildFormU.lfm @@ -43,7 +43,7 @@ object JvThumbnailChildForm: TJvThumbnailChildForm Align = alTop BackgroundColor = clDefault Color = clDefault - FileSortType = fstNone + FileSortType = fstAlphabet HideSelection = False Images = DataModule1.ImageList1 ReadOnly = True @@ -63,6 +63,7 @@ object JvThumbnailChildForm: TJvThumbnailChildForm HideSelection = False Mask = '*.ICO;*.BMP;*.EMF;*.WMF;*.JPG;*.JPEG;' ReadOnly = True + SortType = stText TabOrder = 1 OnChange = ShellListViewChange ObjectTypes = [otNonFolders] @@ -431,9 +432,9 @@ object JvThumbnailChildForm: TJvThumbnailChildForm Constraints.MinWidth = 152 TabOrder = 2 OnClick = ThumbNailClick + ShadowColor = clSilver TitleColor = clBtnFace TitleFont.Color = clWindowText - ShadowColor = clSilver end object Panel1: TPanel AnchorSideLeft.Control = ThumbNail diff --git a/components/jvcllaz/examples/JvThumbnail/JvThumbnailDemo.lpi b/components/jvcllaz/examples/JvThumbnail/JvThumbnailDemo.lpi index ede33b005..bada03cae 100644 --- a/components/jvcllaz/examples/JvThumbnail/JvThumbnailDemo.lpi +++ b/components/jvcllaz/examples/JvThumbnail/JvThumbnailDemo.lpi @@ -13,7 +13,6 @@ - @@ -58,7 +57,6 @@ - diff --git a/components/jvcllaz/examples/JvThumbnail/JvThumbnailMainFormU.lfm b/components/jvcllaz/examples/JvThumbnail/JvThumbnailMainFormU.lfm index 63c9a93a3..849f01998 100644 --- a/components/jvcllaz/examples/JvThumbnail/JvThumbnailMainFormU.lfm +++ b/components/jvcllaz/examples/JvThumbnail/JvThumbnailMainFormU.lfm @@ -1,10 +1,10 @@ object JvThumbnailMainForm: TJvThumbnailMainForm Left = 296 - Height = 656 + Height = 748 Top = 126 Width = 931 Caption = 'JvThumbView Demo' - ClientHeight = 656 + ClientHeight = 748 ClientWidth = 931 Color = clBtnFace Constraints.MinHeight = 430 @@ -17,7 +17,7 @@ object JvThumbnailMainForm: TJvThumbnailMainForm Scaled = False object PageControl1: TPageControl Left = 0 - Height = 632 + Height = 724 Top = 0 Width = 931 ActivePage = TabSheet1 @@ -26,11 +26,11 @@ object JvThumbnailMainForm: TJvThumbnailMainForm TabOrder = 0 object TabSheet1: TTabSheet Caption = 'ThumbView Component' - ClientHeight = 604 + ClientHeight = 696 ClientWidth = 923 object Splitter1: TSplitter Left = 205 - Height = 544 + Height = 636 Top = 60 Width = 3 end @@ -61,9 +61,9 @@ object JvThumbnailMainForm: TJvThumbnailMainForm ParentColor = False end object Label3: TLabel - AnchorSideLeft.Control = SpinEdit1 + AnchorSideLeft.Control = EdGap AnchorSideTop.Control = Panel1 - AnchorSideRight.Control = SpinEdit1 + AnchorSideRight.Control = EdGap AnchorSideRight.Side = asrBottom Left = 600 Height = 16 @@ -80,9 +80,9 @@ object JvThumbnailMainForm: TJvThumbnailMainForm ShowHint = True end object Label4: TLabel - AnchorSideLeft.Control = SpinEdit2 + AnchorSideLeft.Control = EdSelected AnchorSideTop.Control = Label3 - AnchorSideRight.Control = SpinEdit2 + AnchorSideRight.Control = EdSelected AnchorSideRight.Side = asrBottom Left = 680 Height = 16 @@ -159,7 +159,7 @@ object JvThumbnailMainForm: TJvThumbnailMainForm State = cbChecked TabOrder = 2 end - object SpinEdit1: TSpinEdit + object EdGap: TSpinEdit AnchorSideLeft.Control = BtnEditSelThumb AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = Label3 @@ -173,16 +173,16 @@ object JvThumbnailMainForm: TJvThumbnailMainForm BorderSpacing.Top = 3 MaxValue = 300 MinValue = 1 - OnChange = SpinEdit1Change + OnChange = EdGapChange ParentShowHint = False ShowHint = True TabOrder = 3 Value = 1 end - object SpinEdit2: TSpinEdit - AnchorSideLeft.Control = SpinEdit1 + object EdSelected: TSpinEdit + AnchorSideLeft.Control = EdGap AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = SpinEdit1 + AnchorSideTop.Control = EdGap Left = 680 Height = 23 Hint = 'Selects the thumbnail with this index' @@ -190,7 +190,7 @@ object JvThumbnailMainForm: TJvThumbnailMainForm Width = 64 BorderSpacing.Left = 16 MaxValue = 0 - OnChange = SpinEdit2Change + OnChange = EdSelectedChange ParentShowHint = False ShowHint = True TabOrder = 4 @@ -264,23 +264,23 @@ object JvThumbnailMainForm: TJvThumbnailMainForm end object Panel2: TPanel Left = 0 - Height = 544 + Height = 636 Top = 60 Width = 205 Align = alLeft BevelOuter = bvNone Caption = 'Panel2' - ClientHeight = 544 + ClientHeight = 636 ClientWidth = 205 TabOrder = 1 object ShellTreeView: TShellTreeView Left = 0 - Height = 374 + Height = 438 Hint = 'Set directory where your images are located and watch the thumbview creating the thumbs' Top = 0 Width = 205 Align = alClient - FileSortType = fstNone + FileSortType = fstAlphabet HideSelection = False Images = DataModule1.ImageList1 ReadOnly = True @@ -290,102 +290,173 @@ object JvThumbnailMainForm: TJvThumbnailMainForm Options = [tvoAutoItemHeight, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw] ObjectTypes = [otFolders] end - object RadioGroup1: TRadioGroup + object GroupBox4: TGroupBox Left = 0 - Height = 77 - Hint = 'Change the AlignView property to either use the thumbGup (VTNormal) autocalculate the empty space to equall parts(VTSPACEEQUAL) or Cender the thumbs in the using the htumbgup between them.' - Top = 382 + Height = 190 + Top = 446 Width = 205 Align = alBottom - AutoFill = True AutoSize = True BorderSpacing.Top = 8 - Caption = ' AlignView ' - ChildSizing.LeftRightSpacing = 6 - ChildSizing.EnlargeHorizontal = crsHomogenousChildResize - ChildSizing.EnlargeVertical = crsHomogenousChildResize - ChildSizing.ShrinkHorizontal = crsScaleChilds - ChildSizing.ShrinkVertical = crsScaleChilds - ChildSizing.Layout = cclLeftToRightThenTopToBottom - ChildSizing.ControlsPerLine = 1 - ClientHeight = 57 + Caption = 'File info' + ClientHeight = 170 ClientWidth = 201 - ItemIndex = 0 - Items.Strings = ( - 'VTNormal' - 'VTCenter' - 'VTFitToScreen' - ) - OnClick = RadioGroup1Click TabOrder = 1 - end - object RadioGroup2: TRadioGroup - Left = 0 - Height = 77 - Hint = 'Change the ScrollMode to change the direction the thumb are scrolling in the screen SMVertical You will see a vertical scrollbar SMHorizontal For A horizontal ScrollBar or SMBoth to create a square view ' - Top = 467 - Width = 205 - Align = alBottom - AutoFill = True - AutoSize = True - BorderSpacing.Top = 8 - Caption = ' ScrollMode ' - ChildSizing.LeftRightSpacing = 6 - ChildSizing.EnlargeHorizontal = crsHomogenousChildResize - ChildSizing.EnlargeVertical = crsHomogenousChildResize - ChildSizing.ShrinkHorizontal = crsScaleChilds - ChildSizing.ShrinkVertical = crsScaleChilds - ChildSizing.Layout = cclLeftToRightThenTopToBottom - ChildSizing.ControlsPerLine = 1 - ClientHeight = 57 - ClientWidth = 201 - ItemIndex = 2 - Items.Strings = ( - 'SMHorizontal' - 'SMVertical' - 'SMBoth' - ) - OnClick = RadioGroup2Click - TabOrder = 2 + object LblFileSize: TLabel + AnchorSideLeft.Control = GroupBox4 + AnchorSideTop.Control = InfoFileName + AnchorSideTop.Side = asrBottom + Left = 12 + Height = 15 + Top = 34 + Width = 23 + BorderSpacing.Left = 12 + Caption = 'Size:' + ParentColor = False + end + object InfoFileSize: TLabel + AnchorSideLeft.Control = GroupBox4 + AnchorSideTop.Control = LblFileSize + AnchorSideTop.Side = asrBottom + Left = 20 + Height = 15 + Top = 49 + Width = 5 + BorderSpacing.Left = 20 + BorderSpacing.Bottom = 4 + Caption = '-' + ParentColor = False + end + object LblDateCreated: TLabel + AnchorSideLeft.Control = GroupBox4 + AnchorSideTop.Control = InfoFileSize + AnchorSideTop.Side = asrBottom + Left = 12 + Height = 15 + Top = 68 + Width = 69 + BorderSpacing.Left = 12 + BorderSpacing.Top = 4 + Caption = 'Date created:' + ParentColor = False + end + object InfoDateCreated: TLabel + AnchorSideLeft.Control = GroupBox4 + AnchorSideTop.Control = LblDateCreated + AnchorSideTop.Side = asrBottom + Left = 20 + Height = 15 + Top = 83 + Width = 5 + BorderSpacing.Left = 20 + BorderSpacing.Bottom = 4 + Caption = '-' + ParentColor = False + end + object LblDateModified: TLabel + AnchorSideLeft.Control = GroupBox4 + AnchorSideTop.Control = InfoDateCreated + AnchorSideTop.Side = asrBottom + Left = 12 + Height = 15 + Top = 102 + Width = 75 + BorderSpacing.Left = 12 + BorderSpacing.Top = 4 + Caption = 'Date modified' + ParentColor = False + end + object InfoDateModified: TLabel + AnchorSideLeft.Control = GroupBox4 + AnchorSideTop.Control = LblDateModified + AnchorSideTop.Side = asrBottom + Left = 20 + Height = 15 + Top = 117 + Width = 5 + BorderSpacing.Left = 20 + BorderSpacing.Bottom = 4 + Caption = '-' + ParentColor = False + end + object LblDateAccessed: TLabel + AnchorSideLeft.Control = GroupBox4 + AnchorSideTop.Control = InfoDateModified + AnchorSideTop.Side = asrBottom + Left = 12 + Height = 15 + Top = 136 + Width = 77 + BorderSpacing.Left = 12 + BorderSpacing.Top = 4 + Caption = 'Date accessed:' + ParentColor = False + end + object InfoDateAccessed: TLabel + AnchorSideLeft.Control = GroupBox4 + AnchorSideTop.Control = LblDateAccessed + AnchorSideTop.Side = asrBottom + Left = 20 + Height = 15 + Top = 151 + Width = 5 + BorderSpacing.Left = 20 + BorderSpacing.Bottom = 4 + Caption = '-' + ParentColor = False + end + object LblFilename: TLabel + AnchorSideLeft.Control = GroupBox4 + AnchorSideTop.Control = GroupBox4 + Left = 12 + Height = 15 + Top = 0 + Width = 54 + BorderSpacing.Left = 12 + Caption = 'File name:' + ParentColor = False + end + object InfoFileName: TLabel + AnchorSideLeft.Control = GroupBox4 + AnchorSideTop.Control = LblFilename + AnchorSideTop.Side = asrBottom + Left = 20 + Height = 15 + Top = 15 + Width = 5 + BorderSpacing.Left = 20 + BorderSpacing.Bottom = 4 + Caption = '-' + ParentColor = False + end end end object Panel3: TPanel Left = 208 - Height = 544 + Height = 636 Top = 60 Width = 715 Align = alClient BevelOuter = bvNone Caption = 'Panel3' - ClientHeight = 544 + ClientHeight = 636 ClientWidth = 715 TabOrder = 2 - object DirInfoPanel: TPanel - Left = 0 - Height = 16 - Hint = 'Read the selectedFile property to get the path+filename of the selected thumb' - Top = 528 - Width = 715 - Align = alBottom - BevelOuter = bvLowered - ParentShowHint = False - ShowHint = True - TabOrder = 0 - end object ThumbView: TJvThumbView Left = 0 - Height = 528 + Height = 636 Top = 0 Width = 553 - HorzScrollBar.Page = 1 + HorzScrollBar.Page = 5 HorzScrollBar.Tracking = True - VertScrollBar.Page = 1 + VertScrollBar.Page = 50 VertScrollBar.Tracking = True Align = alClient - TabOrder = 1 + ClientHeight = 632 + ClientWidth = 549 + TabOrder = 0 TabStop = True OnDblClick = ThumbViewDblClick - OnMouseUp = ThumbViewMouseUp AlignView = vtNormal AsButtons = False AutoHandleKeyb = True @@ -401,23 +472,28 @@ object JvThumbnailMainForm: TJvThumbnailMainForm Sorted = True ThumbColor = clNone OnChange = ThumbViewChange - OnKeyUp = ThumbViewKeyUp OnScanProgress = ThumbViewScanProgress OnStartScanning = ThumbViewStartScanning OnStopScanning = ThumbViewStopScanning + object Splitter2: TSplitter + Left = 0 + Height = 632 + Top = 0 + Width = 5 + end end object Panel4: TPanel Left = 561 - Height = 528 + Height = 636 Top = 0 Width = 146 Align = alRight BorderSpacing.Left = 8 BorderSpacing.Right = 8 BevelOuter = bvNone - ClientHeight = 528 + ClientHeight = 636 ClientWidth = 146 - TabOrder = 2 + TabOrder = 1 object GroupBox1: TGroupBox Left = 0 Height = 80 @@ -730,6 +806,64 @@ object JvThumbnailMainForm: TJvThumbnailMainForm Text = 'bsNone' end end + object RgAlignView: TRadioGroup + Left = 0 + Height = 93 + Hint = 'Change the AlignView property to either use the thumbGup (VTNormal) autocalculate the empty space to equall parts(VTSPACEEQUAL) or Cender the thumbs in the using the htumbgup between them.' + Top = 432 + Width = 146 + Align = alTop + AutoFill = False + AutoSize = True + BorderSpacing.Top = 8 + BorderSpacing.InnerBorder = 4 + Caption = ' AlignView ' + ChildSizing.LeftRightSpacing = 16 + ChildSizing.VerticalSpacing = 4 + ChildSizing.ShrinkHorizontal = crsScaleChilds + ChildSizing.ShrinkVertical = crsScaleChilds + ChildSizing.Layout = cclLeftToRightThenTopToBottom + ChildSizing.ControlsPerLine = 1 + ClientHeight = 73 + ClientWidth = 142 + ItemIndex = 0 + Items.Strings = ( + 'VTNormal' + 'VTCenter' + 'VTFitToScreen' + ) + OnClick = RgAlignViewClick + TabOrder = 3 + end + object RgScrollMode: TRadioGroup + Left = 0 + Height = 93 + Hint = 'Change the ScrollMode to change the direction the thumb are scrolling in the screen SMVertical You will see a vertical scrollbar SMHorizontal For A horizontal ScrollBar or SMBoth to create a square view ' + Top = 533 + Width = 146 + Align = alTop + AutoFill = False + AutoSize = True + BorderSpacing.Top = 8 + BorderSpacing.InnerBorder = 4 + Caption = ' ScrollMode ' + ChildSizing.LeftRightSpacing = 16 + ChildSizing.VerticalSpacing = 4 + ChildSizing.ShrinkHorizontal = crsScaleChilds + ChildSizing.ShrinkVertical = crsScaleChilds + ChildSizing.Layout = cclLeftToRightThenTopToBottom + ChildSizing.ControlsPerLine = 1 + ClientHeight = 73 + ClientWidth = 142 + ItemIndex = 2 + Items.Strings = ( + 'SMHorizontal' + 'SMVertical' + 'SMBoth' + ) + OnClick = RgScrollModeClick + TabOrder = 4 + end end end end @@ -737,7 +871,7 @@ object JvThumbnailMainForm: TJvThumbnailMainForm object Panel5: TPanel Left = 0 Height = 24 - Top = 632 + Top = 724 Width = 931 Align = alBottom BorderWidth = 2 diff --git a/components/jvcllaz/examples/JvThumbnail/JvThumbnailMainFormU.pas b/components/jvcllaz/examples/JvThumbnail/JvThumbnailMainFormU.pas index 26f69c91a..21c8a3580 100644 --- a/components/jvcllaz/examples/JvThumbnail/JvThumbnailMainFormU.pas +++ b/components/jvcllaz/examples/JvThumbnail/JvThumbnailMainFormU.pas @@ -31,8 +31,8 @@ unit JvThumbnailMainFormU; interface uses - Classes, Controls, Graphics, Forms, StdCtrls, ExtCtrls, ComCtrls, Dialogs, - Spin, ShellCtrls, + SysUtils, Classes, Controls, Graphics, Forms, Spin, + StdCtrls, ExtCtrls, ComCtrls, Dialogs, ShellCtrls, JvThumbnails, JvThumbViews, {%H-}JvThumbnailDatamodule; {JvSpecialProgress, @@ -55,16 +55,28 @@ type GroupBox1: TGroupBox; GroupBox2: TGroupBox; GroupBox3: TGroupBox; + GroupBox4: TGroupBox; + InfoDateAccessed: TLabel; + InfoFileName: TLabel; Label1: TLabel; Label10: TLabel; + LblDateAccessed: TLabel; + LblFileSize: TLabel; + InfoFileSize: TLabel; + LblDateCreated: TLabel; + InfoDateCreated: TLabel; + LblDateModified: TLabel; + InfoDateModified: TLabel; Label2: TLabel; Label5: TLabel; Label6: TLabel; Label7: TLabel; Label8: TLabel; Label9: TLabel; + LblFilename: TLabel; PageControl1: TPageControl; Panel4: TPanel; + Splitter2: TSplitter; TabSheet1: TTabSheet; Splitter1: TSplitter; Panel1: TPanel; @@ -74,22 +86,28 @@ type TbThumbSize: TTrackBar; CbAutoScrolling: TCheckBox; CbAutoHandleKeyboard: TCheckBox; - SpinEdit1: TSpinEdit; - SpinEdit2: TSpinEdit; + EdGap: TSpinEdit; + EdSelected: TSpinEdit; CbSorted: TCheckBox; CbMinMemory: TCheckBox; Panel2: TPanel; ShellTreeView: TShellTreeView; - RadioGroup1: TRadioGroup; - RadioGroup2: TRadioGroup; + RgAlignView: TRadioGroup; + RgScrollMode: TRadioGroup; Panel3: TPanel; - DirInfoPanel: TPanel; BtnStopLoading: TButton; BtnEditSelThumb: TButton; - ThumbView: TJVTHumbview; + ThumbView: TJVThumbview; Panel5: TPanel; ProgressBar: TProgressBar; Bevel1: TBevel; + + procedure BtnEditSelThumbClick(Sender: TObject); + procedure BtnStopLoadingClick(Sender: TObject); + + procedure CbAutoHandleKeyboardClick(Sender: TObject); + procedure CbAutoScrollingClick(Sender: TObject); + procedure CbMinMemoryClick(Sender: TObject); procedure CbThumbBevelInnerChange(Sender: TObject); procedure CbThumbBevelOuterChange(Sender: TObject); procedure CbThumbBorderStyleChange(Sender: TObject); @@ -98,28 +116,23 @@ type procedure CbThumbTitleBevelOuterChange(Sender: TObject); procedure CbThumbTitleBorderStyleChange(Sender: TObject); procedure CbTitleColorColorChanged(Sender: TObject); + procedure EdGapChange(Sender: TObject); + procedure EdSelectedChange(Sender: TObject); + + procedure FormShow(Sender: TObject); + + procedure RgAlignViewClick(Sender: TObject); + procedure RgScrollModeClick(Sender: TObject); procedure ShellTreeViewChange(Sender: TObject; Node: TTreeNode); procedure ShellTreeViewGetImageIndex(Sender: TObject; Node: TTreeNode); - procedure ThumbViewKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); - procedure ThumbViewMouseUp(Sender: TObject; Button: TMouseButton; - Shift: TShiftState; X, Y: Integer); + procedure TbThumbSizeChange(Sender: TObject); + procedure ThumbViewChange(Sender: TObject); + procedure ThumbViewDblClick(Sender: TObject); procedure ThumbViewScanProgress(Sender: TObject; APosition: Integer; var Break: Boolean); procedure ThumbViewStartScanning(Sender: TObject; AMax: Integer); procedure ThumbViewStopScanning(Sender: TObject); - procedure BtnStopLoadingClick(Sender: TObject); - procedure CbAutoScrollingClick(Sender: TObject); - procedure CbAutoHandleKeyboardClick(Sender: TObject); - procedure CbMinMemoryClick(Sender: TObject); - procedure SpinEdit1Change(Sender: TObject); - procedure SpinEdit2Change(Sender: TObject); - procedure RadioGroup1Click(Sender: TObject); - procedure RadioGroup2Click(Sender: TObject); - procedure FormShow(Sender: TObject); - procedure TbThumbSizeChange(Sender: TObject); - procedure ThumbViewDblClick(Sender: TObject); - procedure BtnEditSelThumbClick(Sender: TObject); - procedure ThumbViewChange(Sender: TObject); + public NewDir: Boolean; Scanning: Boolean; @@ -130,22 +143,12 @@ var implementation -uses JvThumbnailChildFormU; +uses + StrUtils, + JvThumbnailChildFormU; {$R *.lfm} -procedure TJvThumbnailMainForm.ThumbViewMouseUp(Sender: TObject; Button: TMouseButton; - Shift: TShiftState; X, Y: Integer); -begin - DirInfoPanel.Caption := ThumbView.SelectedFile; -end; - -procedure TJvThumbnailMainForm.ThumbViewKeyUp(Sender: TObject; var Key: Word; - Shift: TShiftState); -begin - DirInfoPanel.Caption := ThumbView.SelectedFile; -end; - procedure TJvThumbnailMainForm.ThumbViewScanProgress(Sender: TObject; APosition: Integer; var Break: Boolean); @@ -167,11 +170,12 @@ procedure TJvThumbnailMainForm.ThumbViewStopScanning(Sender: TObject); begin Scanning := False; // ShellTreeView.Enabled := True; - Spinedit2.MaxValue := ThumbView.Count - 1; + EdSelected.MaxValue := ThumbView.Count - 1; newdir := False; BtnStopLoading.Enabled := False; ProgressBar.Position := 0; ProgressBar.Visible := false; + ThumbViewChange(nil); end; procedure TJvThumbnailMainForm.BtnStopLoadingClick(Sender: TObject); @@ -234,24 +238,24 @@ begin ThumbView.ThumbTitleColor := CbTitleColor.ButtonColor; end; -procedure TJvThumbnailMainForm.SpinEdit1Change(Sender: TObject); +procedure TJvThumbnailMainForm.EdGapChange(Sender: TObject); begin - if spinedit1.Text <> '' then ThumbView.ThumbGap := spinedit1.Value; + if EdGap.Text <> '' then ThumbView.ThumbGap := EdGap.Value; end; -procedure TJvThumbnailMainForm.SpinEdit2Change(Sender: TObject); +procedure TJvThumbnailMainForm.EdSelectedChange(Sender: TObject); begin - ThumbView.Selected := spinedit2.Value; + ThumbView.Selected := EdSelected.Value; end; -procedure TJvThumbnailMainForm.RadioGroup1Click(Sender: TObject); +procedure TJvThumbnailMainForm.RgAlignViewClick(Sender: TObject); begin - ThumbView.AlignView := TViewType(radiogroup1.ItemIndex); + ThumbView.AlignView := TViewType(RgAlignView.ItemIndex); end; -procedure TJvThumbnailMainForm.RadioGroup2Click(Sender: TObject); +procedure TJvThumbnailMainForm.RgScrollModeClick(Sender: TObject); begin - ThumbView.ScrollMode := TscrollMode(radiogroup2.ItemIndex); + ThumbView.ScrollMode := TscrollMode(RgScrollMode.ItemIndex); end; procedure TJvThumbnailMainForm.ShellTreeViewChange(Sender: TObject; @@ -283,11 +287,11 @@ begin CbAutoHandleKeyboard.Checked := ThumbView.AutoHandleKeyb; CbSorted.Checked := ThumbView.Sorted; CbSorted.Checked := ThumbView.MinMemory; - spinedit1.Value := ThumbView.ThumbGap; - spinedit2.MaxValue := 0; - spinedit1.MinValue := 0; - radiogroup1.ItemIndex := integer(ThumbView.alignview); - radiogroup2.ItemIndex := integer(ThumbView.scrollMode); + EdGap.Value := ThumbView.ThumbGap; + EdSelected.MaxValue := 0; + EdGap.MinValue := 0; + RgAlignView.ItemIndex := integer(ThumbView.alignview); + RgScrollMode.ItemIndex := integer(ThumbView.scrollMode); Newdir := False; Scanning := False; end; @@ -305,15 +309,9 @@ begin try F.ShelLTreeView.Path := ShellTreeView.Path; if Sender is TJvThumbView then - begin F.SetFileName(TJvThumbView(Sender).SelectedFile); -// F.FileListBox1.FileName := tjvThumbView(Sender).SelectedFile; - end; if Sender is TJvThumbnail then - begin F.SetFileName(TJvThumbnail(Sender).FileName); - // F.FileListBox1.FileName := tjvthumbnail(Sender).FileName; - end; F.ShowModal; finally F.Free; @@ -326,8 +324,27 @@ begin end; procedure TJvThumbnailMainForm.ThumbViewChange(Sender: TObject); +var + thumbnail: TJvThumbnail; begin - DirInfoPanel.Caption := ThumbView.SelectedFile; + Caption := 'JvThumbView Demo - ' + ThumbView.SelectedFile; + if ThumbView.Selected > -1 then begin + thumbnail := ThumbView.ThumbList[ThumbView.Selected]; + InfoFilename.Caption := ExtractfileName(thumbnail.FileName); + InfoFileSize.Caption := Format('%.1n kB', [thumbnail.FileSize/1024]); + InfoDateCreated.Caption := IfThen(thumbnail.FileCreated = 0, '-', + DateTimeToStr(thumbnail.FileCreated)); + InfoDateAccessed.Caption := IfThen(thumbnail.FileAccessed = 0, '-', + DateTimeToStr(thumbnail.FileAccessed)); + InfoDateModified.Caption := IfThen(thumbnail.FileChanged = 0, '-', + DateTimeToStr(thumbnail.FileChanged)); + end else begin + InfoFileSize.Caption := '-'; + InfoDateCreated.Caption := '-'; + InfoDateAccessed.Caption := '-'; + InfoDateModified.Caption := '-'; + end; + EdSelected.Value := ThumbView.Selected; end; end. diff --git a/components/jvcllaz/run/JvCustomControls/JvBaseThumbnail.pas b/components/jvcllaz/run/JvCustomControls/JvBaseThumbnail.pas index b82e97b35..b259cf93f 100644 --- a/components/jvcllaz/run/JvCustomControls/JvBaseThumbnail.pas +++ b/components/jvcllaz/run/JvCustomControls/JvBaseThumbnail.pas @@ -64,6 +64,9 @@ type 02) SaveToStream(AStream: TStream; APos: Integer); Save the FileName to AStream if APos > -1 then AStream.Seek(APos, 0); SaveData; + + wp: removed LongName and ShortName - seem to be old DOS-style filenames not + useful in Linux, are not used anywhere. } TProgressNotify = procedure(Sender: TObject; Position: Integer; var Stop: Boolean) of object; TInvalidImageEvent = procedure(Sender: TObject; const AFileName: string) of object; @@ -74,13 +77,17 @@ type {$M+} TJvFileName = class(TObject) // was: TFileName, renamed to TJvFileName to avoid conflict with existing type private + { wp: removed -- not used anywhere FLongName: string; FShortName: string; + } FFileName: string; + { wp: not used anywhere FCreated: TDateTime; FAccessed: TDateTime; FModified: TDateTime; FFileSize: Longint; + } protected procedure SetName(NewName: string); virtual; function GetLength: Integer; @@ -91,12 +98,14 @@ type // both of this routines are inserting extract data to the stream its self // like a header and data end string; procedure SaveToStream(AStream: TStream; APos: Integer); // Save to a Stream + { wp -- not used anywhere // (rom) moved to public property LongName: string read FLongName; // The LongName of this filename property ShortName: string read FShortName; // shortname of this filename + } published property FileName: string read FFileName write SetName; // The FileName as given by the user - property Length: Integer read GetLength write SetLength; + //property Length: Integer read GetLength write SetLength; end; {$M-} @@ -185,8 +194,14 @@ function InRange(Min, Max, Value: Integer; WithBorder: Boolean = false): Boolean implementation uses - SysUtils, Types, - JvJCLUtils, JvThemes; + {$IFDEF WINDOWS} + Windows, + {$ENDIF} + {$IFDEF UNIX} + baseunix, + {$ENDIF} + SysUtils, Types, DateUtils, + JvThemes; function ReplaceAllStr(const Str, SearchFor, ReplaceWith: string; CaseSensitive: Boolean): string; @@ -627,55 +642,74 @@ begin end; } + //=== { TJvFileName } ========================================================== procedure TJvFileName.SetName(NewName: string); begin + if FFileName = NewName then exit; FFileName := NewName; - {$IFDEF WINDOWS} - if (NewName <> LongName) and (NewName <> ShortName) then - {$ENDIF} - Init; + Init; end; +{$IFDEF WINDOWS} +function FileTimeToDateTime(FileTime: TFileTime): TDateTime; +var + LocalTime: TFileTime; + DOSTime: Integer; +begin + FileTimeToLocalFileTime(FileTime, LocalTime); + FileTimeToDosDateTime(LocalTime, LongRec(DOSTime).Hi, LongRec(DOSTime).Lo); + Result := FileDateToDateTime(DOSTime); +end; +{$ENDIF} + procedure TJvFileName.Init; var + {$IFDEF WINDOWS} Dft: DWORD; Lft: TFileTime; sr: TSearchRec; + {$ENDIF} + {$IFDEF UNIX} + info: stat; + {$ENDIF} begin + (* wp: not used anywhere... + + {$IFDEF WINDOWS} if FindFirst(FFileName, faAnyFile or faDirectory, sr) = 0 then begin FindClose(sr); - {$IFDEF WINDOWS} - FLongName := sr.FindData.cFileName; - FShortName := sr.FindData.cAlternateFileName; - if FLongName = '' then - FLongName := FShortName; - if FShortName = '' then - FShortName := FLongName; - - // FIX ME !!! - - (**************** NOT CONVERTED *** //fdFileAccessed FileTimeToLocalFileTime(sr.FindData.ftLastAccessTime, Lft); FileTimeToDosDateTime(Lft, LongRec(Dft).Hi, LongRec(Dft).Lo); FAccessed := Dft; + //fdFilechanged FileTimeToLocalFileTime(sr.FindData.ftLastwriteTime, Lft); FileTimeToDosDateTime(Lft, LongRec(Dft).Hi, LongRec(Dft).Lo); FModified := Dft; + //fdFilecreated FileTimeToLocalFileTime(sr.FindData.ftCreationTime, Lft); FileTimeToDosDateTime(Lft, LongRec(Dft).Hi, LongRec(Dft).Lo); FCreated := Dft; - **************) + FFileSize := (sr.FindData.nFileSizeHigh * MAXDWORD) + sr.FindData.nFileSizeLow; - //FFileName:=NewName; - {$ENDIF} end; + {$ENDIF} + + {$IFDEF UNIX} + if fpstat(FFileName, info) = 0 then begin + FAccessed := UnixToDateTime(info.st_atime); + FModified := UnixToDateTime(info.st_mtime); + FCreated := UnixToDateTime(info.st_ctime); + FFileSize := info.Size; + end; + {$ENDIF} + *) end; procedure TJvFileName.LoadFromStream(AStream: TStream; APos: Integer); diff --git a/components/jvcllaz/run/JvCustomControls/JvThumbViews.pas b/components/jvcllaz/run/JvCustomControls/JvThumbViews.pas index f2a4f5a26..b8dfbf0cd 100644 --- a/components/jvcllaz/run/JvCustomControls/JvThumbViews.pas +++ b/components/jvcllaz/run/JvCustomControls/JvThumbViews.pas @@ -829,6 +829,7 @@ begin // setfocus; if Count > 0 then begin SelNo := -1; + No := -1; case ScrollMode of smVertical, smBoth: begin @@ -837,12 +838,6 @@ begin 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 @@ -851,14 +846,16 @@ begin 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; + 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; SetSelected(SelNo); end; inherited MouseDown(Button, Shift, X, Y); @@ -1132,6 +1129,7 @@ end; procedure TJvThumbView.SetSelected(Number: Longint); var TN: TJvThumbnail; + scrolled: Boolean = false; begin if (Number < 0) or (Number >= FThumbList.Count) then Number := -1; @@ -1151,19 +1149,21 @@ begin TN.TitleFont.Color := clHighlightText; if AutoScrolling then begin - if (TN.Top + TN.Height > Height) or (TN.Top < 0) then + if (TN.Top + TN.Height > Height) or (TN.Top < 0) then begin ScrollTo(Number); - if (TN.Left + TN.Width > Width) or (TN.Left < 0) then + scrolled := true; + end; + if (TN.Left + TN.Width > Width) or (TN.Left < 0) then begin ScrollTo(Number); + scrolled := true; + end; end end; - if FSelected <> Number then + if (FSelected <> Number) or scrolled then begin if Assigned(FOnChanging) then FOnChanging(Self); - FSelected := Number; - if Assigned(FOnChange) then FOnChange(Self); end; diff --git a/components/jvcllaz/run/JvCustomControls/JvThumbnails.pas b/components/jvcllaz/run/JvCustomControls/JvThumbnails.pas index 408b84a65..71c9ae36c 100644 --- a/components/jvcllaz/run/JvCustomControls/JvThumbnails.pas +++ b/components/jvcllaz/run/JvCustomControls/JvThumbnails.pas @@ -50,7 +50,13 @@ unit JvThumbnails; interface uses - LCLIntf, LCLType, LMessages, + {$IFDEF WINDOWS} + Windows, + {$ENDIF} + {$IFDEF UNIX} + baseunix, + {$ENDIF} + LCLIntf, LCLType, LMessages, Types, Classes, Controls, ExtCtrls, SysUtils, Graphics, Forms, JvThumbImage, JvBaseThumbnail, Dialogs; @@ -71,9 +77,9 @@ type FTitleColor: TColor; FTitleFont: TFont; FStreamFileKind: TGRFKind; - FDFileCreated: string; - FDFileChanged: string; - FDFileAccessed: string; + FDFileCreated: TDateTime; + FDFileChanged: TDateTime; + FDFileAccessed: TDateTime; FShowTitle: Boolean; FDFileSize: Longint; FStream: TStream; @@ -172,17 +178,17 @@ type property TitlePlacement: TTitlePos read FTitlePlacement write SetTitlePlacement default tpUp; property OnGetTitle: TTitleNotify read FOnGetTitle write FOnGetTitle; { Do not store dummies } - property FileSize: Longint read FDFileSize write SetDummyCard stored False; - property FileAccessed: string read FDFileAccessed write SetDummyStr stored False; - property FileCreated: string read FDFileCreated write SetDummyStr stored False; - property FileChanged: string read FDFileChanged write SetDummyStr stored False; + property FileSize: Longint read FDFileSize stored false; // write SetDummyCard stored False; + property FileAccessed: TDateTime read FDFileAccessed stored false; // write SetDummyStr stored False; + property FileCreated: TDateTime read FDFileCreated stored false; // write SetDummyStr stored False; + property FileChanged: TDateTime read FDFileChanged stored false; // write SetDummyStr stored False; end; implementation uses - FileUtil, + FileUtil, DateUtils, JvThumbViews, JvResources; constructor TJvThumbnail.Create(AOwner: TComponent); @@ -321,50 +327,60 @@ end; procedure TJvThumbnail.GetFileInfo(AName: String); var - FileInfo: TSearchRec; -begin - if FileExists(AName) then begin - FDFilesize := FileUtil.FileSize(AName); - // Other fields not supported - end; -end; -{ wp ----------- partly replaced by above -procedure TJvThumbnail.GetFileInfo(AName: string); -var - FileInfo: TWin32FindData; + {$IFDEF WINDOWS} + info: TWin32FindDataW; + dft: DWORD; + lft: TFileTime; H: THandle; - Dft: DWORD; - Lft: TFileTime; + ws: WideString; + {$ENDIF} + {$IFDEF UNIX} + info: stat; + {$ENDIF} begin - H := Windows.FindFirstFile(PChar(AName), FileInfo); + {$IFDEF WINDOWS} + ws := UTF8Decode(AName); + H := Windows.FindFirstFileW(PWideChar(ws), info); if H <> INVALID_HANDLE_VALUE then begin Windows.FindClose(H); - FileTimeToLocalFileTime(FileInfo.ftLastAccessTime, Lft); - FileTimeToDosDateTime(Lft, LongRec(Dft).Hi, LongRec(Dft).Lo); + //fdFileAccessed + FileTimeToLocalFileTime(info.ftLastAccessTime, lft); + FileTimeToDosDateTime(lft, LongRec(dft).Hi, LongRec(dft).Lo); try - FDFileAccessed := DateTimeToStr(FileDateToDateTime(Dft)); + FDFileAccessed := FileDateToDateTime(dft); except - FDFileAccessed := RsUnknown; + FDFileAccessed := 0; end; - FileTimeToLocalFileTime(FileInfo.ftLastwriteTime, Lft); - FileTimeToDosDateTime(Lft, LongRec(Dft).Hi, LongRec(Dft).Lo); + //fdFilechanged + FileTimeToLocalFileTime(info.ftLastwriteTime, lft); + FileTimeToDosDateTime(lft, LongRec(dft).Hi, LongRec(dft).Lo); try - FDFileChanged := DateTimeToStr(FileDateToDateTime(Dft)); + FDFileChanged := FileDateToDateTime(dft); except - FDFileChanged := RsUnknown; + FDFileChanged := 0; end; - FileTimeToLocalFileTime(FileInfo.ftCreationTime, Lft); - FileTimeToDosDateTime(Lft, LongRec(Dft).Hi, LongRec(Dft).Lo); + //fdFileCreated + FileTimeToLocalFileTime(info.ftCreationTime, lft); + FileTimeToDosDateTime(lft, LongRec(dft).Hi, LongRec(dft).Lo); try - FDFileCreated := DateTimeToStr(FileDateToDateTime(Dft)); + FDFileCreated := FileDateToDateTime(dft); except - FDFileCreated := RsUnknown; + FDFileCreated := 0; end; - FDFileSize := (FileInfo.nFileSizeHigh * MAXDWORD) + FileInfo.nFileSizeLow; + FDFileSize := info.nFileSizeHigh * MAXDWORD + info.nFileSizeLow; end; + {$ENDIF} + + {$IFDEF UNIX} + if fpstat(AName, info) = 0 then begin + FDFileAccessed := UnixToDateTime(info.st_atime); + FDFileChanged := UnixToDateTime(info.st_mtime); + FDFileCreated := UnixToDateTime(info.st_ctime); + FDFileSize := info.Size; + end; + {$ENDIF} end; ----------------- } function TJvThumbnail.GetFileName: string; begin @@ -731,3 +747,4 @@ begin end; end. +