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;
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)
and not (csNoDesignVisible in ControlStyle))
and (Parent <> nil) and Parent.HandleAllocated
and (not (csLoading in Parent.ComponentState)) then
begin
then begin
Rect := BoundsRect;
InvalidateRect(Parent.Handle, @Rect, not (IsOpaque or
(csOpaque in Parent.ControlStyle) or BackgroundClipped));
@ -1655,10 +1658,11 @@ procedure TControl.Repaint;
var
DC: HDC;
begin
if (Parent=nil) or (not Parent.HandleAllocated)
or (csDestroying in ComponentState) then exit;
if (Visible or (csDesigning in ComponentState)
and not (csNoDesignVisible in ControlStyle))
and (Parent <> nil)
and Parent.HandleAllocated
then
if csOpaque in ControlStyle then
begin
@ -2414,6 +2418,9 @@ end;
{ =============================================================================
$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
fixed using streamed clientwith/height for child anchors

View File

@ -1155,6 +1155,8 @@ var
ControlsNeedsClipping: boolean;
begin
//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]));
DC := TheMessage.DC;
if DC = 0 then DC := BeginPaint(Handle, PS);
@ -1200,6 +1202,10 @@ var
TempControl : TCOntrol;
begin
//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
// they are repainted as part of the parent:
if FControls <> nil then
@ -1258,6 +1264,10 @@ var
Message: TLMessage;
begin
//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.WParam := DC;
Message.LParam := 0;
@ -1727,7 +1737,7 @@ end;
{------------------------------------------------------------------------------}
Procedure TWinControl.Invalidate;
Begin
if HandleAllocated
if HandleAllocated and (not (csDestroying in ComponentState))
then CNSendMessage(LM_Invalidate,Self,Nil);
end;
@ -1736,13 +1746,12 @@ end;
{------------------------------------------------------------------------------}
Procedure TWinControl.Repaint;
Begin
if HandleAllocated
if HandleAllocated and (not (csDestroying in ComponentState))
then begin
CNSendMessage(LM_PAINT, Self, nil);
end;
end;
{------------------------------------------------------------------------------}
{ TWinControl DoMouseWheel "Event Handler" }
{------------------------------------------------------------------------------}
@ -2161,6 +2170,8 @@ var
PS : TPaintStruct;
begin
//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]));
if (Msg.DC <> 0) then
begin
@ -2816,6 +2827,9 @@ end;
{ =============================================================================
$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
fixed update on changing package usage options

View File

@ -2279,59 +2279,60 @@ var
begin
//if Widget<>nil then begin
// use the gtk paint functions to draw a widget style dependent button
// set State (the interior filling style)
if (DFCS_INACTIVE and uState)<>0 then begin
// button disabled
State:=GTK_STATE_INSENSITIVE;
end else begin
if (DFCS_PUSHED and uState)<>0 then begin
// button enabled, down
if (DFCS_CHECKED and uState)<>0 then begin
// button enabled, down, special (e.g. mouse over)
State:=GTK_STATE_ACTIVE;
end else begin
// button enabled, down, normal
State:=GTK_STATE_SELECTED;
end;
end else begin
// button enabled, up
if (DFCS_CHECKED and uState)<>0 then begin
// button enabled, up, special (e.g. mouse over)
State:=GTK_STATE_PRELIGHT;
end else begin
// button enabled, up, normal
State:=GTK_STATE_NORMAL;
end;
end;
end;
// set Shadow (the border style)
// use the gtk paint functions to draw a widget style dependent button
// set State (the interior filling style)
if (DFCS_INACTIVE and uState)<>0 then begin
// button disabled
State:=GTK_STATE_INSENSITIVE;
end else begin
if (DFCS_PUSHED and uState)<>0 then begin
// button down
Shadow:=GTK_SHADOW_IN;
end else begin
if (((DFCS_FLAT+DFCS_CHECKED) and uState)=DFCS_FLAT) then begin
// button up, flat, no special
Shadow:=GTK_SHADOW_NONE;
// button enabled, down
if (DFCS_CHECKED and uState)<>0 then begin
// button enabled, down, special (e.g. mouse over)
State:=GTK_STATE_ACTIVE;
end else begin
// button up
Shadow:=GTK_SHADOW_OUT;
// button enabled, down, normal
State:=GTK_STATE_SELECTED;
end;
end else begin
// button enabled, up
if (DFCS_CHECKED and uState)<>0 then begin
// button enabled, up, special (e.g. mouse over)
State:=GTK_STATE_PRELIGHT;
end else begin
// button enabled, up, normal
State:=GTK_STATE_NORMAL;
end;
end;
aDC:=TDeviceContext(DC);
DCOrigin:=GetDCOffset(aDC);
aStyle := GetStyle('button');
If aStyle = nil then
aStyle := Widget^.theStyle
else begin
If State = GTK_STATE_SELECTED then
State := GTK_STATE_ACTIVE;
aStyle := gtk_style_attach(gtk_style_ref(aStyle),aDC.Drawable);
end;
// set Shadow (the border style)
if (DFCS_PUSHED and uState)<>0 then begin
// button down
Shadow:=GTK_SHADOW_IN;
end else begin
if (((DFCS_FLAT+DFCS_CHECKED) and uState)=DFCS_FLAT) then begin
// button up, flat, no special
Shadow:=GTK_SHADOW_NONE;
end else begin
// button up
Shadow:=GTK_SHADOW_OUT;
end;
end;
aDC:=TDeviceContext(DC);
DCOrigin:=GetDCOffset(aDC);
aStyle := GetStyle('button');
If aStyle = nil then
aStyle := Widget^.theStyle
else begin
If State = GTK_STATE_SELECTED then
State := GTK_STATE_ACTIVE;
aStyle := gtk_style_attach(gtk_style_ref(aStyle),aDC.Drawable);
end;
if aStyle<>nil then begin
If (DFCS_FLAT and uState)<>0 then
gtk_paint_flat_box(aStyle,aDC.Drawable,
State,
@ -2350,6 +2351,7 @@ var
'button',
Rect.Left+DCOrigin.X,Rect.Top+DCOrigin.Y,
Rect.Right-Rect.Left,Rect.Bottom-Rect.Top);
end;
Result := True;
end;
@ -2398,17 +2400,19 @@ var
Widget := GetStyleWidget('default');
If (Widget <> nil) and (Style <> nil) then begin
Widget^.Window := aDC.Drawable;
gtk_paint_check(Style,aDC.Drawable, State,
Shadow, nil, Widget, 'checkbutton',
Rect.Left+DCOrigin.X,Rect.Top+DCOrigin.Y,
Rect.Right-Rect.Left, Rect.Bottom-Rect.Top);
if Style<>nil then
gtk_paint_check(Style,aDC.Drawable, State,
Shadow, nil, Widget, 'checkbutton',
Rect.Left+DCOrigin.X,Rect.Top+DCOrigin.Y,
Rect.Right-Rect.Left, Rect.Bottom-Rect.Top);
Result := True;
end
else begin
{$IfNDef Win32}
gtk_draw_check(Style,aDC.Drawable, State,
Shadow, Rect.Left+DCOrigin.X,Rect.Top+DCOrigin.Y,
Rect.Right-Rect.Left, Rect.Bottom-Rect.Top);
if Style<>nil then
gtk_draw_check(Style,aDC.Drawable, State,
Shadow, Rect.Left+DCOrigin.X,Rect.Top+DCOrigin.Y,
Rect.Right-Rect.Left, Rect.Bottom-Rect.Top);
{$EndIf}
Result := True;
end;
@ -3260,80 +3264,81 @@ var
//RightBottomGC: PGdkGC;
begin
Result := IsValidDC(DC);
if Result then
if FrameWidth=0 then exit;
with TDeviceContext(DC) do
begin
if GC = nil then begin
Result:= False;
end
else begin
Widget:=PGtkWidget(TDeviceContext(DC).Wnd);
ClientWidget:=GetFixedWidget(Widget);
if ClientWidget=nil then
ClientWidget:=Widget;
AWindow:=GetControlWindow(ClientWidget);
if AWindow<>nil then begin
DCOrigin:=GetDCOffset(TDeviceContext(DC));
TheStyle:=GetStyle('button');
Area.X:=ARect.Left+DCOrigin.X;
Area.Y:=ARect.Top+DCOrigin.Y;
Area.Width:=ARect.Right-ARect.Left;
Area.Height:=ARect.Bottom-ARect.Top;
{case Style of
bvLowered:
begin
LeftTopGC:=TheStyle^.light_gc[GTK_STATE_NORMAL];
RightBottomGC:=TheStyle^.dark_gc[GTK_STATE_NORMAL];
end;
bvRaised:
begin
LeftTopGC:=TheStyle^.dark_gc[GTK_STATE_NORMAL];
RightBottomGC:=TheStyle^.light_gc[GTK_STATE_NORMAL];
end;
else
begin
LeftTopGC:=TheStyle^.mid_gc[GTK_STATE_NORMAL];
RightBottomGC:=TheStyle^.mid_gc[GTK_STATE_NORMAL];
end;
end;
gdk_gc_set_clip_rectangle (LeftTopGC, @Area);
gdk_gc_set_clip_rectangle (RightBottomGC, @Area);}
if FrameWidth=1 then
ShadowType:=GTKThinShadowType[Style]
else
ShadowType:=GTKStrongShadowType[Style];
for i:= 1 to FrameWidth do begin
{ // left edge
gdk_draw_line(Drawable, LeftTopGC,
ARect.Left+DCOrigin.X, ARect.Top+DCOrigin.Y,
ARect.Left+DCOrigin.X, ARect.Bottom+DCOrigin.Y);
// top edge
gdk_draw_line(Drawable, LeftTopGC,
ARect.Left+DCOrigin.X, ARect.Top+DCOrigin.Y,
ARect.Right+DCOrigin.X, ARect.Top+DCOrigin.Y);
// right edge
gdk_draw_line(Drawable, RightBottomGC,
ARect.Right+DCOrigin.X, ARect.Top+DCOrigin.Y,
ARect.Right+DCOrigin.X, ARect.Bottom+DCOrigin.Y);
// bottom edge
gdk_draw_line(Drawable, RightBottomGC,
ARect.Left+DCOrigin.X, ARect.Bottom+DCOrigin.Y,
ARect.Right+DCOrigin.X, ARect.Bottom+DCOrigin.Y);}
gtk_paint_shadow(TheStyle,
AWindow, GTK_STATE_NORMAL,
ShadowType,
@Area,
ClientWidget,
'button',
ARect.Left+DCOrigin.X, ARect.Top+DCOrigin.Y,
ARect.Right-ARect.Left, ARect.Bottom-ARect.Top);
InflateRect(ARect, -1, -1);
end;
end;
if not Result then exit;
if FrameWidth=0 then exit;
with TDeviceContext(DC) do
begin
if GC = nil then begin
Result:= False;
exit;
end;
Widget:=PGtkWidget(TDeviceContext(DC).Wnd);
ClientWidget:=GetFixedWidget(Widget);
if ClientWidget=nil then
ClientWidget:=Widget;
AWindow:=GetControlWindow(ClientWidget);
if AWindow=nil then begin
exit;
end;
DCOrigin:=GetDCOffset(TDeviceContext(DC));
TheStyle:=GetStyle('button');
Area.X:=ARect.Left+DCOrigin.X;
Area.Y:=ARect.Top+DCOrigin.Y;
Area.Width:=ARect.Right-ARect.Left;
Area.Height:=ARect.Bottom-ARect.Top;
{case Style of
bvLowered:
begin
LeftTopGC:=TheStyle^.light_gc[GTK_STATE_NORMAL];
RightBottomGC:=TheStyle^.dark_gc[GTK_STATE_NORMAL];
end;
bvRaised:
begin
LeftTopGC:=TheStyle^.dark_gc[GTK_STATE_NORMAL];
RightBottomGC:=TheStyle^.light_gc[GTK_STATE_NORMAL];
end;
else
begin
LeftTopGC:=TheStyle^.mid_gc[GTK_STATE_NORMAL];
RightBottomGC:=TheStyle^.mid_gc[GTK_STATE_NORMAL];
end;
end;
gdk_gc_set_clip_rectangle (LeftTopGC, @Area);
gdk_gc_set_clip_rectangle (RightBottomGC, @Area);}
if FrameWidth=1 then
ShadowType:=GTKThinShadowType[Style]
else
ShadowType:=GTKStrongShadowType[Style];
for i:= 1 to FrameWidth do begin
{ // left edge
gdk_draw_line(Drawable, LeftTopGC,
ARect.Left+DCOrigin.X, ARect.Top+DCOrigin.Y,
ARect.Left+DCOrigin.X, ARect.Bottom+DCOrigin.Y);
// top edge
gdk_draw_line(Drawable, LeftTopGC,
ARect.Left+DCOrigin.X, ARect.Top+DCOrigin.Y,
ARect.Right+DCOrigin.X, ARect.Top+DCOrigin.Y);
// right edge
gdk_draw_line(Drawable, RightBottomGC,
ARect.Right+DCOrigin.X, ARect.Top+DCOrigin.Y,
ARect.Right+DCOrigin.X, ARect.Bottom+DCOrigin.Y);
// bottom edge
gdk_draw_line(Drawable, RightBottomGC,
ARect.Left+DCOrigin.X, ARect.Bottom+DCOrigin.Y,
ARect.Right+DCOrigin.X, ARect.Bottom+DCOrigin.Y);}
if TheStyle<>nil then
gtk_paint_shadow(TheStyle,
AWindow, GTK_STATE_NORMAL,
ShadowType,
@Area,
ClientWidget,
'button',
ARect.Left+DCOrigin.X, ARect.Top+DCOrigin.Y,
ARect.Right-ARect.Left, ARect.Bottom-ARect.Top);
InflateRect(ARect, -1, -1);
end;
end;
end;
{------------------------------------------------------------------------------
@ -8291,6 +8296,9 @@ end;
{ =============================================================================
$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
fixed changing unitname during update