cocoa: continue work on moze/sizing

git-svn-id: trunk@34142 -
This commit is contained in:
paul 2011-12-13 02:17:06 +00:00
parent 20fa5ad2ef
commit edffab4454
3 changed files with 43 additions and 12 deletions

View File

@ -31,7 +31,9 @@ uses
Types, Classes, SysUtils,
CGGeometry,
// Libs
MacOSAll, CocoaAll, CocoaUtils;
MacOSAll, CocoaAll, CocoaUtils,
// LCL
LCLType;
type
{ LCLObjectExtension }
@ -40,6 +42,7 @@ type
function lclIsEnabled: Boolean; message 'lclIsEnabled';
procedure lclSetEnabled(AEnabled: Boolean); message 'lclSetEnabled:';
function lclIsVisible: Boolean; message 'lclIsVisible';
function lclWindowState: Integer; message 'lclWindowState';
procedure lclInvalidateRect(const r: TRect); message 'lclInvalidateRect:';
procedure lclInvalidate; message 'lclInvalidate';
@ -75,6 +78,7 @@ type
LCLWindowExtension = objccategory(NSWindow)
function lclIsVisible: Boolean; message 'lclIsVisible'; reintroduce;
function lclWindowState: Integer; message 'lclWindowState'; reintroduce;
procedure lclInvalidateRect(const r: TRect); message 'lclInvalidateRect:'; reintroduce;
procedure lclInvalidate; message 'lclInvalidate'; reintroduce;
procedure lclLocalToScreen(var X,Y: Integer); message 'lclLocalToScreen::'; reintroduce;
@ -113,6 +117,7 @@ type
procedure CloseQuery(var CanClose: Boolean);
procedure Close;
procedure Resize;
procedure Move;
end;
{ TCocoaMenu }
@ -183,6 +188,7 @@ type
procedure windowDidBecomeKey(notification: NSNotification); message 'windowDidBecomeKey:';
procedure windowDidResignKey(notification: NSNotification); message 'windowDidResignKey:';
procedure windowDidResize(notification: NSNotification); message 'windowDidResize:';
procedure windowDidMove(notification: NSNotification); message 'windowDidMove:';
public
callback: IWindowCallback;
function acceptsFirstResponder: Boolean; override;
@ -456,6 +462,11 @@ begin
callback.Resize;
end;
procedure TCocoaWindow.windowDidMove(notification: NSNotification);
begin
callback.Move;
end;
function TCocoaWindow.acceptsFirstResponder: Boolean;
begin
Result:=true;
@ -554,6 +565,11 @@ begin
Result:=False;
end;
function LCLObjectExtension.lclWindowState: Integer;
begin
Result := SIZENORMAL;
end;
procedure LCLObjectExtension.lclInvalidateRect(const r:TRect);
begin
@ -687,6 +703,17 @@ begin
Result:=isVisible;
end;
function LCLWindowExtension.lclWindowState: Integer;
begin
if isMiniaturized then
Result := SIZEICONIC
else
if isZoomed then
Result := SIZEFULLSCREEN
else
Result := SIZENORMAL;
end;
procedure LCLWindowExtension.lclInvalidateRect(const r: TRect);
begin
contentView.lclInvalidateRect(r);

View File

@ -155,7 +155,8 @@ procedure TLCLCommonCallback.boundsDidChange;
var
NewBounds, OldBounds: TRect;
PosMsg: TLMWindowPosChanged;
Resized, Moved: Boolean;
Resized, Moved, ClientResized: Boolean;
SizeType: Integer;
begin
NewBounds := Owner.lclFrame;
OldBounds := Target.BoundsRect;
@ -167,6 +168,8 @@ begin
(OldBounds.Left <> NewBounds.Left) or
(OldBounds.Top <> NewBounds.Top);
ClientResized := False;
// send window pos changed
if Resized or Moved then
begin
@ -193,13 +196,14 @@ begin
if Resized or Target.ClientRectNeedsInterfaceUpdate then
begin
Target.InvalidateClientRectCache(False);
ClientResized := True;
end;
// then send a LM_SIZE message
if Resized then
if Resized or ClientResized then
begin
LCLSendSizeMsg(Target, NewBounds.Right - NewBounds.Left,
NewBounds.Bottom - NewBounds.Top, Size_SourceIsInterface);
NewBounds.Bottom - NewBounds.Top, Owner.lclWindowState, True);
end;
// then send a LM_MOVE message

View File

@ -40,13 +40,14 @@ uses
type
{ TLCLWindowCallback }
TLCLWindowCallback=class(TLCLCommonCallBack, IWindowCallback)
TLCLWindowCallback = class(TLCLCommonCallBack, IWindowCallback)
public
procedure Activate; virtual;
procedure Deactivate; virtual;
procedure CloseQuery(var CanClose: Boolean); virtual;
procedure Close; virtual;
procedure Resize; virtual;
procedure Move; virtual;
end;
@ -168,14 +169,13 @@ begin
end;
procedure TLCLWindowCallback.Resize;
var
sz : NSSize;
r : TRect;
begin
sz := NSWindow(Owner).frame.size;
TCocoaWSCustomForm.GetClientBounds(TWinControl(Target), r);
if Assigned(Target) then
LCLSendSizeMsg(Target, Round(sz.width), Round(sz.height), SIZENORMAL);
boundsDidChange;
end;
procedure TLCLWindowCallback.Move;
begin
boundsDidChange;
end;