Merged revision(s) 59886 #efa6764860, 59893 #7a61d8d829 from trunk:

Qt,Qt5: implemented TQtWSCustomListView.GetHitTestInfoAt(), TQtWSCustomListView.ItemSetStateImage(), draw StateImages in virtual mode. issue #34742
........
Qt5: fixed wrong Left & Top form positions when form is wsMaximized under MacOS. issue #34698
........

git-svn-id: branches/fixes_2_0@59909 -
This commit is contained in:
maxim 2018-12-24 22:50:09 +00:00
parent 21c68350ce
commit a73d9b8eec
4 changed files with 428 additions and 17 deletions

View File

@ -12524,7 +12524,7 @@ var
TopItem: Integer;
i: Integer;
VHeight: Integer; // viewport height
RowHeight: Integer;
RowHeight, AImagesWidth: Integer;
item: QListWidgetItemH;
v, v2, v3: QVariantH;
WStr, DataStr: WideString;
@ -12532,7 +12532,7 @@ var
AImageIndex: TImageIndex;
Bmp: TBitmap;
AIcon: QIconH;
AOk: Boolean;
AOk, AStateImages: Boolean;
ASize: TSize;
ImgListRes: TScaledImageListResolution;
begin
@ -12570,11 +12570,21 @@ begin
if (TopItem < 0) or (TopItem > TCustomListViewHack(LCLObject).Items.Count - 1) then
break;
AStateImages := False;
ImgList := TCustomListViewHack(LCLObject).SmallImages;
if Assigned(ImgList) then
AImagesWidth := TCustomListViewHack(LCLObject).SmallImagesWidth
else
begin
ImgList := TCustomListViewHack(LCLObject).StateImages;
if Assigned(ImgList) then
AImagesWidth := TCustomListViewHack(LCLObject).StateImagesWidth;
AStateImages := True;
end;
if Assigned(ImgList) then
begin
ImgListRes := ImgList.ResolutionForPPI[
TCustomListViewHack(LCLObject).SmallImagesWidth,
AImagesWidth,
TCustomListViewHack(LCLObject).Font.PixelsPerInch,
TCustomListViewHack(LCLObject).GetCanvasScaleFactor];
QListWidgetItem_sizeHint(item, @ASize);
@ -12584,7 +12594,10 @@ begin
ASize.cy := ImgListRes.Height;
QListWidgetItem_setSizeHint(item, @ASize);
end;
AImageIndex := TCustomListViewHack(LCLObject).Items[TopItem].ImageIndex;
if AStateImages then
AImageIndex := TCustomListViewHack(LCLObject).Items[TopItem].StateIndex
else
AImageIndex := TCustomListViewHack(LCLObject).Items[TopItem].ImageIndex;
if (ImgListRes.Count > 0) and
((AImageIndex >= 0) and (AImageIndex < ImgListRes.Count)) then
begin
@ -14700,7 +14713,7 @@ var
j: Integer;
ChildCount: Integer;
VHeight: Integer; // viewport height
RowHeight: Integer;
RowHeight, AImagesWidth: Integer;
item: QTreeWidgetItemH;
itemChild: QTreeWidgetItemH;
v,v2,v3: QVariantH;
@ -14709,7 +14722,7 @@ var
ImgList: TCustomImageList;
AImageIndex: TImageIndex;
Bmp: TBitmap;
AOk: Boolean;
AOk, AStateImages: Boolean;
AIcon: QIconH;
ASize: TSize;
ImgListRes: TScaledImageListResolution;
@ -14764,12 +14777,22 @@ begin
QVariant_destroy(v2);
end;
AStateImages := False;
// set imageindex, part of comment in issue #27233
ImgList := TCustomListViewHack(LCLObject).SmallImages;
if Assigned(ImgList) then
AImagesWidth := TCustomListViewHack(LCLObject).SmallImagesWidth
else
begin
ImgList := TCustomListViewHack(LCLObject).StateImages;
if Assigned(ImgList) then
AImagesWidth := TCustomListViewHack(LCLObject).StateImagesWidth;
AStateImages := True;
end;
if Assigned(ImgList) then
begin
ImgListRes := ImgList.ResolutionForPPI[
TCustomListViewHack(LCLObject).SmallImagesWidth,
AImagesWidth,
TCustomListViewHack(LCLObject).Font.PixelsPerInch,
TCustomListViewHack(LCLObject).GetCanvasScaleFactor];
QTreeWidgetItem_sizeHint(item, @ASize, 0);
@ -14779,7 +14802,10 @@ begin
ASize.cy := ImgListRes.Height;
QTreeWidgetItem_setSizeHint(item, 0, @ASize);
end;
AImageIndex := TCustomListViewHack(LCLObject).Items[TopItem].ImageIndex;
if AStateImages then
AImageIndex := TCustomListViewHack(LCLObject).Items[TopItem].StateIndex
else
AImageIndex := TCustomListViewHack(LCLObject).Items[TopItem].ImageIndex;
if (ImgListRes.Count > 0) and
((AImageIndex >= 0) and (AImageIndex < ImgListRes.Count)) then
begin

