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.
-
doublemax
- Moderator

- Posts: 15651
- Joined: Fri Apr 21, 2006 8:03 pm
- Location: $FCE2
Post
by doublemax » Fri Sep 05, 2014 11:54 am
I now use wxAutoBufferedPaintDC, u mean that it internally creates a bitmap each time?
Yes. Unless the underlying OS performs double buffering by default.
You can use a static bitmap as buffer only with wxBufferedPaintDC.
Code: Select all
// assumes wxBitmap m_buffer; as member variable of ImagePanel:
void ImagePanel::OnPaint(wxPaintEvent &WXUNUSED(event))
{
wxSize size = GetClientSize();
// recreate bitmap if the size of the window has changed
if( m_buffer.IsOk()==false || m_buffer.GetWidth()!=size.x || m_buffer.GetHeight()!=size.y)
{
m_buffer.Create(size);
}
wxBufferedPaintDC dc(this, m_buffer);
// drawing code here
}
Use the source, Luke!
-
gpu
- Experienced Solver

- Posts: 92
- Joined: Tue Aug 12, 2014 3:46 am
Post
by gpu » Tue Sep 09, 2014 1:58 am
I tried this method, for both the big panel and small panel. It's better and faster rendering when fast move the panel, but still have that "dragging" appearance when move the big panel...
and I am really comfused that why the 1st big panel I add on the wxScrollWindow is always perfect, but when I add the 2nd panel, and drag the 2nd it's worse, while move the 1st one it's still perfect! and the more i add, the latter one looks worse....
ps.another problem is that I now use Refresh() everywhere I need to refresh, for wxScrollWindow, big panel, small panel...might it be another problem? and what is the difference of it from Update, InvalidateRect? which one is more efficient?
-
doublemax
- Moderator

- Posts: 15651
- Joined: Fri Apr 21, 2006 8:03 pm
- Location: $FCE2
Post
by doublemax » Tue Sep 09, 2014 8:12 am
I tried this method, for both the big panel and small panel. It's better and faster rendering when fast move the panel, but still have that "dragging" appearance when move the big panel...
Any chance you can make a video of this? Because i can't really imaging what you're seeing.
I am really comfused that why the 1st big panel I add on the wxScrollWindow is always perfect, but when I add the 2nd panel, and drag the 2nd it's worse, while move the 1st one it's still perfect! and the more i add, the latter one looks worse....
I have no idea about this. Do these big panels overlap? wxWidgets doesn't support overlapping siblings, which could lead to some redraw issues.
and what is the difference of it from Update, InvalidateRect? which one is more efficient?
Refresh() invalidates the whole window which will then receive a paint event later. Update() forces an immediate redraw of the invalidated parts of the window. Of course it's more efficient to invalidate only the parts of the window that have actually changed, but don't think this would improve the performance very much in your case.
Use the source, Luke!
-
gpu
- Experienced Solver

- Posts: 92
- Joined: Tue Aug 12, 2014 3:46 am
Post
by gpu » Tue Sep 09, 2014 10:09 am
ok, I will make a video. May I send it to ur email ? I found upload file here is very slow...
and I found when move the panel, if I call the panel's Update instead of Refresh(), it's better, but the semi-transparent backgound is wrong cause of no refresh...
-
doublemax
- Moderator

- Posts: 15651
- Joined: Fri Apr 21, 2006 8:03 pm
- Location: $FCE2
Post
by doublemax » Tue Sep 09, 2014 11:04 am
May I send it to ur email ?
Make a private youtube video and post the link.
Use the source, Luke!
-
gpu
- Experienced Solver

- Posts: 92
- Joined: Tue Aug 12, 2014 3:46 am
Post
by gpu » Tue Sep 09, 2014 12:57 pm
i tried, but upload was failed..it's 27M.
-
doublemax
- Moderator

