mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-10 10:55:54 +02:00
implemnted CarbonListView ColumnClick
git-svn-id: trunk@19929 -
This commit is contained in:
parent
2ffb8e87be
commit
c4203802c6
@ -212,6 +212,7 @@ type
|
|||||||
|
|
||||||
procedure ClearIconCache;
|
procedure ClearIconCache;
|
||||||
|
|
||||||
|
procedure DoColumnClicked(MouseX,MouseY: Integer);
|
||||||
function NeedDeliverMouseEvent(Msg: Integer; const AMessage): Boolean; override;
|
function NeedDeliverMouseEvent(Msg: Integer; const AMessage): Boolean; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1605,33 +1606,110 @@ begin
|
|||||||
FIcons.Clear;
|
FIcons.Clear;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCarbonListView.NeedDeliverMouseEvent(Msg: Integer; const AMessage): Boolean;
|
procedure TCarbonListView.DoColumnClicked(MouseX, MouseY: Integer);
|
||||||
|
type
|
||||||
|
TColumnInfo = record
|
||||||
|
Index : Integer;
|
||||||
|
Width : Integer;
|
||||||
|
end;
|
||||||
var
|
var
|
||||||
h : UInt16;
|
cx, cl : Integer;
|
||||||
y : Integer;
|
ci : DataBrowserTableViewColumnIndex;
|
||||||
|
order : array of TColumnInfo;
|
||||||
|
i : Integer;
|
||||||
|
|
||||||
|
msg : TLMNotify;
|
||||||
|
NM : TNMListView;
|
||||||
|
begin
|
||||||
|
SetLength(order, FColumns.Count);
|
||||||
|
for i := 0 to FColumns.Count - 1 do
|
||||||
|
begin
|
||||||
|
if GetDataBrowserTableViewColumnPosition(Content, GetColumn(i).PropertyID, ci) = noErr then
|
||||||
|
if (ci >= 0) and (ci<FColumns.Count) then
|
||||||
|
begin
|
||||||
|
order[ci].Index := i;
|
||||||
|
order[ci].Width := GetColumn(i).GetWidth;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
cx := 0;
|
||||||
|
cl := -1;
|
||||||
|
for i := 0 to length(order) - 1 do
|
||||||
|
begin
|
||||||
|
inc(cx, order[i].Width);
|
||||||
|
if MouseX < cx then
|
||||||
|
begin
|
||||||
|
cl := order[i].Index;
|
||||||
|
Break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if (cl>=0) and (cl < FColumns.Count) then
|
||||||
|
begin
|
||||||
|
msg.Msg := CN_NOTIFY;
|
||||||
|
FillChar(NM, SizeOf(NM), 0);
|
||||||
|
NM.hdr.hwndfrom := PtrUInt(Self);
|
||||||
|
NM.hdr.code := LVN_COLUMNCLICK;
|
||||||
|
NM.iItem := -1;
|
||||||
|
NM.iSubItem := cl;
|
||||||
|
msg.NMHdr := @NM.hdr;
|
||||||
|
DeliverMessage(Self.LCLObject, msg);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCarbonListView.NeedDeliverMouseEvent(Msg: Integer; const AMessage): Boolean;
|
||||||
type
|
type
|
||||||
PLMMouse = ^TLMMouse;
|
PLMMouse = ^TLMMouse;
|
||||||
PLMMouseMove = ^TLMMouseMove;
|
PLMMouseMove = ^TLMMouseMove;
|
||||||
|
var
|
||||||
|
h: UInt16;
|
||||||
|
x, y: Integer;
|
||||||
|
scrolltop, scrollleft : UInt32;
|
||||||
|
|
||||||
// for some unkown reason, HIViewConvertPoint does return inaccurate x,y position for ListView
|
// for some unkown reason, HIViewConvertPoint does return inaccurate x,y position for ListView
|
||||||
// (because of focus ring?)
|
// (because of focus ring?)
|
||||||
const
|
const
|
||||||
OfsY = -2;
|
OfsY = -2;
|
||||||
|
OfsX = -4;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if Assigned(LCLObject) and (TListView(LCLObject).Columns.Count > 0) and
|
if Assigned(LCLObject) and (TListView(LCLObject).Columns.Count > 0) and
|
||||||
(TListView(LCLObject).ViewStyle = vsReport) then
|
(TListView(LCLObject).ViewStyle = vsReport) then
|
||||||
begin
|
begin
|
||||||
case Msg of
|
case Msg of
|
||||||
LM_LBUTTONDOWN..LM_MBUTTONDBLCLK: y := PLMMouse(@AMessage)^.YPos;
|
LM_LBUTTONDOWN..LM_MBUTTONDBLCLK:
|
||||||
LM_MOUSEMOVE: y := PLMMouseMove(@AMessage)^.YPos ;
|
begin
|
||||||
LM_MOUSEWHEEL: y := PLMMouseEvent(@AMessage)^.Y;
|
y := PLMMouse(@AMessage)^.YPos;
|
||||||
|
x := PLMMouse(@AMessage)^.XPos;
|
||||||
|
end;
|
||||||
|
LM_MOUSEMOVE:
|
||||||
|
begin
|
||||||
|
y := PLMMouseMove(@AMessage)^.YPos;
|
||||||
|
x := PLMMouseMove(@AMessage)^.XPos;
|
||||||
|
end;
|
||||||
|
|
||||||
|
LM_MOUSEWHEEL:
|
||||||
|
begin
|
||||||
|
y := PLMMouseEvent(@AMessage)^.Y;
|
||||||
|
x := PLMMouseEvent(@AMessage)^.X;
|
||||||
|
end;
|
||||||
else
|
else
|
||||||
Result := inherited NeedDeliverMouseEvent(msg, AMessage);
|
Result := inherited NeedDeliverMouseEvent(msg, AMessage);
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
GetDataBrowserListViewHeaderBtnHeight(Content, h);
|
GetDataBrowserListViewHeaderBtnHeight(Content, h);
|
||||||
inc(y, OfsY);
|
inc(y, OfsY);
|
||||||
Result := y > h;
|
Result := y > h;
|
||||||
|
|
||||||
|
if not Result and (Msg = LM_LBUTTONUP) then
|
||||||
|
begin
|
||||||
|
GetDataBrowserScrollPosition(Content, scrolltop, scrollleft );
|
||||||
|
inc(x, Integer(scrollleft) + OfsX);
|
||||||
|
|
||||||
|
DoColumnClicked(x,y);
|
||||||
|
end;
|
||||||
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Result := inherited NeedDeliverMouseEvent(msg, AMessage);
|
Result := inherited NeedDeliverMouseEvent(msg, AMessage);
|
||||||
|
Loading…
Reference in New Issue
Block a user