View File

@ -141,6 +141,7 @@ type
class function ItemGetState(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const AState: TListItemState; out AIsSet: Boolean): Boolean; override; // returns True if supported
class procedure ItemSetImage(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const ASubIndex, AImageIndex: Integer); override;
class procedure ItemSetState(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const AState: TListItemState; const AIsSet: Boolean); override;
class procedure ItemSetStateImage(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const ASubIndex, AStateImageIndex: Integer); override;
class procedure ItemSetText(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const ASubIndex: Integer; const AText: String); override;
class procedure ItemShow(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const PartialOK: Boolean); override;
class function ItemDisplayRect(const ALV: TCustomListView; const AIndex, ASubItem: Integer; ACode: TDisplayCode): TRect; override;
@ -150,6 +151,7 @@ type
class procedure EndUpdate(const ALV: TCustomListView); override;
class function GetFocused(const ALV: TCustomListView): Integer; override;
class function GetHitTestInfoAt( const ALV: TCustomListView; X, Y: Integer ) : THitTests; override;
class function GetItemAt(const ALV: TCustomListView; x,y: integer): Integer; override;
class function GetSelCount(const ALV: TCustomListView): Integer; override;
class function GetSelection(const ALV: TCustomListView): Integer; override;
@ -1298,6 +1300,8 @@ begin
end;
end else
begin
if Assigned(TCustomListViewHack(ALV).StateImages) and (AItem.StateIndex >= 0) then
exit;
if LWI <> nil then
QListWidgetItem_setIcon(LWI, nil)
else
@ -1387,6 +1391,66 @@ begin
end;
end;
class procedure TQtWSCustomListView.ItemSetStateImage(
const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem;
const ASubIndex, AStateImageIndex: Integer);
var
QtListWidget: TQtListWidget;
LWI: QListWidgetItemH;
QtTreeWidget: TQtTreeWidget;
TWI: QTreeWidgetItemH;
Bmp: TBitmap;
ImgListRes: TScaledImageListResolution;
AImgList: TCustomImageList;
AImgListWidth: Integer;
begin
if not WSCheckHandleAllocated(ALV, 'ItemSetStateImage') then
Exit;
if not Assigned(TCustomListViewHack(ALV).StateImages) then
exit;
TWI := nil;
LWI := nil;
if IsIconView(ALV) then
begin
if ASubIndex > 0 then
exit;
QtListWidget := TQtListWidget(ALV.Handle);
LWI := QtListWidget.getItem(AIndex);
end else
begin
QtTreeWidget := TQtTreeWidget(ALV.Handle);
TWI := QtTreeWidget.topLevelItem(AIndex);
end;
if (TWI <> nil) or (LWI <> nil) then
begin
AImgList := TCustomListViewHack(ALV).StateImages;
AImgListWidth := TCustomListViewHack(ALV).StateImagesWidth;
ImgListRes := AImgList.ResolutionForControl[AImgListWidth, ALV];
if ImgListRes.Valid and
((AStateImageIndex >= 0) and (AStateImageIndex < ImgListRes.Count)) then
begin
Bmp := TBitmap.Create;
try
ImgListRes.GetBitmap(AStateImageIndex, Bmp);
if LWI <> nil then
QListWidgetItem_setIcon(LWI, TQtImage(Bmp.Handle).AsIcon)
else
QTreeWidgetItem_setIcon(TWI, ASubIndex, TQtImage(Bmp.Handle).AsIcon);
finally
Bmp.Free;
end;
end else
begin
if LWI <> nil then
QListWidgetItem_setIcon(LWI, nil)
else
QTreeWidgetItem_setIcon(TWI, ASubIndex, nil);
end;
end;
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomListView.ItemInsert
Params: None
@ -1747,6 +1811,109 @@ begin
end;
end;
class function TQtWSCustomListView.GetHitTestInfoAt(const ALV: TCustomListView;
X, Y: Integer): THitTests;
var
I, AImgListWidth, Ax: Integer;
QtListWidget: TQtListWidget;
QtTreeWidget: TQtTreeWidget;
LWI: QListWidgetItemH;
TWI: QTreeWidgetItemH;
AImgList: TCustomImageList;
AImgListRes: TScaledImageListResolution;
AListSpacing, AFocusFrame: integer;
begin
Result := [];
if not WSCheckHandleAllocated(ALV, 'GetHitTestInfoAt') then
Exit;
I := GetItemAt(ALV, x, y);
AFocusFrame := 2;
AListSpacing := 4; {default, we are using pixelMetric() for real spacing}
AX := 0;
if I >= 0 then
begin
Include(Result, htOnItem);
if Assigned(TCustomListViewHack(ALV).LargeImages) or Assigned(TCustomListViewHack(ALV).SmallImages) or
Assigned(TCustomListViewHack(ALV).StateImages) then
begin
if IsIconView(ALV) then
begin
QtListWidget := TQtListWidget(ALV.Handle);
LWI := QtListWidget.getItem(I);
AFocusFrame := QStyle_pixelMetric(QApplication_style(), QStylePM_FocusFrameHMargin, nil, QtListWidget.Widget);
AListSpacing := QStyle_pixelMetric(QApplication_style(), QStylePM_CheckBoxLabelSpacing, nil, QtListWidget.Widget);
// AItemRect := QtListWidget.getVisualItemRect(LWI);
end else
begin
QtTreeWidget := TQtTreeWidget(ALV.Handle);
TWI := QtTreeWidget.topLevelItem(I);
AFocusFrame := QStyle_pixelMetric(QApplication_style(), QStylePM_FocusFrameHMargin, nil, QtTreeWidget.Widget);
AListSpacing := QStyle_pixelMetric(QApplication_style(), QStylePM_CheckBoxLabelSpacing, nil, QtTreeWidget.Widget);
// AItemRect := QtTreeWidget.visualItemRect(TWI);
end;
if Assigned(TCustomListViewHack(ALV).StateImages) and (ALV.Items[I].StateIndex >= 0) then
begin
if Assigned(TWI) or Assigned(LWI) then
begin
AImgList := TCustomListViewHack(ALV).StateImages;
AImgListWidth := TCustomListViewHack(ALV).StateImagesWidth;
AImgListRes := AImgList.ResolutionForControl[AImgListWidth, ALV];
if AImgListRes.Valid then
begin
if (x >= AListSpacing) and (x <= AImgListRes.Width + AFocusFrame) then
include(Result, htOnStateIcon);
Ax += AImgListRes.Width + AListSpacing;
end;
end;
end;
if Assigned(TCustomListViewHack(ALV).SmallImages) and (ALV.Items[I].ImageIndex >= 0) then
begin
if Assigned(TWI) or Assigned(LWI) then
begin
AImgList := TCustomListViewHack(ALV).SmallImages;
AImgListWidth := TCustomListViewHack(ALV).SmallImagesWidth;
AImgListRes := AImgList.ResolutionForControl[AImgListWidth, ALV];
if AImgListRes.Valid and (x >= AListSpacing) and (x <= AImgListRes.Width + AFocusFrame) then
begin
include(Result, htOnIcon);
Ax += AImgListRes.Width + AListSpacing;
end;
end;
end else
if Assigned(TCustomListViewHack(ALV).LargeImages) and (ALV.Items[I].ImageIndex >= 0) then
begin
if Assigned(TWI) or Assigned(LWI) then
begin
AImgList := TCustomListViewHack(ALV).LargeImages;
AImgListWidth := TCustomListViewHack(ALV).LargeImagesWidth;
AImgListRes := AImgList.ResolutionForControl[AImgListWidth, ALV];
if AImgListRes.Valid and (x >= AListSpacing) and (x <= AImgListRes.Width + AFocusFrame) then
begin
include(Result, htOnIcon);
Ax += AImgListRes.Width + AListSpacing;
end;
end;
end;
if [htOnIcon, htOnStateIcon] * Result = [] then
begin
if x >= (AX + AFocusFrame) then
include(Result, htOnLabel);
end;
end;
end else
begin
if PtInRect(ALV.ClientRect, Point(x, y)) then
Result := [THitTest.htNowhere];
end;
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomListView.GetItemAt
Params: None
@ -1926,6 +2093,11 @@ begin
AImgList := nil;
AImgListWidth := 0;
end;
if AImgList = nil then
begin
AImgList := LV.StateImages;
AImgListWidth := LV.StateImagesWidth;
end;
if AImgList<>nil then
AImgListRes := AImgList.ResolutionForControl[AImgListWidth, ALV]
else

