drawing on panel Topic is solved

Are you writing your own components and need help with how to set them up or have questions about the components you are deriving from ? Ask them here.
Post Reply
amst
In need of some credit
In need of some credit
Posts: 5
Joined: Mon Feb 21, 2011 9:25 pm

drawing on panel

Post by amst »

Hi :)
I have a sample code to draw lines on wxPanel, but sometimes (when wxPen's wide is bigger than 1)it works slowly.

And what is the most strange for me, it works good if I run a lot of application on my computer, but if I run only this application it works slowly...

Thanks for help !
Attachments
main.cpp
(2.27 KiB) Downloaded 359 times
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

What OS? For me (OSX) it seems fast
"Keyboard not detected. Press F1 to continue"
-- Windows
amst
In need of some credit
In need of some credit
Posts: 5
Joined: Mon Feb 21, 2011 9:25 pm

Post by amst »

Win 7
RainRat
I live to help wx-kind
I live to help wx-kind
Posts: 178
Joined: Thu Jan 06, 2011 11:26 pm

Post by RainRat »

It worked fine for me for different size pens in both debug/release compile and on winXP and Win 7 netbook. I link statically also, if that matters.
amst
In need of some credit
In need of some credit
Posts: 5
Joined: Mon Feb 21, 2011 9:25 pm

Post by amst »

Thank You for your quick replay !

I started to test this application more and I noticed that it works fine when I run any program which contains any graphics, for example my photo viewer or a website which contains Flash banner. If banner is moving application works fine, but when banner stops moving, application works slowly.

So maybe it is some problem with graphics?
amst
In need of some credit
In need of some credit
Posts: 5
Joined: Mon Feb 21, 2011 9:25 pm

Post by amst »

Hi,

I have just realised that the function DrawLine doesn't refresh my screen (if a line is wider than 1). Does anyone know why? How to force screen to refresh in wxWidgets?
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

This is perhaps a compositing issue; if you OS's compositor doesn't refetch the data because it thinks it doesn't need to.

What I would recommend, and that is highly recommended anyway, is to not rely on wxClientDC (alone). Handle paint events (see http://wiki.wxwidgets.org/Drawing_on_a_ ... tant_Notes ). Then you can perhaps simply remove the need for wxClientDC and just call for Refresh() when you need it.

True this will make your code more complicated, but really you have no choice, wxClientDC is meant for temporary drawings only, so this is bad for a drawing app where drawings should not be temporary
"Keyboard not detected. Press F1 to continue"
-- Windows
amst
In need of some credit
In need of some credit
Posts: 5
Joined: Mon Feb 21, 2011 9:25 pm

Post by amst »

Now, it works perfectly !

Thank You very much ! :)
Post Reply