OnPaint() of wxScrolledWindow in custom wxFrame

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
tuli
Knows some wx things
Knows some wx things
Posts: 42
Joined: Sat Dec 03, 2011 3:56 pm

Re: OnPaint() of wxScrolledWindow in custom wxFrame

Post by tuli » Sat Jan 21, 2012 9:12 am

Why should that be faster?
i thought drawing to a bitmap was generally faster than drawing directly to the screen...(?)

Code: Select all

I think caching the file content would be more important that trying to optimize the display.
definitely. I just used this example to demonstrate the problem.

As usually, you were right about the last line, and it works fine, after changing the code as you suggested...thanks! :)

I am unable to catch all scroll-events for correct refreshing, though:

Code: Select all

void MyScrolledWindow::OnScroll(wxScrollWinEvent &event)
{
	Refresh();
	event.Skip();
}

EVT_SCROLLWIN(MyScrolledWindow::OnScroll)
This supposedly catches all scrollevents there are (afaik), but it doesnt do so

- at all, when the user uses the mousewheel to scroll
- while the user drags the scrollbar up/down (it is refreshed when the user finally lets go, though).

What other scrollevents are there to catch?

User avatar
doublemax
Moderator
Moderator
Posts: 15069
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: OnPaint() of wxScrolledWindow in custom wxFrame

Post by doublemax » Sat Jan 21, 2012 10:27 am

i thought drawing to a bitmap was generally faster than drawing directly to the screen...(?)
I have to admit i never tested this, but that would surprise me.
- at all, when the user uses the mousewheel to scroll
- while the user drags the scrollbar up/down (it is refreshed when the user finally lets go, though).

What other scrollevents are there to catch?
That should catch all events. And i just tested it in a small sample, it does. Are you sure the event handler is not executed in these cases?

Why do you still need the Refresh? I think the code as it is now, should work fine without.
Use the source, Luke!

tuli
Knows some wx things
Knows some wx things
Posts: 42
Joined: Sat Dec 03, 2011 3:56 pm

Re: OnPaint() of wxScrolledWindow in custom wxFrame

Post by tuli » Sat Jan 21, 2012 5:39 pm

i see the problem.

It`s because i tried to have a static bar on top again (which is not scrolled) :roll: . My scroll-handler and the Refresh() are executed just fine, but AFTER that, the OS "helps" scrolling and shifts the static bar up/down...that sucks.


Auria:
It looks like you want some portion of the drawing to stay static no matter how much you scroll. As far as I know Windows tries to optimize scrolling by scrolling what had been already drawn and to ask you to draw only the part remaining.

Maybe you could just use a plain old wxPanel surrounded by plain wxScrollBars? You'd need to manually fake scrolling but you'd have full control
this might be the best solution after all...if i insist on that static bar. Let me think over my GUI concept once more. :P

Post Reply