View File

@ -3986,7 +3986,7 @@ begin
if QtWidgetSet.IsWidgetAtCache(HWND(Self)) then
QtWidgetSet.InvalidateWidgetAtCache;
// do not loop with LCL
if InUpdate then
if InUpdate {$ifdef darwin} and not (qtwsForceSendMove in WidgetState){$endif} then
exit;
ForceSendMove := False; {mantis #34589}
@ -3994,6 +3994,16 @@ begin
// only children of 1st level should move.
ForceSendMove := qtwsForceSendMove in TQtWidget(LCLObject.Parent.Handle).WidgetState;
{$ifdef darwin}
// issue #34698
if not ForceSendMove and not QEvent_spontaneous(Event) and Assigned(LCLObject) and
(Self is TQtMainWindow) and not TQtMainWindow(Self).IsMdiChild then
begin
ForceSendMove := qtwsForceSendMove in WidgetState;
Exclude(FWidgetState, qtwsForceSendMove);
end;
{$endif}
if ForceSendMove then
// send message mantis #34589
else
@ -7811,6 +7821,11 @@ begin
end;
QEventResize:
begin
// issue #34698
{$ifdef darwin}
if (QResizeEvent_oldSize(QResizeEventH(Event))^.cx = -1) and (QResizeEvent_oldSize(QResizeEventH(Event))^.cy = -1) then
include(FWidgetState, qtwsForceSendMove);
{$endif}
{$IFDEF QTSCROLLABLEFORMS}
if not Assigned(ScrollArea) then
{$ENDIF}
@ -12472,7 +12487,7 @@ var
TopItem: Integer;
i: Integer;
VHeight: Integer; // viewport height
RowHeight: Integer;
RowHeight, AImagesWidth: Integer;
item: QListWidgetItemH;
v, v2, v3: QVariantH;
WStr: WideString;
@ -12481,7 +12496,7 @@ var
AImageIndex: TImageIndex;
Bmp: TBitmap;
AIcon: QIconH;
AOk: Boolean;
AOk, AStateImages: Boolean;
ASize: TSize;
ImgListRes: TScaledImageListResolution;
begin
@ -12519,11 +12534,21 @@ begin
if (TopItem < 0) or (TopItem > TCustomListViewHack(LCLObject).Items.Count - 1) then
break;
AStateImages := False;
ImgList := TCustomListViewHack(LCLObject).SmallImages;
if Assigned(ImgList) then
AImagesWidth := TCustomListViewHack(LCLObject).SmallImagesWidth
else
begin
ImgList := TCustomListViewHack(LCLObject).StateImages;
if Assigned(ImgList) then
AImagesWidth := TCustomListViewHack(LCLObject).StateImagesWidth;
AStateImages := True;
end;
if Assigned(ImgList) then
begin
ImgListRes := ImgList.ResolutionForPPI[
TCustomListViewHack(LCLObject).SmallImagesWidth,
AImagesWidth,
TCustomListViewHack(LCLObject).Font.PixelsPerInch,
TCustomListViewHack(LCLObject).GetCanvasScaleFactor];
QListWidgetItem_sizeHint(item, @ASize);
@ -12533,7 +12558,10 @@ begin
ASize.cy := ImgListRes.Height;
QListWidgetItem_setSizeHint(item, @ASize);
end;
AImageIndex := TCustomListViewHack(LCLObject).Items[TopItem].ImageIndex;
if AStateImages then
AImageIndex := TCustomListViewHack(LCLObject).Items[TopItem].StateIndex
else
AImageIndex := TCustomListViewHack(LCLObject).Items[TopItem].ImageIndex;
if (ImgListRes.Count > 0) and
((AImageIndex >= 0) and (AImageIndex < ImgListRes.Count)) then
begin
@ -14655,7 +14683,7 @@ var
j: Integer;
ChildCount: Integer;
VHeight: Integer; // viewport height
RowHeight: Integer;
RowHeight, AImagesWidth: Integer;
item: QTreeWidgetItemH;
itemChild: QTreeWidgetItemH;
v,v2,v3: QVariantH;
@ -14664,7 +14692,7 @@ var
ImgList: TCustomImageList;
AImageIndex: TImageIndex;
Bmp: TBitmap;
AOk: Boolean;
AOk, AStateImages: Boolean;
AIcon: QIconH;
ASize: TSize;
ImgListRes: TScaledImageListResolution;
@ -14719,12 +14747,22 @@ begin
QVariant_destroy(v2);
end;
AStateImages := False;
// set imageindex, part of comment in issue #27233
ImgList := TCustomListViewHack(LCLObject).SmallImages;
if Assigned(ImgList) then
AImagesWidth := TCustomListViewHack(LCLObject).SmallImagesWidth
else
begin
ImgList := TCustomListViewHack(LCLObject).StateImages;
if Assigned(ImgList) then
AImagesWidth := TCustomListViewHack(LCLObject).StateImagesWidth;
AStateImages := True;
end;
if Assigned(ImgList) then
begin
ImgListRes := ImgList.ResolutionForPPI[
TCustomListViewHack(LCLObject).SmallImagesWidth,
AImagesWidth,
TCustomListViewHack(LCLObject).Font.PixelsPerInch,
TCustomListViewHack(LCLObject).GetCanvasScaleFactor];
QTreeWidgetItem_sizeHint(item, @ASize, 0);
@ -14734,7 +14772,10 @@ begin
ASize.cy := ImgListRes.Height;
QTreeWidgetItem_setSizeHint(item, 0, @ASize);
end;
AImageIndex := TCustomListViewHack(LCLObject).Items[TopItem].ImageIndex;
if AStateImages then
AImageIndex := TCustomListViewHack(LCLObject).Items[TopItem].StateIndex
else
AImageIndex := TCustomListViewHack(LCLObject).Items[TopItem].ImageIndex;
if (ImgListRes.Count > 0) and
((AImageIndex >= 0) and (AImageIndex < ImgListRes.Count)) then
begin

View File

@ -140,6 +140,7 @@ type
class function ItemGetState(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const AState: TListItemState; out AIsSet: Boolean): Boolean; override; // returns True if supported
class procedure ItemSetImage(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const ASubIndex, AImageIndex: Integer); override;
class procedure ItemSetState(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const AState: TListItemState; const AIsSet: Boolean); override;
class procedure ItemSetStateImage(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const ASubIndex, AStateImageIndex: Integer); override;
class procedure ItemSetText(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const ASubIndex: Integer; const AText: String); override;
class procedure ItemShow(const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem; const PartialOK: Boolean); override;
class function ItemDisplayRect(const ALV: TCustomListView; const AIndex, ASubItem: Integer; ACode: TDisplayCode): TRect; override;
@ -149,6 +150,7 @@ type
class procedure EndUpdate(const ALV: TCustomListView); override;
class function GetFocused(const ALV: TCustomListView): Integer; override;
class function GetHitTestInfoAt( const ALV: TCustomListView; X, Y: Integer ) : THitTests; override;
class function GetItemAt(const ALV: TCustomListView; x,y: integer): Integer; override;
class function GetSelCount(const ALV: TCustomListView): Integer; override;
class function GetSelection(const ALV: TCustomListView): Integer; override;
@ -1297,6 +1299,8 @@ begin
end;
end else
begin
if Assigned(TCustomListViewHack(ALV).StateImages) and (AItem.StateIndex >= 0) then
exit;
if LWI <> nil then
QListWidgetItem_setIcon(LWI, nil)
else
@ -1386,6 +1390,66 @@ begin
end;
end;
class procedure TQtWSCustomListView.ItemSetStateImage(
const ALV: TCustomListView; const AIndex: Integer; const AItem: TListItem;
const ASubIndex, AStateImageIndex: Integer);
var
QtListWidget: TQtListWidget;
LWI: QListWidgetItemH;
QtTreeWidget: TQtTreeWidget;
TWI: QTreeWidgetItemH;
Bmp: TBitmap;
ImgListRes: TScaledImageListResolution;
AImgList: TCustomImageList;
AImgListWidth: Integer;
begin
if not WSCheckHandleAllocated(ALV, 'ItemSetStateImage') then
Exit;
if not Assigned(TCustomListViewHack(ALV).StateImages) then
exit;
TWI := nil;
LWI := nil;
if IsIconView(ALV) then
begin
if ASubIndex > 0 then
exit;
QtListWidget := TQtListWidget(ALV.Handle);
LWI := QtListWidget.getItem(AIndex);
end else
begin
QtTreeWidget := TQtTreeWidget(ALV.Handle);
TWI := QtTreeWidget.topLevelItem(AIndex);
end;
if (TWI <> nil) or (LWI <> nil) then
begin
AImgList := TCustomListViewHack(ALV).StateImages;
AImgListWidth := TCustomListViewHack(ALV).StateImagesWidth;
ImgListRes := AImgList.ResolutionForControl[AImgListWidth, ALV];
if ImgListRes.Valid and
((AStateImageIndex >= 0) and (AStateImageIndex < ImgListRes.Count)) then
begin
Bmp := TBitmap.Create;
try
ImgListRes.GetBitmap(AStateImageIndex, Bmp);
if LWI <> nil then
QListWidgetItem_setIcon(LWI, TQtImage(Bmp.Handle).AsIcon)
else
QTreeWidgetItem_setIcon(TWI, ASubIndex, TQtImage(Bmp.Handle).AsIcon);
finally
Bmp.Free;
end;
end else
begin
if LWI <> nil then
QListWidgetItem_setIcon(LWI, nil)
else
QTreeWidgetItem_setIcon(TWI, ASubIndex, nil);
end;
end;
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomListView.ItemInsert
Params: None
@ -1752,6 +1816,109 @@ begin
end;
end;
class function TQtWSCustomListView.GetHitTestInfoAt(const ALV: TCustomListView;
X, Y: Integer): THitTests;
var
I, AImgListWidth, Ax: Integer;
QtListWidget: TQtListWidget;
QtTreeWidget: TQtTreeWidget;
LWI: QListWidgetItemH;
TWI: QTreeWidgetItemH;
AImgList: TCustomImageList;
AImgListRes: TScaledImageListResolution;
AListSpacing, AFocusFrame: integer;
begin
Result := [];
if not WSCheckHandleAllocated(ALV, 'GetHitTestInfoAt') then
Exit;
I := GetItemAt(ALV, x, y);
AFocusFrame := 2;
AListSpacing := 4; {default, we are using pixelMetric() for real spacing}
AX := 0;
if I >= 0 then
begin
Include(Result, htOnItem);
if Assigned(TCustomListViewHack(ALV).LargeImages) or Assigned(TCustomListViewHack(ALV).SmallImages) or
Assigned(TCustomListViewHack(ALV).StateImages) then
begin
if IsIconView(ALV) then
begin
QtListWidget := TQtListWidget(ALV.Handle);
LWI := QtListWidget.getItem(I);
AFocusFrame := QStyle_pixelMetric(QApplication_style(), QStylePM_FocusFrameHMargin, nil, QtListWidget.Widget);
AListSpacing := QStyle_pixelMetric(QApplication_style(), QStylePM_CheckBoxLabelSpacing, nil, QtListWidget.Widget);
// AItemRect := QtListWidget.getVisualItemRect(LWI);
end else
begin
QtTreeWidget := TQtTreeWidget(ALV.Handle);
TWI := QtTreeWidget.topLevelItem(I);
AFocusFrame := QStyle_pixelMetric(QApplication_style(), QStylePM_FocusFrameHMargin, nil, QtTreeWidget.Widget);
AListSpacing := QStyle_pixelMetric(QApplication_style(), QStylePM_CheckBoxLabelSpacing, nil, QtTreeWidget.Widget);
// AItemRect := QtTreeWidget.visualItemRect(TWI);
end;
if Assigned(TCustomListViewHack(ALV).StateImages) and (ALV.Items[I].StateIndex >= 0) then
begin
if Assigned(TWI) or Assigned(LWI) then
begin
AImgList := TCustomListViewHack(ALV).StateImages;
AImgListWidth := TCustomListViewHack(ALV).StateImagesWidth;
AImgListRes := AImgList.ResolutionForControl[AImgListWidth, ALV];
if AImgListRes.Valid then
begin
if (x >= AListSpacing) and (x <= AImgListRes.Width + AFocusFrame) then
include(Result, htOnStateIcon);
Ax += AImgListRes.Width + AListSpacing;
end;
end;
end;
if Assigned(TCustomListViewHack(ALV).SmallImages) and (ALV.Items[I].ImageIndex >= 0) then
begin
if Assigned(TWI) or Assigned(LWI) then
begin
AImgList := TCustomListViewHack(ALV).SmallImages;
AImgListWidth := TCustomListViewHack(ALV).SmallImagesWidth;
AImgListRes := AImgList.ResolutionForControl[AImgListWidth, ALV];
if AImgListRes.Valid and (x >= AListSpacing) and (x <= AImgListRes.Width + AFocusFrame) then
begin
include(Result, htOnIcon);
Ax += AImgListRes.Width + AListSpacing;
end;
end;
end else
if Assigned(TCustomListViewHack(ALV).LargeImages) and (ALV.Items[I].ImageIndex >= 0) then
begin
if Assigned(TWI) or Assigned(LWI) then
begin
AImgList := TCustomListViewHack(ALV).LargeImages;
AImgListWidth := TCustomListViewHack(ALV).LargeImagesWidth;
AImgListRes := AImgList.ResolutionForControl[AImgListWidth, ALV];
if AImgListRes.Valid and (x >= AListSpacing) and (x <= AImgListRes.Width + AFocusFrame) then
begin
include(Result, htOnIcon);
Ax += AImgListRes.Width + AListSpacing;
end;
end;
end;
if [htOnIcon, htOnStateIcon] * Result = [] then
begin
if x >= (AX + AFocusFrame) then
include(Result, htOnLabel);
end;
end;
end else
begin
if PtInRect(ALV.ClientRect, Point(x, y)) then
Result := [THitTest.htNowhere];
end;
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomListView.GetItemAt
Params: None
@ -1931,6 +2098,11 @@ begin
AImgList := nil;
AImgListWidth := 0;
end;
if AImgList = nil then
begin
AImgList := LV.StateImages;
AImgListWidth := LV.StateImagesWidth;
end;
if AImgList<>nil then
AImgListRes := AImgList.ResolutionForControl[AImgListWidth, ALV]
else