Recent

Author Topic: gtk2: tControl.Onpaint Message missing  (Read 3807 times)

Martin V

  • Full Member
  • ***
  • Posts: 139
gtk2: tControl.Onpaint Message missing
« on: August 22, 2016, 11:32:07 am »
In gtk2 (Linux), Controls do not have an OnPaint message, an overwritten Paint message is not executed. Only tForm.OnPaint/Paint exists and is executed.

I have got a Form where a Control resides in. I want to redraw only a part of my Control. (The Control is an editor and fills nearly the whole Form). But with InvalidateRect I can only make a repaint of the whole Form and if the control is part of the invalidated Rectangle, the whole Control gets painted. In Windows, I can send an InvalidateRect (Control.Handle...)

How to redraw a part of a control on the Linux platform without having a Control.Paint ?
Setting Control.Fillrect before using InvalidateRect (Form.Handle) has no effect.

Redrawing outside the Paint message works, but this would not work on MacOS, because MacOS only allows drawing within a Paint message.

A sample is nearby. If the control gets white, the whole control has been repainted I do not want.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4693
  • I like bugs.
Re: gtk2: tControl.Onpaint Message missing
« Reply #1 on: August 22, 2016, 04:42:48 pm »
May be difficult with TPanel.
Try instead TPaintBox or some other control which is not derived from TWinControl.
« Last Edit: August 22, 2016, 06:44:36 pm by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Martin V

  • Full Member
  • ***
  • Posts: 139
Re: gtk2: tControl.Onpaint Message missing
« Reply #2 on: August 22, 2016, 06:46:53 pm »
My original control is derived from tCustomControl which contains the OnPaint, the Handle and the KeyPress property which I need for my editor. Now I have replaced the tPanel in the sample with a CustomControl and use InvalidateRect (CustomControl.Handle, ...), see attachment. But it still does not work and repaints the whole control after using InvalidateRect. Is this a bug?

P.S.  Paintbox does not work because it has an OnPaint event, but no handle.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4693
  • I like bugs.
Re: gtk2: tControl.Onpaint Message missing
« Reply #3 on: August 22, 2016, 06:56:32 pm »
P.S.  Paintbox does not work because it has an OnPaint event, but no handle.

My idea was that you paint what you need in OnPaint handler and do not call InvalidateRect.
I don't know why you need it.
However my knowledge of graphics programming is not very good. Somebody else can answer better.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Martin V

  • Full Member
  • ***
  • Posts: 139
Re: gtk2: tControl.Onpaint Message missing
« Reply #4 on: August 22, 2016, 09:44:11 pm »
My control is a complete text editor which can fit the whole screen. The editor should only redraw the part where the user types input or where the text cursor blinks and so on. At the moment, the Linux version uses direct drawing outside the OnPaint message and it works. On Windows, both codes work (direct drawing and drawing inside OnPaint), and on MacOS only drawing inside OnPaint is allowed. All works fine at the moment, but only with different code. On the long run, I hope that one single code works (write once, compile everywhere) and I want to report lcl bugs after I'm sure.

If anyone is interested in my work:
http://www.hypermake.com/english/betatest.html
http://www.hypermake.de/deutsch/betatest.html

 

TinyPortal © 2005-2018