|
|
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » Parent continues before child is painted
Parent continues before child is painted [message #45352] |
Sun, 01 November 2015 09:42  |
slashupp
Messages: 231 Registered: July 2009
|
Experienced Member |
|
|
(debian 64bit)
How can I synchronize updates to a child control so that function calls in my app are guaranteed to happen after the paint-event of the child has completed?
I've tried Sync(), both in the parent and the child but to no avail.
The child's paint-event calculates and sets values in the items that are painted (their x,y-coord's) which I want to use elsewhere. This happens during start-up in the ctor of the parent, but the parent ctor always finishes before the paint-event of the child is called - meaning the x,y's are zeros. I want to ensure that the child's paint-event happens in sequence to the function-calls in the parent-ctor. How can I force this?
|
|
|
|
Re: Parent continues before child is painted [message #45354 is a reply to message #45352] |
Sun, 01 November 2015 12:15   |
|
Hi slashupp,
I don't know the answer to your question, but I think there is something wrong with your design, if you need to paint the controls in given order...
Each control should only display some state of your application. If there are data that are visualized by more then one control, then it should not be "owned" by any of them, but by some higher level entity, which takes care about it's state and calls Refresh() on all of the controls when necessary (e.g. when the data change).
Best regards,
Honza
|
|
|
Re: Parent continues before child is painted [message #45355 is a reply to message #45353] |
Sun, 01 November 2015 14:06   |
 |
mirek
Messages: 14258 Registered: November 2005
|
Ultimate Member |
|
|
Agreed, this is really a bad design. Paint should basically be 'const' (although in special cases, this rule can be broken). Order is not guaranteed.
Now I can suggest two solution, based on what values you expect to 'compute' in Paint.
Model situation 1: You need some coordinates computed during Paint e.g. to use in LeftDown. If that is the case, separate painting into some routine other than ::Paint. In Paint, call this other routine. When you need coordinates computed, call this routine with "NilDraw". If there are some really heavy computation, you can add bool flag to avoid them.
Model situation 2: Some values displayed are slow to compute, you do not want to repeat this. In this case, use lazy evaluation/cache to compute them...
Mirek
|
|
|
|
|
|
Goto Forum:
Current Time: Wed May 14 22:39:31 CEST 2025
Total time taken to generate the page: 0.00927 seconds
|
|
|