reduced paint messages on destroy

git-svn-id: trunk@2660 -
This commit is contained in:
mattias 2002-08-17 23:41:34 +00:00
parent d2ef70e4c2
commit f3340fb77b
3 changed files with 164 additions and 135 deletions

View File

@ -1618,11 +1618,14 @@ var
end; end;
begin begin
if (Parent=nil) or (not Parent.HandleAllocated)
or ([csLoading,csDestroying]*Parent.ComponentState<>[])
or ([csLoading,csDestroying]*ComponentState<>[])
then exit;
if (IsVisible or (csDesigning in ComponentState) if (IsVisible or (csDesigning in ComponentState)
and not (csNoDesignVisible in ControlStyle)) and not (csNoDesignVisible in ControlStyle))
and (Parent <> nil) and Parent.HandleAllocated then begin
and (not (csLoading in Parent.ComponentState)) then
begin
Rect := BoundsRect; Rect := BoundsRect;
InvalidateRect(Parent.Handle, @Rect, not (IsOpaque or InvalidateRect(Parent.Handle, @Rect, not (IsOpaque or
(csOpaque in Parent.ControlStyle) or BackgroundClipped)); (csOpaque in Parent.ControlStyle) or BackgroundClipped));
@ -1655,10 +1658,11 @@ procedure TControl.Repaint;
var var
DC: HDC; DC: HDC;
begin begin
if (Parent=nil) or (not Parent.HandleAllocated)
or (csDestroying in ComponentState) then exit;
if (Visible or (csDesigning in ComponentState) if (Visible or (csDesigning in ComponentState)
and not (csNoDesignVisible in ControlStyle)) and not (csNoDesignVisible in ControlStyle))
and (Parent <> nil)
and Parent.HandleAllocated
then then
if csOpaque in ControlStyle then if csOpaque in ControlStyle then
begin begin
@ -2414,6 +2418,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.135 2003/06/20 12:56:53 mattias
reduced paint messages on destroy
Revision 1.134 2003/06/13 14:38:01 mattias Revision 1.134 2003/06/13 14:38:01 mattias
fixed using streamed clientwith/height for child anchors fixed using streamed clientwith/height for child anchors

View File

@ -1155,6 +1155,8 @@ var
ControlsNeedsClipping: boolean; ControlsNeedsClipping: boolean;
begin begin
//writeln('[TWinControl.PaintHandler] ',Name,':',ClassName,' DC=',HexStr(Message.DC,8)); //writeln('[TWinControl.PaintHandler] ',Name,':',ClassName,' DC=',HexStr(Message.DC,8));
if (csDestroying in ComponentState) or (not HandleAllocated) then exit;
Assert(False, Format('Trace:> [TWinControl.PaintHandler] %s --> Msg.DC: 0x%x', [ClassName, TheMessage.DC])); Assert(False, Format('Trace:> [TWinControl.PaintHandler] %s --> Msg.DC: 0x%x', [ClassName, TheMessage.DC]));
DC := TheMessage.DC; DC := TheMessage.DC;
if DC = 0 then DC := BeginPaint(Handle, PS); if DC = 0 then DC := BeginPaint(Handle, PS);
@ -1200,6 +1202,10 @@ var
TempControl : TCOntrol; TempControl : TCOntrol;
begin begin
//writeln('[TWinControl.PaintControls] ',Name,':',ClassName,' DC=',HexStr(DC,8)); //writeln('[TWinControl.PaintControls] ',Name,':',ClassName,' DC=',HexStr(DC,8));
if (csDestroying in ComponentState)
or ((DC=0) and (not HandleAllocated)) then
exit;
// Controls that are not TWinControl, have no handle of their own, and so // Controls that are not TWinControl, have no handle of their own, and so
// they are repainted as part of the parent: // they are repainted as part of the parent:
if FControls <> nil then if FControls <> nil then
@ -1258,6 +1264,10 @@ var
Message: TLMessage; Message: TLMessage;
begin begin
//writeln('[TWinControl.PaintWindow] ',Name,':',Classname,' DC=',HexStr(DC,8)); //writeln('[TWinControl.PaintWindow] ',Name,':',Classname,' DC=',HexStr(DC,8));
if (csDestroying in ComponentState)
or ((DC=0) and (not HandleAllocated)) then
exit;
Message.Msg := LM_PAINT; Message.Msg := LM_PAINT;
Message.WParam := DC; Message.WParam := DC;
Message.LParam := 0; Message.LParam := 0;
@ -1727,7 +1737,7 @@ end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
Procedure TWinControl.Invalidate; Procedure TWinControl.Invalidate;
Begin Begin
if HandleAllocated if HandleAllocated and (not (csDestroying in ComponentState))
then CNSendMessage(LM_Invalidate,Self,Nil); then CNSendMessage(LM_Invalidate,Self,Nil);
end; end;
@ -1736,13 +1746,12 @@ end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
Procedure TWinControl.Repaint; Procedure TWinControl.Repaint;
Begin Begin
if HandleAllocated if HandleAllocated and (not (csDestroying in ComponentState))
then begin then begin
CNSendMessage(LM_PAINT, Self, nil); CNSendMessage(LM_PAINT, Self, nil);
end; end;
end; end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
{ TWinControl DoMouseWheel "Event Handler" } { TWinControl DoMouseWheel "Event Handler" }
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
@ -2161,6 +2170,8 @@ var
PS : TPaintStruct; PS : TPaintStruct;
begin begin
//writeln('[TWinControl.WMPaint] ',Name,':',ClassName,' ',HexStr(Msg.DC,8)); //writeln('[TWinControl.WMPaint] ',Name,':',ClassName,' ',HexStr(Msg.DC,8));
if (csDestroying in ComponentState) then exit;
Assert(False, Format('Trace:> [TWinControl.WMPaint] %s Msg.DC: 0x%x', [ClassName, Msg.DC])); Assert(False, Format('Trace:> [TWinControl.WMPaint] %s Msg.DC: 0x%x', [ClassName, Msg.DC]));
if (Msg.DC <> 0) then if (Msg.DC <> 0) then
begin begin
@ -2816,6 +2827,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.141 2003/06/20 12:56:53 mattias
reduced paint messages on destroy
Revision 1.140 2003/06/19 22:38:21 mattias Revision 1.140 2003/06/19 22:38:21 mattias
fixed update on changing package usage options fixed update on changing package usage options

