Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-06

Repainting nested components

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Roland Turcan

Hello lazarus project!

How to assure, that all nested components will be repainted after calling MyPanel.Paint, because actually all components are behind new rectangle.

procedure TMyPanel.Paint;
var rect :TRect;
begin
  rect := GetClientRect;
  InflateRect(rect,-50,-50);
  Canvas.Brush.Color:= clYellow;
  Canvas.Rectangle(rect);
  inherited Paint;
end;
procedure TForm1.FormCreate(Sender: TObject);
var mp:TMyPanel;
begin
  mp := TMyPanel.Create (self);
  with mp do begin
    Parent := self;
    Left := 0;
    Top := 0;
    Width := 200;
    Height := 150;
    Color:= clRed;
  end;
  with TRadioButton.Create(mp) do begin
    Left:= 10;
    Top := mp.Height div 2;
    Width:=150;
    Caption:= 'Roland';
    Parent := mp;
  end;
end;

Thanks in advance.

Reply by email

Roland Turcan
to Mattias Gärtner

Thanks for you answer.

I am converting one project from Delphi/Kylix to Lazarus and using SVN versions of Lazarus with FPC 2.2.0.

This behavior is currently related to i386-linux-gtk. But I am going to port it under MacOS too (Carbon).

MG> Some widgetsets use a mixture. That means it depends on the type of widget, what MG> technique is used.

Where I can find information of differences among widgets?

TRoland;

<<< 30.6.2008 12:57 - Mattias G?rtner "" >>>
MG> Zitat von Roland Turcan :

Show quoted text 5 lines
> Hello lazarus project! > > How to assure, that all nested components will be repainted after > calling MyPanel.Paint, because actually all components are behind new > rectangle.

MG> I'm not sure, if you found a bug or if you misunderstood the concept of event MG> based painting and/or clipping.

MG> In general:
MG> TPanel and TRadioButton are TWinControls and have their own handle. So it is up MG> to the widgetset (windows, gtk, carbon, qt, fpgui ...) to control the order and MG> how (double buffered, default background, clipping, overlapping) these widgets MG> are painted. If they use clipping, then they can paint in any order. They can MG> even paint only one of them. If they don't use clipping, then they will first MG> paint TPanel and then TRadioButton.
MG> Some widgetsets use a mixture. That means it depends on the type of widget, what MG> technique is used.

MG> What widgetset are you using?
MG> What effect do you expect and what do you get? MG> What lazarus, fpc and OS version are you using?

Show quoted text 34 lines
> procedure TMyPanel.Paint; > var rect :TRect; > begin > rect := GetClientRect; > InflateRect(rect,-50,-50); > Canvas.Brush.Color:= clYellow; > Canvas.Rectangle(rect); > > inherited Paint; > end; > > procedure TForm1.FormCreate(Sender: TObject); > var mp:TMyPanel; > begin > mp := TMyPanel.Create (self); > with mp do begin > Parent := self; > Left := 0; > Top := 0; > Width := 200; > Height := 150; > Color:= clRed; > end; > > with TRadioButton.Create(mp) do begin > Left:= 10; > Top := mp.Height div 2; > Width:=150; > Caption:= 'Roland'; > Parent := mp; > end; > end; > > Thanks in advance.

MG> Mattias

Reply by email

Martin Friebe
to Roland Turcan

Maybe the following may be of help.
http://bugs.freepascal.org/view.php?id=11560

I just spotted in the below

How to assure, that all nested components will be repainted after calling MyPanel.Paint, because actually all components are behind new

I think you should call MyPanel.Invalidate, instead of MyPanel.Paint? that should take care of repainting any child-controls.

Best Regards
Martin

Roland Turcan wrote 88 lines
Thanks for you answer. I am converting one project from Delphi/Kylix to Lazarus and using SVN versions of Lazarus with FPC 2.2.0. This behavior is currently related to i386-linux-gtk. But I am going to port it under MacOS too (Carbon). MG> Some widgetsets use a mixture. That means it depends on the type of widget, what MG> technique is used. Where I can find information of differences among widgets? TRoland; <<< 30.6.2008 12:57 - Mattias G?rtner "" >>> MG> Zitat von Roland Turcan : >> Hello lazarus project! >> >> How to assure, that all nested components will be repainted after >> calling MyPanel.Paint, because actually all components are behind new >> rectangle. >> MG> I'm not sure, if you found a bug or if you misunderstood the concept of event MG> based painting and/or clipping. MG> In general: MG> TPanel and TRadioButton are TWinControls and have their own handle. So it is up MG> to the widgetset (windows, gtk, carbon, qt, fpgui ...) to control the order and MG> how (double buffered, default background, clipping, overlapping) these widgets MG> are painted. If they use clipping, then they can paint in any order. They can MG> even paint only one of them. If they don't use clipping, then they will first MG> paint TPanel and then TRadioButton. MG> Some widgetsets use a mixture. That means it depends on the type of widget, what MG> technique is used. MG> What widgetset are you using? MG> What effect do you expect and what do you get? MG> What lazarus, fpc and OS version are you using? >> procedure TMyPanel.Paint; >> var rect :TRect; >> begin >> rect := GetClientRect; >> InflateRect(rect,-50,-50); >> Canvas.Brush.Color:= clYellow; >> Canvas.Rectangle(rect); >> >> inherited Paint; >> end; >> >> procedure TForm1.FormCreate(Sender: TObject); >> var mp:TMyPanel; >> begin >> mp := TMyPanel.Create (self); >> with mp do begin >> Parent := self; >> Left := 0; >> Top := 0; >> Width := 200; >> Height := 150; >> Color:= clRed; >> end; >> >> with TRadioButton.Create(mp) do begin >> Left:= 10; >> Top := mp.Height div 2; >> Width:=150; >> Caption:= 'Roland'; >> Parent := mp; >> end; >> end; >> >> Thanks in advance. >> MG> Mattias

Reply by email