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

View File

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

View File

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

View File

@ -196,6 +196,7 @@ begin
R := CreateParamsToNSRect(AParams);
win := TCocoaPanel(win.initWithContentRect_styleMask_backing_defer(R, WinMask, NSBackingStoreBuffered, False));
win.enableCursorRects;
// TODO: replace numeric constant with Cocoa constant
win.setLevel(8);
TCocoaPanel(win).callback := TLCLWindowCallback.Create(win, AWinControl);
win.setDelegate(win);
@ -210,9 +211,6 @@ begin
Result := TLCLIntfHandle(cnt);
end;
{ TLCLWindowCallback }
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
// prior to 10.6. Check the if there's the method and use it, if available
if Assigned(APopupMenu) and (APopupMenu.Handle<>0) then
begin
begin
w:=NSApp.keyWindow;
if Assigned(w) then
NSMenu.popUpContextMenu_withEvent_forView( TCocoaMenu(APopupMenu.Handle),
NSApp.currentEvent, NSView(w.contentView));
APopupMenu.Close; // notify LCL popup menu
APopupMenu.Close; // notify LCL popup menu
end;
end;