* carbon: removed doubled-draw effect of invalidates inside painting event.

git-svn-id: trunk@19629 -
This commit is contained in:
dmitry 2009-04-26 08:25:52 +00:00
parent 7277e0b12c
commit 8307ced794
2 changed files with 32 additions and 8 deletions

View File

@ -31,6 +31,21 @@ begin
LCLSendDestroyMsg(AWidget.LCLObject); // widget is disposed in DestroyHandle
end;
{------------------------------------------------------------------------------
Name: CarbonCommon_Draw
Handles draw event
------------------------------------------------------------------------------}
function CarbonWindow_ContentDraw(ANextHandler: EventHandlerCallRef;
AEvent: EventRef;
AWidget: TCarbonWidget): OSStatus; {$IFDEF darwin}mwpascal;{$ENDIF}
begin
if not isRepaint then
Result := CallNextEventHandler(ANextHandler, AEvent)
else
Result := noErr;
end;
{------------------------------------------------------------------------------
Name: CarbonCommon_Draw
Handles draw event
@ -43,6 +58,11 @@ var
Win : WindowRef;
Content : HIViewRef;
begin
if isRepaint then
begin
Result := noErr;
Exit;
end;
{$IFDEF VerbosePaint}
Debugln('CarbonCommon_Draw ', DbgSName(AWidget.LCLObject));
@ -61,15 +81,11 @@ begin
AWidget.Context.Reset;
// let carbon draw/update
if not isRepaint or ( AWidget.InheritsFrom(TCarbonCustomControl) and not (AWidget is TCarbonScrollingWinControl)) then
Result := CallNextEventHandler(ANextHandler, AEvent)
else
Result := noErr;
Result := CallNextEventHandler(ANextHandler, AEvent);
if (AWidget is TCarbonControl) and
(cceDraw in (AWidget as TCarbonControl).GetValidEvents) then
begin
// todo: find a way to erase old content
(AWidget as TCarbonControl).Draw;
end;
@ -84,7 +100,6 @@ begin
finally
Dispose(AStruct);
end;
if AWidget.HasCaret then DrawCaret;
finally
@ -97,8 +112,8 @@ begin
IsRepaint := true;
Win:=HIViewGetWindow(AWidget.Widget);
HIViewFindByID( HIViewGetRoot(Win), kHIViewWindowContentID, Content);
HIViewSetNeedsDisplay(Content, true);
HIViewRender(Content);
//HIViewSetNeedsDisplay(Content, true);
HIViewRender(HIViewGetRoot(Win));
IsRepaint:=false;
end;
InvalidPaint:=false;

View File

@ -996,6 +996,7 @@ var
KeySpecs: array[0..3] of EventTypeSpec;
ActivateSpecs: array[0..1] of EventTypeSpec;
ShowWindowSpecs: array[0..2] of EventTypeSpec;
WinContent: HIViewRef;
begin
// Window Events
@ -1078,6 +1079,14 @@ begin
RegisterEventHandler(@CarbonCommon_User),
1, @TmpSpec, Pointer(Self), nil);
// paint content message
if (HIViewFindByID( HIViewGetRoot(fWindowRef), kHIViewWindowContentID, WinContent) = noErr) then
begin
TmpSpec := MakeEventSpec(kEventClassControl, kEventControlDraw);
InstallControlEventHandler(WinContent,
RegisterEventHandler(@CarbonWindow_ContentDraw),
1, @TmpSpec, Pointer(Self), nil);
end;
end;
procedure TCarbonWindow.CreateWindow(const AParams: TCreateParams);