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,8 +1929,10 @@ end;
{ TCocoaMenuITem } { TCocoaMenuITem }
procedure TCocoaMenuItem.lclItemSelected(sender:id); procedure TCocoaMenuItem.lclItemSelected(sender:id);
var Msg:TLMessage; var
Msg:TLMessage;
begin begin
// TODO: move this to callback and call it using callback.ItemSelected
FillChar(Msg{%H-}, SizeOf(Msg), 0); FillChar(Msg{%H-}, SizeOf(Msg), 0);
Msg.msg := LM_ACTIVATE; Msg.msg := LM_ACTIVATE;
// debugln('send LM_Activate'); // debugln('send LM_Activate');

View File

@ -1000,32 +1000,30 @@ 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
r: TRect;
windows: NSArray; windows: NSArray;
subviews: NSArray; subviews: NSArray;
contentView: NSView; contentView: NSView;
i, n: integer; i, n: integer;
obj: NSObject; obj: NSObject;
begin begin
Result := 0;
if not assigned(NSApp) then if not assigned(NSApp) then
begin Exit;
result:=0;
exit;
end;
windows := NSApp.windows; windows := NSApp.windows;
@ -1045,13 +1043,11 @@ for i:=0 to windows.count-1 do
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
if (Event.type_ = NSRightMouseDown) and (GetTarget is TControl) and Assigned(TControl(GetTarget).PopupMenu) then
begin begin
Msg.Msg := LM_CONTEXTMENU; Msg.Msg := LM_CONTEXTMENU;
Result := DeliverMessage(Msg) <> 0; Result := DeliverMessage(Msg) <> 0;
end; 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;