View File

@ -2332,6 +2332,7 @@ var
aStyle := gtk_style_attach(gtk_style_ref(aStyle),aDC.Drawable); aStyle := gtk_style_attach(gtk_style_ref(aStyle),aDC.Drawable);
end; end;
if aStyle<>nil then begin
If (DFCS_FLAT and uState)<>0 then If (DFCS_FLAT and uState)<>0 then
gtk_paint_flat_box(aStyle,aDC.Drawable, gtk_paint_flat_box(aStyle,aDC.Drawable,
State, State,
@ -2350,6 +2351,7 @@ var
'button', 'button',
Rect.Left+DCOrigin.X,Rect.Top+DCOrigin.Y, Rect.Left+DCOrigin.X,Rect.Top+DCOrigin.Y,
Rect.Right-Rect.Left,Rect.Bottom-Rect.Top); Rect.Right-Rect.Left,Rect.Bottom-Rect.Top);
end;
Result := True; Result := True;
end; end;
@ -2398,6 +2400,7 @@ var
Widget := GetStyleWidget('default'); Widget := GetStyleWidget('default');
If (Widget <> nil) and (Style <> nil) then begin If (Widget <> nil) and (Style <> nil) then begin
Widget^.Window := aDC.Drawable; Widget^.Window := aDC.Drawable;
if Style<>nil then
gtk_paint_check(Style,aDC.Drawable, State, gtk_paint_check(Style,aDC.Drawable, State,
Shadow, nil, Widget, 'checkbutton', Shadow, nil, Widget, 'checkbutton',
Rect.Left+DCOrigin.X,Rect.Top+DCOrigin.Y, Rect.Left+DCOrigin.X,Rect.Top+DCOrigin.Y,
@ -2406,6 +2409,7 @@ var
end end
else begin else begin
{$IfNDef Win32} {$IfNDef Win32}
if Style<>nil then
gtk_draw_check(Style,aDC.Drawable, State, gtk_draw_check(Style,aDC.Drawable, State,
Shadow, Rect.Left+DCOrigin.X,Rect.Top+DCOrigin.Y, Shadow, Rect.Left+DCOrigin.X,Rect.Top+DCOrigin.Y,
Rect.Right-Rect.Left, Rect.Bottom-Rect.Top); Rect.Right-Rect.Left, Rect.Bottom-Rect.Top);
@ -3260,20 +3264,22 @@ var
//RightBottomGC: PGdkGC; //RightBottomGC: PGdkGC;
begin begin
Result := IsValidDC(DC); Result := IsValidDC(DC);
if Result then if not Result then exit;
if FrameWidth=0 then exit; if FrameWidth=0 then exit;
with TDeviceContext(DC) do with TDeviceContext(DC) do
begin begin
if GC = nil then begin if GC = nil then begin
Result:= False; Result:= False;
end exit;
else begin end;
Widget:=PGtkWidget(TDeviceContext(DC).Wnd); Widget:=PGtkWidget(TDeviceContext(DC).Wnd);
ClientWidget:=GetFixedWidget(Widget); ClientWidget:=GetFixedWidget(Widget);
if ClientWidget=nil then if ClientWidget=nil then
ClientWidget:=Widget; ClientWidget:=Widget;
AWindow:=GetControlWindow(ClientWidget); AWindow:=GetControlWindow(ClientWidget);
if AWindow<>nil then begin if AWindow=nil then begin
exit;
end;
DCOrigin:=GetDCOffset(TDeviceContext(DC)); DCOrigin:=GetDCOffset(TDeviceContext(DC));
TheStyle:=GetStyle('button'); TheStyle:=GetStyle('button');
Area.X:=ARect.Left+DCOrigin.X; Area.X:=ARect.Left+DCOrigin.X;
@ -3321,6 +3327,7 @@ begin
gdk_draw_line(Drawable, RightBottomGC, gdk_draw_line(Drawable, RightBottomGC,
ARect.Left+DCOrigin.X, ARect.Bottom+DCOrigin.Y, ARect.Left+DCOrigin.X, ARect.Bottom+DCOrigin.Y,
ARect.Right+DCOrigin.X, ARect.Bottom+DCOrigin.Y);} ARect.Right+DCOrigin.X, ARect.Bottom+DCOrigin.Y);}
if TheStyle<>nil then
gtk_paint_shadow(TheStyle, gtk_paint_shadow(TheStyle,
AWindow, GTK_STATE_NORMAL, AWindow, GTK_STATE_NORMAL,
ShadowType, ShadowType,
@ -3332,8 +3339,6 @@ begin
InflateRect(ARect, -1, -1); InflateRect(ARect, -1, -1);
end; end;
end; end;
end;
end;
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -8291,6 +8296,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.246 2003/06/20 12:56:53 mattias
reduced paint messages on destroy
Revision 1.245 2003/06/19 09:26:58 mattias Revision 1.245 2003/06/19 09:26:58 mattias
fixed changing unitname during update fixed changing unitname during update