You've already forked lazarus-ccr
jvcllaz: Fix scrolling of JvThumbView.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6268 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -14,14 +14,17 @@ implementation
|
|||||||
{$R ..\..\resource\jvpagecompsreg.res}
|
{$R ..\..\resource\jvpagecompsreg.res}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
ImgList, PropEdits,
|
ImgList,
|
||||||
|
PropEdits, ComponentEditors,
|
||||||
JvDsgnConsts,
|
JvDsgnConsts,
|
||||||
JvNavigationPane, JvNavPaneEditors;
|
JvNavigationPane, JvNavPaneEditors,
|
||||||
|
JvPageList,JvPageListEditors, JvPageListTreeView;
|
||||||
|
|
||||||
procedure Register;
|
procedure Register;
|
||||||
const
|
const
|
||||||
cImageIndex = 'ImageIndex';
|
cImageIndex = 'ImageIndex';
|
||||||
begin
|
begin
|
||||||
|
// JvNavigationPanel
|
||||||
RegisterComponents(RsPaletteJvcl, [ // was: RsPaletteNavPane
|
RegisterComponents(RsPaletteJvcl, [ // was: RsPaletteNavPane
|
||||||
TJvNavigationPane,
|
TJvNavigationPane,
|
||||||
TJvNavIconButton,
|
TJvNavIconButton,
|
||||||
@ -29,10 +32,37 @@ begin
|
|||||||
TJvOutlookSplitter,
|
TJvOutlookSplitter,
|
||||||
TJvNavPaneStyleManager, TJvNavPaneToolPanel
|
TJvNavPaneStyleManager, TJvNavPaneToolPanel
|
||||||
]);
|
]);
|
||||||
RegisterPropertyEditor(TypeInfo(TImageIndex), TJvNavPanelPage, cImageIndex, TJvNavPanePageImageIndexProperty);
|
RegisterPropertyEditor(TypeInfo(TImageIndex), TJvNavPanelPage, cImageIndex,
|
||||||
RegisterPropertyEditor(TypeInfo(TImageIndex), TJvNavPanelHeader, cImageIndex, TJvNavPanelHeaderImageIndexProperty);
|
TJvNavPanePageImageIndexProperty);
|
||||||
RegisterPropertyEditor(TypeInfo(TImageIndex), TJvNavPanelButton, cImageIndex, TJvNavPanelButtonImageIndexProperty);
|
RegisterPropertyEditor(TypeInfo(TImageIndex), TJvNavPanelHeader, cImageIndex,
|
||||||
RegisterPropertyEditor(TypeInfo(TImageIndex), TJvNavIconButton, cImageIndex, TJvNavIconButtonImageIndexProperty);
|
TJvNavPanelHeaderImageIndexProperty);
|
||||||
|
RegisterPropertyEditor(TypeInfo(TImageIndex), TJvNavPanelButton, cImageIndex,
|
||||||
|
TJvNavPanelButtonImageIndexProperty);
|
||||||
|
RegisterPropertyEditor(TypeInfo(TImageIndex), TJvNavIconButton, cImageIndex,
|
||||||
|
TJvNavIconButtonImageIndexProperty);
|
||||||
|
|
||||||
|
// JvPageList
|
||||||
|
RegisterComponents(RsPaletteJvcl, [ // was: RsPaletteListComboTree
|
||||||
|
TJvPageList]);
|
||||||
|
RegisterClasses([TJvPageList, TJvStandardPage]);
|
||||||
|
RegisterComponentEditor(TJvCustomPageList, TJvCustomPageListEditor); // was: TJvCustomPageEditor
|
||||||
|
RegisterComponentEditor(TJvCustomPage, TJvCustomPageEditor);
|
||||||
|
RegisterPropertyEditor(TypeInfo(TJvShowDesignCaption), nil, '',
|
||||||
|
TJvShowDesignCaptionProperty);
|
||||||
|
{
|
||||||
|
RegisterPropertyEditor(TypeInfo(TJvCustomPage),
|
||||||
|
TJvCustomPageList, cActivePage, TJvActivePageProperty);
|
||||||
|
}
|
||||||
|
|
||||||
|
// JvPageTree
|
||||||
|
RegisterComponents(RsPaletteJvcl, [ // was: TsPaletteListComboTree
|
||||||
|
TJvSettingsTreeView, TJvPageListTreeView
|
||||||
|
]);
|
||||||
|
RegisterClasses([TJvSettingsTreeView, TJvPageListTreeView]);
|
||||||
|
|
||||||
|
RegisterPropertyEditor(TypeInfo(TImageIndex), TJvSettingsTreeImages, '',
|
||||||
|
TJvSettingsTreeImagesProperty);
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -187,12 +187,14 @@ end;
|
|||||||
procedure TJvThumbnailChildForm.SetFileName(AFileName: String);
|
procedure TJvThumbnailChildForm.SetFileName(AFileName: String);
|
||||||
var
|
var
|
||||||
dir, fn: String;
|
dir, fn: String;
|
||||||
|
item: TListItem;
|
||||||
begin
|
begin
|
||||||
dir := ExtractFilePath(AFileName);
|
dir := ExtractFilePath(AFileName);
|
||||||
fn := ExtractFileName(AFileName);
|
fn := ExtractFileName(AFileName);
|
||||||
if dir <> ShellListView.Root then
|
if dir <> ShellListView.Root then
|
||||||
ShellTreeView.Path := dir;
|
ShellTreeView.Path := dir;
|
||||||
ShellListView.Selected := ShellListView.Items.FindCaption(0, fn, false, false, false);
|
item := ShellListView.Items.FindCaption(-0, fn, false, true, false);
|
||||||
|
ShellListView.Selected := item;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -179,6 +179,7 @@ function ReplaceChar(const AStr: string; const CharToFind, NewChar: Char;
|
|||||||
function JkCeil(I: Extended): Longint;
|
function JkCeil(I: Extended): Longint;
|
||||||
function ReplaceAllStr(const Str, SearchFor, ReplaceWith: string;
|
function ReplaceAllStr(const Str, SearchFor, ReplaceWith: string;
|
||||||
CaseSensitive: Boolean): string;
|
CaseSensitive: Boolean): string;
|
||||||
|
function InRange(Min, Max, Value: Integer; WithBorder: Boolean = false): Boolean;
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -308,6 +309,15 @@ begin
|
|||||||
Result := Value;
|
Result := Value;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function InRange(Min, Max, Value: Integer; WithBorder: Boolean = false): Boolean;
|
||||||
|
begin
|
||||||
|
if WithBorder then
|
||||||
|
Result := (Value >= Min) and (Value <= Max)
|
||||||
|
else
|
||||||
|
Result := (Value > Min) and (Value < Max);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
//=== { TJvThumbTitle } ======================================================
|
//=== { TJvThumbTitle } ======================================================
|
||||||
|
|
||||||
constructor TJvThumbTitle.Create(AOwner: TComponent);
|
constructor TJvThumbTitle.Create(AOwner: TComponent);
|
||||||
|
@ -31,7 +31,7 @@ unit JvThumbViews;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
LCLType, LMessages,
|
LCLType, LMessages, Types,
|
||||||
Classes, Controls, Forms, ExtCtrls,
|
Classes, Controls, Forms, ExtCtrls,
|
||||||
SysUtils, Graphics,
|
SysUtils, Graphics,
|
||||||
JvThumbnails, JvBaseThumbnail, JvExControls;
|
JvThumbnails, JvBaseThumbnail, JvExControls;
|
||||||
@ -96,6 +96,7 @@ type
|
|||||||
FThumbList: TJvThumbList;
|
FThumbList: TJvThumbList;
|
||||||
FOnInvalidImage: TInvalidImageEvent;
|
FOnInvalidImage: TInvalidImageEvent;
|
||||||
FDiskSize: DWORD;
|
FDiskSize: DWORD;
|
||||||
|
FTopLeft: Integer; // Index of thumbnail at top/left corner
|
||||||
procedure WMPaint(var Msg: TLMPaint); message LM_PAINT;
|
procedure WMPaint(var Msg: TLMPaint); message LM_PAINT;
|
||||||
procedure GetFiles(ADirectory: string);
|
procedure GetFiles(ADirectory: string);
|
||||||
procedure SetSorted(const Value: Boolean);
|
procedure SetSorted(const Value: Boolean);
|
||||||
@ -148,13 +149,13 @@ type
|
|||||||
function AddFromFile(AFile: string) : Integer;
|
function AddFromFile(AFile: string) : Integer;
|
||||||
procedure AddFromStream(AStream: TStream; AType: TGRFKind); overload;
|
procedure AddFromStream(AStream: TStream; AType: TGRFKind); overload;
|
||||||
function AddFromStream(AStream: TStream; AType: TGRFKind; const aTitle: string): Integer; overload;
|
function AddFromStream(AStream: TStream; AType: TGRFKind; const aTitle: string): Integer; overload;
|
||||||
|
|
||||||
procedure Delete(No: Longint);
|
procedure Delete(No: Longint);
|
||||||
procedure EmptyList;
|
procedure EmptyList;
|
||||||
procedure SortList;
|
procedure SortList;
|
||||||
procedure Refresh;
|
procedure Refresh;
|
||||||
function GetCount: Word;
|
function GetCount: Word;
|
||||||
property ThumbList: TJvThumbList read FThumbList write FThumbList;
|
property ThumbList: TJvThumbList read FThumbList write FThumbList;
|
||||||
|
|
||||||
published
|
published
|
||||||
property SelectedFile: string read GetSelectedFile write SetSelectedFile;
|
property SelectedFile: string read GetSelectedFile write SetSelectedFile;
|
||||||
property AlignView: TViewType read FAlignView write SetAlignView;
|
property AlignView: TViewType read FAlignView write SetAlignView;
|
||||||
@ -369,40 +370,32 @@ begin
|
|||||||
// if AutoScrolling then
|
// if AutoScrolling then
|
||||||
if (Number < 0) or (Number >= FThumbList.Count) then
|
if (Number < 0) or (Number >= FThumbList.Count) then
|
||||||
Exit;
|
Exit;
|
||||||
TN := TJvThumbnail(FThumbList.Objects[Number]);
|
TN := FThumbList.Thumbnail[Number];
|
||||||
case ScrollMode of
|
case ScrollMode of
|
||||||
smVertical:
|
smVertical:
|
||||||
begin
|
begin
|
||||||
if TN.Top < 0 then
|
if TN.Top - VertScrollbar.Position < 0 then
|
||||||
VertScrollBar.Position := VertScrollBar.Position +
|
VertScrollBar.Position := TN.Top - TN.Width div 2;
|
||||||
(TN.Top - (TN.Width div 2));
|
if TN.Top + TN.Height - VertScrollbar.Position > Height then
|
||||||
if TN.Top + TN.Height > Height then
|
VertScrollBar.Position := TN.Top + TN.Height - (Height - TN.Height div 2);
|
||||||
VertScrollBar.Position := VertScrollBar.Position +
|
|
||||||
(TN.Top - (Height - TN.Height - (TN.Height div 2)));
|
|
||||||
end;
|
end;
|
||||||
smHorizontal:
|
smHorizontal:
|
||||||
begin
|
begin
|
||||||
if TN.Left < 0 then
|
if TN.Left - HorzScrollbar.Position < 0 then
|
||||||
HorzScrollBar.Position := HorzScrollBar.Position +
|
HorzScrollBar.Position := TN.Left - TN.Width div 2;
|
||||||
(TN.Left - (TN.Width div 2));
|
if TN.Left + TN.Width - HorzScrollbar.Position > Width then
|
||||||
if TN.Left + TN.Width > Width then
|
HorzScrollBar.Position := TN.Left + TN.Width - (Width - TN.Width div 2);
|
||||||
HorzScrollBar.Position := HorzScrollBar.Position +
|
|
||||||
(TN.Left - (Width - TN.Width - (TN.Width div 2)));
|
|
||||||
end;
|
end;
|
||||||
smBoth:
|
smBoth:
|
||||||
begin
|
begin
|
||||||
if TN.Top < 0 then
|
if TN.Top < VertScrollbar.Position then
|
||||||
VertScrollBar.Position := VertScrollBar.Position +
|
VertScrollBar.Position := TN.Top - TN.Width div 2;
|
||||||
(TN.Top - (TN.Width div 2));
|
if TN.Top + TN.Height > VertScrollbar.Position + Height then
|
||||||
if TN.Top + TN.Height > Height then
|
VertScrollBar.Position := TN.Top + TN.Height - (Height - TN.Height div 2);
|
||||||
VertScrollBar.Position := VertScrollBar.Position +
|
if TN.Left - HorzScrollbar.Position < 0 then
|
||||||
(TN.Top - (TN.Height - (TN.Height div 2)));
|
HorzScrollBar.Position := TN.Left - TN.Width div 2;
|
||||||
if TN.Left < 0 then
|
if TN.Left + TN.Width - HorzScrollbar.Position > Width then
|
||||||
HorzScrollBar.Position := HorzScrollBar.Position +
|
HorzScrollBar.Position := TN.Left + TN.Width - (Width - (TN.Width div 2));
|
||||||
(TN.Left - (TN.Width div 2));
|
|
||||||
if TN.Left + TN.Width > Width then
|
|
||||||
HorzScrollBar.Position := HorzScrollBar.Position +
|
|
||||||
(TN.Left - (Width - TN.Width - (TN.Width div 2)));
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if FSelected <> Number then
|
if FSelected <> Number then
|
||||||
@ -593,7 +586,7 @@ var
|
|||||||
I: Integer;
|
I: Integer;
|
||||||
Tmp1: Longint;
|
Tmp1: Longint;
|
||||||
Tmp2: Longint;
|
Tmp2: Longint;
|
||||||
TN: TJvThumbnail;
|
thumb: TJvThumbnail;
|
||||||
begin
|
begin
|
||||||
if FThumbList = nil then
|
if FThumbList = nil then
|
||||||
exit;
|
exit;
|
||||||
@ -604,13 +597,13 @@ begin
|
|||||||
VertScrollBar.Position := 0;
|
VertScrollBar.Position := 0;
|
||||||
for I := Start to FThumbList.Count - 1 do
|
for I := Start to FThumbList.Count - 1 do
|
||||||
begin
|
begin
|
||||||
TN := TJvThumbnail(FThumbList.Objects[I]);
|
thumb := FThumbList.Thumbnail[I]; //TJvThumbnail(FThumbList.Objects[I]);
|
||||||
if TN <> nil then
|
if thumb <> nil then
|
||||||
begin
|
begin
|
||||||
TN.Left := CalculateXPos(I + 1);
|
thumb.Left := CalculateXPos(I + 1);
|
||||||
TN.Top := CalculateYPos(I + 1);
|
thumb.Top := CalculateYPos(I + 1);
|
||||||
TN.Width := FThumbSize.X;
|
thumb.Width := FThumbSize.X;
|
||||||
TN.Height := FThumbSize.Y;
|
thumb.Height := FThumbSize.Y;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
HorzScrollBar.Position := Tmp2;
|
HorzScrollBar.Position := Tmp2;
|
||||||
@ -726,67 +719,47 @@ end;
|
|||||||
procedure TJvThumbView.MouseDown(Button: TMouseButton; Shift: TShiftState;
|
procedure TJvThumbView.MouseDown(Button: TMouseButton; Shift: TShiftState;
|
||||||
X, Y: Integer);
|
X, Y: Integer);
|
||||||
var
|
var
|
||||||
No: Word;
|
SelNo, No: Word;
|
||||||
TempX, TempY: Longint;
|
TempX, TempY: Longint;
|
||||||
|
thumb: TJvThumbnail;
|
||||||
begin
|
begin
|
||||||
// Check to see if there are any problems removing the following
|
// Check to see if there are any problems removing the following
|
||||||
// For sure it solves A focus problem I'm having in an application
|
// For sure it solves A focus problem I'm having in an application
|
||||||
// setfocus;
|
// setfocus;
|
||||||
if Count > 0 then
|
if Count > 0 then begin
|
||||||
|
SelNo := -1;
|
||||||
case ScrollMode of
|
case ScrollMode of
|
||||||
smVertical, smBoth:
|
smVertical, smBoth:
|
||||||
begin
|
begin
|
||||||
TempX := JkCeil((X + HorzScrollBar.Position) / (FThumbSize.X + FThumbGap));
|
TempX := trunc(X / (FThumbSize.X + FThumbGap));
|
||||||
TempY := JkCeil((Y + VertScrollBar.Position) / (FThumbSize.Y + FThumbGap));
|
TempY := trunc(Y / (FThumbSize.Y + FThumbGap));
|
||||||
if TempX > FMaxX then
|
if TempX >= FMaxX then TempX := FMaxX - 1;
|
||||||
TempX := FMaxX;
|
if TempY < 0 then TempY := 0;
|
||||||
if TempY < 1 then
|
No := TempY * FMaxX + TempX;
|
||||||
TempY := 1;
|
if No < Count then begin
|
||||||
No := ((TempY - 1) * FMaxX + TempX) - 1;
|
thumb := FThumbList.Thumbnail[No];
|
||||||
if No < Count then
|
if thumb <> nil then
|
||||||
if TJvThumbnail(FThumbList.Objects[No]) <> nil then
|
if InRange(thumb.Left, thumb.Left + thumb.Width, X) and
|
||||||
if (X > TJvThumbnail(FThumbList.Objects[No]).Left) and
|
InRange(thumb.Top, thumb.Top + thumb.Height, Y) then SelNo := No;
|
||||||
(X < TJvThumbnail(FThumbList.Objects[No]).Left +
|
end;
|
||||||
TJvThumbnail(FThumbList.Objects[No]).Width) and
|
|
||||||
(Y > TJvThumbnail(FThumbList.Objects[No]).Top) and
|
|
||||||
(Y < TJvThumbnail(FThumbList.Objects[No]).Top +
|
|
||||||
TJvThumbnail(FThumbList.Objects[No]).Height) then
|
|
||||||
SetSelected(No)
|
|
||||||
else
|
|
||||||
SetSelected(-1)
|
|
||||||
else
|
|
||||||
SetSelected(-1)
|
|
||||||
else
|
|
||||||
SetSelected(-1);
|
|
||||||
end;
|
end;
|
||||||
smHorizontal:
|
smHorizontal:
|
||||||
begin
|
begin
|
||||||
TempX := JkCeil((X + HorzScrollBar.Position) / (FThumbSize.X + FThumbGap));
|
TempX := trunc(X / (FThumbSize.X + FThumbGap));
|
||||||
TempY := JkCeil((Y + VertScrollBar.Position) / (FThumbSize.Y + FThumbGap));
|
TempY := trunc(Y / (FThumbSize.Y + FThumbGap));
|
||||||
if TempY > FMaxX then
|
if TempY >= FMaxX then TempY := FMaxX - 1;
|
||||||
TempY := FMaxX;
|
if TempX < 0 then TempX := 0;
|
||||||
if TempX < 1 then
|
No := TempX * FMaxX + TempY;
|
||||||
TempX := 1;
|
if No < Count then begin
|
||||||
No := ((TempX - 1) * FMaxX + TempY) - 1;
|
thumb := TJvThumbnail(FThumbList.Objects[No]);
|
||||||
if No < Count then
|
if thumb <> nil then
|
||||||
if TJvThumbnail(FThumbList.Objects[No]) <> nil then
|
if InRange(thumb.Left, thumb.Left + thumb.Width, X) and
|
||||||
if (X > TJvThumbnail(FThumbList.Objects[No]).Left) and
|
InRange(thumb.Top, thumb.Top + thumb.Height, Y) then SelNo := No;
|
||||||
(X < TJvThumbnail(FThumbList.Objects[No]).Left +
|
end;
|
||||||
TJvThumbnail(FThumbList.Objects[No]).Width) and
|
|
||||||
(Y > TJvThumbnail(FThumbList.Objects[No]).Top) and
|
|
||||||
(Y < TJvThumbnail(FThumbList.Objects[No]).Top +
|
|
||||||
TJvThumbnail(FThumbList.Objects[No]).Height) then
|
|
||||||
SetSelected(No)
|
|
||||||
else
|
|
||||||
SetSelected(-1)
|
|
||||||
else
|
|
||||||
SetSelected(-1)
|
|
||||||
else
|
|
||||||
SetSelected(-1);
|
|
||||||
end;
|
end;
|
||||||
else
|
|
||||||
SetSelected(-1);
|
|
||||||
end;
|
end;
|
||||||
|
SetSelected(SelNo);
|
||||||
|
end;
|
||||||
inherited MouseDown(Button, Shift, X, Y);
|
inherited MouseDown(Button, Shift, X, Y);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user