cocoa: fix formatting and add several todo items for freq

git-svn-id: trunk@43539 -
This commit is contained in:
paul 2013-12-14 00:52:07 +00:00
parent 2cf7f3b363
commit 125883d7bf
5 changed files with 50 additions and 60 deletions

View File

@ -1929,12 +1929,14 @@ end;
{ TCocoaMenuITem } { TCocoaMenuITem }
procedure TCocoaMenuItem.lclItemSelected(sender:id); procedure TCocoaMenuItem.lclItemSelected(sender:id);
var Msg:TLMessage; var
Msg:TLMessage;
begin begin
FillChar(Msg{%H-}, SizeOf(Msg), 0); // TODO: move this to callback and call it using callback.ItemSelected
Msg.msg := LM_ACTIVATE; FillChar(Msg{%H-}, SizeOf(Msg), 0);
// debugln('send LM_Activate'); Msg.msg := LM_ACTIVATE;
DeliverMessage(lclTarget,Msg); // debugln('send LM_Activate');
DeliverMessage(lclTarget,Msg);
end; end;
end. end.

View File

@ -1000,58 +1000,54 @@ begin
end; end;
function TCocoaWidgetSet.IsWindow(handle: HWND): boolean; function TCocoaWidgetSet.IsWindow(handle: HWND): boolean;
var Obj: NSObject; var
Obj: NSObject;
begin begin
if handle<>0 then if handle <> 0 then
begin begin
Obj := NSObject(handle); Obj := NSObject(handle);
result:= Obj.isKindOfClass(NSWindow); Result := Obj.isKindOfClass(NSWindow);
end end
else else
result:=false; Result := False;
end; end;
function TCocoaWidgetSet.WindowFromPoint(Point: TPoint): HWND; function TCocoaWidgetSet.WindowFromPoint(Point: TPoint): HWND;
var r:TRect; var
windows:NSArray; r: TRect;
subviews:NSArray; windows: NSArray;
contentView:NSView; subviews: NSArray;
i,n:integer; contentView: NSView;
obj:NSObject; i, n: integer;
obj: NSObject;
begin begin
Result := 0;
if not assigned(NSApp) then
Exit;
windows := NSApp.windows;
if not assigned(NSApp) then for i := 0 to windows.count - 1 do
begin begin
result:=0; obj:=windows.objectAtIndex(i);
exit; if obj.isKindOfClass(NSWindow) then
end; begin
r := NSWindow(obj).lclFrame;
windows:=NSApp.windows; if PtInRect(r, Point) then
for i:=0 to windows.count-1 do
begin
obj:=windows.objectAtIndex(i);
if obj.isKindOfClass(NSWindow) then
begin begin
r:=NSWindow(obj).lclFrame; //debugln('Point:'+DbgS(point)+' Rect:'+DbgS(r));
if PtInRect(r,Point) then //todo: Find NSViews
begin
//debugln('Point:'+DbgS(point)+' Rect:'+DbgS(r));
//todo: Find NSViews
{ contentView:=NSWindow(obj).contentView; { contentView:=NSWindow(obj).contentView;
if assigned(contentView) then if assigned(contentView) then
begin begin
end; } end; }
result:=HWND(obj); Result := HWND(obj);
exit; Exit;
end;
end; end;
end; end;
end;
result:=0;
end; end;
function TCocoaWidgetSet.GetRgnBox(RGN: HRGN; lpRect: PRect): Longint; function TCocoaWidgetSet.GetRgnBox(RGN: HRGN; lpRect: PRect): Longint;

View File

@ -14,12 +14,8 @@ uses
CocoaPrivate, CocoaGDIObjects, CocoaCaret, CocoaUtils, LCLMessageGlue; CocoaPrivate, CocoaGDIObjects, CocoaCaret, CocoaUtils, LCLMessageGlue;
type type
{ TLCLCommonCallback } { TLCLCommonCallback }
TLCLCommonCallback = class(TObject, ICommonCallBack) TLCLCommonCallback = class(TObject, ICommonCallBack)
private private
class var class var
@ -102,8 +98,6 @@ type
const AParams: TCreateParams): TLCLIntfHandle; override; const AParams: TCreateParams): TLCLIntfHandle; override;
end; end;
const const
DblClickThreshold = 3;// max Movement between two clicks of a DblClick DblClickThreshold = 3;// max Movement between two clicks of a DblClick
@ -310,13 +304,13 @@ begin
NotifyApplicationUserInput(Target, Msg.Msg); NotifyApplicationUserInput(Target, Msg.Msg);
Result := DeliverMessage(Msg) <> 0; Result := DeliverMessage(Msg) <> 0;
if (Event.type_ = NSRightMouseDown) and (GetTarget is TControl) then // TODO: 1. LM_CONTEXTMENU should be called even if PopupMenu is not assigned
if assigned(TControl(GetTarget).PopupMenu) then // TODO: 2. Check if Cocoa has special context menu check event
begin if (Event.type_ = NSRightMouseDown) and (GetTarget is TControl) and Assigned(TControl(GetTarget).PopupMenu) then
Msg.Msg := LM_CONTEXTMENU; begin
Result := DeliverMessage(Msg) <> 0; Msg.Msg := LM_CONTEXTMENU;
end; Result := DeliverMessage(Msg) <> 0;
end;
end; end;
NSLeftMouseUp, NSLeftMouseUp,
NSRightMouseUp, NSRightMouseUp,

View File

@ -196,6 +196,7 @@ begin
R := CreateParamsToNSRect(AParams); R := CreateParamsToNSRect(AParams);
win := TCocoaPanel(win.initWithContentRect_styleMask_backing_defer(R, WinMask, NSBackingStoreBuffered, False)); win := TCocoaPanel(win.initWithContentRect_styleMask_backing_defer(R, WinMask, NSBackingStoreBuffered, False));
win.enableCursorRects; win.enableCursorRects;
// TODO: replace numeric constant with Cocoa constant
win.setLevel(8); win.setLevel(8);
TCocoaPanel(win).callback := TLCLWindowCallback.Create(win, AWinControl); TCocoaPanel(win).callback := TLCLWindowCallback.Create(win, AWinControl);
win.setDelegate(win); win.setDelegate(win);
@ -210,9 +211,6 @@ begin
Result := TLCLIntfHandle(cnt); Result := TLCLIntfHandle(cnt);
end; end;
{ TLCLWindowCallback } { TLCLWindowCallback }
function TLCLWindowCallback.CanActivate: Boolean; function TLCLWindowCallback.CanActivate: Boolean;

View File

@ -303,12 +303,12 @@ begin
// todo: there's no way to control X,Y coordinates of the Popup menu in the OSX // todo: there's no way to control X,Y coordinates of the Popup menu in the OSX
// prior to 10.6. Check the if there's the method and use it, if available // prior to 10.6. Check the if there's the method and use it, if available
if Assigned(APopupMenu) and (APopupMenu.Handle<>0) then if Assigned(APopupMenu) and (APopupMenu.Handle<>0) then
begin begin
w:=NSApp.keyWindow; w:=NSApp.keyWindow;
if Assigned(w) then if Assigned(w) then
NSMenu.popUpContextMenu_withEvent_forView( TCocoaMenu(APopupMenu.Handle), NSMenu.popUpContextMenu_withEvent_forView( TCocoaMenu(APopupMenu.Handle),
NSApp.currentEvent, NSView(w.contentView)); NSApp.currentEvent, NSView(w.contentView));
APopupMenu.Close; // notify LCL popup menu APopupMenu.Close; // notify LCL popup menu
end; end;
end; end;