CarbonListView + column sorting partial support + column moving + windows-like mouse handling at for ListView's header

git-svn-id: trunk@19910 -
This commit is contained in:
dmitry 2009-05-10 17:45:34 +00:00
parent f3dfb636c4
commit 1760ca6826
4 changed files with 74 additions and 18 deletions

View File

@ -87,6 +87,7 @@ type
procedure ControlAdded; dynamic;
function FilterKeyPress(SysKey: Boolean; const Char: TUTF8Char): Boolean; dynamic;
procedure ProcessKeyEvent(const msg: TLMKey; var Result: OSStatus); virtual;
function NeedDeliverMouseEvent(Msg: Integer; const AMessage): Boolean; virtual;
public
constructor Create(const AObject: TWinControl; const AParams: TCreateParams);
destructor Destroy; override;
@ -614,6 +615,11 @@ procedure TCarbonWidget.ProcessKeyEvent(const msg: TLMKey; var Result: OSStatus)
begin
end;
function TCarbonWidget.NeedDeliverMouseEvent(Msg: Integer; const AMessage): Boolean;
begin
Result := true;
end;
{------------------------------------------------------------------------------
Method: TCarbonWidget.Create
Params: AObject - LCL conrol

View File

@ -211,6 +211,8 @@ type
procedure UpdateColumnView; override;
procedure ClearIconCache;
function NeedDeliverMouseEvent(Msg: Integer; const AMessage): Boolean; override;
end;
{ TCarbonListBox }
@ -404,7 +406,9 @@ function TCarbonListColumn.GetHeaderPropertyFlags: Integer;
begin
Result := kDataBrowserPropertyIsMutable or
kDataBrowserListViewSelectionColumn or
kDataBrowserListViewTypeSelectColumn;
kDataBrowserListViewTypeSelectColumn or
kDataBrowserListViewSortableColumn or
kDataBrowserListViewMovableColumn;
end;
constructor TCarbonListColumn.Create(AOwner: TCarbonDataBrowser;
@ -1601,6 +1605,38 @@ begin
FIcons.Clear;
end;
function TCarbonListView.NeedDeliverMouseEvent(Msg: Integer; const AMessage): Boolean;
var
h : UInt16;
y : Integer;
type
PLMMouse = ^TLMMouse;
PLMMouseMove = ^TLMMouseMove;
// for some unkown reason, HIViewConvertPoint does return inaccurate x,y position for ListView
// (because of focus ring?)
const
OfsY = -2;
begin
if Assigned(LCLObject) and (TListView(LCLObject).Columns.Count > 0) and
(TListView(LCLObject).ViewStyle = vsReport) then
begin
case Msg of
LM_LBUTTONDOWN..LM_MBUTTONDBLCLK: y := PLMMouse(@AMessage)^.YPos;
LM_MOUSEMOVE: y := PLMMouseMove(@AMessage)^.YPos ;
LM_MOUSEWHEEL: y := PLMMouseEvent(@AMessage)^.Y;
else
Result := inherited NeedDeliverMouseEvent(msg, AMessage);
Exit;
end;
GetDataBrowserListViewHeaderBtnHeight(Content, h);
inc(y, OfsY);
Result := y > h;
end
else
Result := inherited NeedDeliverMouseEvent(msg, AMessage);
end;
{ TCarbonListBox }
procedure TCarbonListBox.CreateWidget(const AParams: TCreateParams);

View File

@ -173,8 +173,12 @@ begin
Msg.XPos := P.X;
Msg.YPos := P.Y;
Msg.Keys := GetCarbonMsgKeyState;
NotifyApplicationUserInput(Msg.Msg);
DeliverMessage(Widget.LCLObject, Msg);
if Widget.NeedDeliverMouseEvent(Msg.Msg, Msg) then
begin
NotifyApplicationUserInput(Msg.Msg);
DeliverMessage(Widget.LCLObject, Msg);
end;
end;
end;
@ -208,8 +212,11 @@ begin
if PostponedDown then
begin
PostponedDown := False;
NotifyApplicationUserInput(PostponedDownMsg.Msg);
DeliverMessage(AWidget.LCLObject, PostponedDownMsg);
if AWidget.NeedDeliverMouseEvent(PostponedDownMsg.Msg, PostponedDownMsg) then
begin
NotifyApplicationUserInput(PostponedDownMsg.Msg);
DeliverMessage(AWidget.LCLObject, PostponedDownMsg);
end;
end;
MouseButton := GetCarbonMouseButton(AEvent);
@ -262,10 +269,13 @@ begin
end;
end;
DeliverMessage(AWidget.LCLObject, Msg);
if AWidget.NeedDeliverMouseEvent(Msg.Msg, Msg) then
begin
DeliverMessage(AWidget.LCLObject, Msg);
NotifyApplicationUserInput(Msg.Msg);
CarbonWidgetSet.SetCaptureWidget(0); // capture is released
NotifyApplicationUserInput(Msg.Msg);
CarbonWidgetSet.SetCaptureWidget(0); // capture is released
end;
end;
{------------------------------------------------------------------------------

View File

@ -81,7 +81,7 @@ const
SName, SGetEvent, 'kEventParamClickCount') then Exit;
Result := ClickCount;
//debugln('GetClickCount ClickCount=',dbgs(ClickCount));
{debugln('GetClickCount ClickCount=',dbgs(ClickCount));}
end;
function GetMousePoint: TPoint;
@ -141,9 +141,9 @@ const
ClickCount := GetClickCount;
MouseButton := GetCarbonMouseButton(AEvent);
MousePoint := GetMousePoint;
if (ClickCount < Low(MSGKIND)) or (ClickCount > High(MSGKIND)) then
ClickCount := 1;
ClickCount := (ClickCount mod High(MSGKIND))+1;
if (MouseButton < Low(MSGKIND[1])) or (MouseButton > High(MSGKIND[1])) then Exit;
Msg^.Msg := MSGKIND[ClickCount, MouseButton];
@ -296,14 +296,18 @@ begin
end
else
begin
// Msg is set in the Appropriate HandleMousexxx procedure
NotifyApplicationUserInput(Msg.Message.Msg);
if DeliverMessage(Widget.LCLObject, Msg) = 0 then
begin
Result := EventNotHandledErr;
if Widget.NeedDeliverMouseEvent(Msg.Message.Msg, Msg) then begin
// Msg is set in the Appropriate HandleMousexxx procedure
NotifyApplicationUserInput(Msg.Message.Msg);
if DeliverMessage(Widget.LCLObject, Msg) = 0 then
begin
Result := EventNotHandledErr;
end
else // the LCL does not want the event propagated
Result := noErr;
end
else // the LCL does not want the event propagated
Result := noErr;
else
Result := CallNextEventHandler(ANextHandler, AEvent);
end;
// interactive design