- Posts: 15651
- Joined: Fri Apr 21, 2006 8:03 pm
- Location: $FCE2
Post
by doublemax » Wed Sep 10, 2014 9:50 am
I saw the video, i know what you mean now. What OS is that? If it's Windows7 or 8, can you try on a XP machine? I'm wondering if the internal double buffering of Windows7/8 somehow interferes.
Use the source, Luke!
-
gpu
- Experienced Solver

- Posts: 92
- Joined: Tue Aug 12, 2014 3:46 am
Post
by gpu » Wed Sep 10, 2014 9:59 am
win 8
well, I compiled wxWidgets using DLL_DEBUG in vs2013, i guess it is defaut 64bit, so can't run on winXP...
-
jingyu9575
- In need of some credit

- Posts: 7
- Joined: Sun Mar 30, 2014 3:39 am
Post
by jingyu9575 » Wed Sep 10, 2014 3:56 pm
gpu wrote:win 8
well, I compiled wxWidgets using DLL_DEBUG in vs2013, i guess it is defaut 64bit, so can't run on winXP...
Hi,
vs2013 builds to 32bit EXE by default, but it uses new API so it won't run on XP. To get a XP-compatible build, right click your project and select "Properties", then "Configuration Properties" -> "General", change "Platform Toolset" to "Visual Studio 2013 - Windows XP (v120_xp)" and rebuild.
-
doublemax
- Moderator

- Posts: 15651
- Joined: Fri Apr 21, 2006 8:03 pm
- Location: $FCE2
Post
by doublemax » Wed Sep 10, 2014 4:28 pm
I don't have many ideas about this anyway. Could you show the code where you move the panel?
Use the source, Luke!
-
gpu
- Experienced Solver

- Posts: 92
- Joined: Tue Aug 12, 2014 3:46 am
Post
by gpu » Thu Sep 11, 2014 2:21 am
doublemax wrote:I don't have many ideas about this anyway. Could you show the code where you move the panel?
ok
Code: Select all
void MyPanel::MouseMove(wxMouseEvent& event)
{
if(IsDragging)
{
//get the position
...
this->Move(pos);
MyFrame* frame = wxDynamicCast(GetParent(), MyFrame);
if(frame != NULL)
{
frame->Refresh();
}
Refresh();
}
}
void MyPanel::LeftDown(...)
{
CaptureMouse();
IsDragging = true;
}
void MyPanel::LeftUp(...)
{
ReleaseMouse();
IsDragging = false;
}
-
gpu
- Experienced Solver

- Posts: 92
- Joined: Tue Aug 12, 2014 3:46 am
Post
by gpu » Thu Sep 11, 2014 2:29 am
and the Render func is like what we disscussed before, for big panel and small panel, first call parent->Render(), then draw its own bitmap and others. the frame is the big panel's parent, and the big panel is the small panel's parent. for the frame, in its Render(), just do its own drawings.
and all of them use wxBufferPaintDC.
-
doublemax
- Moderator

- Posts: 15651
- Joined: Fri Apr 21, 2006 8:03 pm
- Location: $FCE2
Post
by doublemax » Thu Sep 11, 2014 9:33 am
Code: Select all
MyFrame* frame = wxDynamicCast(GetParent(), MyFrame);
if(frame != NULL)
{
frame->Refresh();
}
Refresh();
Did you check if these Redraw calls are needed? Refreshing the panel itself shouldn't be necessary at all and under normal circumstances redrawing the frame shouldn't be needed either.
Use the source, Luke!
-
gpu
- Experienced Solver

- Posts: 92
- Joined: Tue Aug 12, 2014 3:46 am
Post
by gpu » Fri Sep 12, 2014 2:24 am
I all tired...
Last edited by
gpu on Wed Sep 17, 2014 8:31 am, edited 1 time in total.
-
gpu
- Experienced Solver

- Posts: 92
- Joined: Tue Aug 12, 2014 3:46 am
Post
by gpu » Wed Sep 17, 2014 8:30 am
I all tired...
but the two Refresh are both nessesary.
if no Refresh for the frame, the linked lines will not refresh...
if no Refresh for the panel, the panel's background will not right......