Discussion:
clientarea not properly redrawn after hide/show toolbar/statusbar
Theo Veenker
2014-10-01 07:40:03 UTC
Permalink
Hi all,

I have a wxFrame with a menu, toolbar and statusbar. The user can toggle the toolbar and
statusbar on and off. It works well with GTK. Under Windows (7) the clientarea doesn't get
repainted properly when toggling toolbar or statusbar visibility.

I tried following the hide/show of toolbar/statusbar with Layout() or Refresh() + Update()
or all three of them. It helps somewhat, but there are still artifacts.

Does anyone know the proper actions (under Windows) that need to follow hide/show
toolbar/statusbar?

Regards,
Theo
--
Theo Veenker | Beexy - Behavioral Experiment Software
+31(0)524-541531 | +31(0)6-42525777 mobile
***@beexy.nl | www.beexy.nl
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Igor Korot
2014-10-01 15:05:12 UTC
Permalink
Hi Theo,
Can you reproduce this in the toolbar/status bar sample?
Thank you.
Post by Theo Veenker
Hi all,
I have a wxFrame with a menu, toolbar and statusbar. The user can toggle
the toolbar and statusbar on and off. It works well with GTK. Under Windows
(7) the clientarea doesn't get repainted properly when toggling toolbar or
statusbar visibility.
I tried following the hide/show of toolbar/statusbar with Layout() or
Refresh() + Update() or all three of them. It helps somewhat, but there are
still artifacts.
Does anyone know the proper actions (under Windows) that need to follow
hide/show toolbar/statusbar?
Regards,
Theo
--
Theo Veenker | Beexy - Behavioral Experiment Software
+31(0)524-541531 | +31(0)6-42525777 mobile
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
or visit http://groups.google.com/group/wx-users
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Theo Veenker
2014-10-01 18:24:09 UTC
Permalink
Post by Igor Korot
Hi Theo,
Can you reproduce this in the toolbar/status bar sample?
Thank you.
Yes (well, not in in the statbar sample since the window has no content).

Take the toolbar sample and change content of
void MyFrame::OnToggleAnotherToolbar(wxCommandEvent& WXUNUSED(event))
to:
static bool show = true;
show = !show;
wxStatusBar* statusbar = GetStatusBar();
if (statusbar) statusbar->Show(show);

Then run the thing and play with the "toggle another toolbar" option. In my actual
application the problem is mostly occurs when making the statusbar shown after having
resized the frame. I can work around it by calling SetClientSize() twice after toggling
the statusbar; first with current client size + 1, then back to current client size.

Note I'm using Show() instead of create/delete. Could that be the problem?

Theo
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Vadim Zeitlin
2014-10-01 22:16:49 UTC
Permalink
On Wed, 01 Oct 2014 20:24:09 +0200 Theo Veenker wrote:

TV> On 10/01/2014 05:05 PM, Igor Korot wrote:
TV> > Hi Theo,
TV> > Can you reproduce this in the toolbar/status bar sample?
TV> > Thank you.
TV>
TV> Yes (well, not in in the statbar sample since the window has no content).
TV>
TV> Take the toolbar sample and change content of
TV> void MyFrame::OnToggleAnotherToolbar(wxCommandEvent& WXUNUSED(event))
TV> to:
TV> static bool show = true;
TV> show = !show;
TV> wxStatusBar* statusbar = GetStatusBar();
TV> if (statusbar) statusbar->Show(show);

I don't see any particular problems with this change under Windows 7:

-- >8 --
diff --git a/samples/toolbar/toolbar.cpp b/samples/toolbar/toolbar.cpp
index c85371c..192e796 100644
--- a/samples/toolbar/toolbar.cpp
+++ b/samples/toolbar/toolbar.cpp
@@ -718,6 +718,10 @@ void MyFrame::OnToggleHorizontalText(wxCommandEvent& WXUNUSED(event))

void MyFrame::OnToggleAnotherToolbar(wxCommandEvent& WXUNUSED(event))
{
+ GetStatusBar()->Show(!GetStatusBar()->IsShown());
+ PostSizeEvent();
+ return;
+
if ( m_tbar )
{
wxDELETE(m_tbar);
-- >8 --

Of course, you do need the call to PostSizeEvent() as otherwise the main
frame wouldn't be relaid out, as it has to be, to account for the status
bar [dis]appearance.

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Theo Veenker
2014-10-02 06:18:55 UTC
Permalink
Post by Vadim Zeitlin
TV> > Hi Theo,
TV> > Can you reproduce this in the toolbar/status bar sample?
TV> > Thank you.
TV>
TV> Yes (well, not in in the statbar sample since the window has no content).
TV>
TV> Take the toolbar sample and change content of
TV> void MyFrame::OnToggleAnotherToolbar(wxCommandEvent& WXUNUSED(event))
TV> static bool show = true;
TV> show = !show;
TV> wxStatusBar* statusbar = GetStatusBar();
TV> if (statusbar) statusbar->Show(show);
-- >8 --
diff --git a/samples/toolbar/toolbar.cpp b/samples/toolbar/toolbar.cpp
index c85371c..192e796 100644
--- a/samples/toolbar/toolbar.cpp
+++ b/samples/toolbar/toolbar.cpp
@@ -718,6 +718,10 @@ void MyFrame::OnToggleHorizontalText(wxCommandEvent& WXUNUSED(event))
void MyFrame::OnToggleAnotherToolbar(wxCommandEvent& WXUNUSED(event))
{
+ GetStatusBar()->Show(!GetStatusBar()->IsShown());
+ PostSizeEvent();
+ return;
+
if ( m_tbar )
{
wxDELETE(m_tbar);
-- >8 --
Of course, you do need the call to PostSizeEvent() as otherwise the main
frame wouldn't be relaid out, as it has to be, to account for the status
bar [dis]appearance.
Thanks, that did the trick. Shouldn't a wxFrame do this itself when its
toolbar/statusbar/menubar are shown/hidden?

Theo
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Vadim Zeitlin
2014-10-02 14:25:15 UTC
Permalink
On Thu, 02 Oct 2014 08:18:55 +0200 Theo Veenker wrote:

TV> > Of course, you do need the call to PostSizeEvent() as otherwise the main
TV> > frame wouldn't be relaid out, as it has to be, to account for the status
TV> > bar [dis]appearance.
TV>
TV> Thanks, that did the trick. Shouldn't a wxFrame do this itself when its
TV> toolbar/statusbar/menubar are shown/hidden?

First of all, if you hide the status bar directly, wxFrame has no
knowledge about this happening, so it can hardly do anything. Second, if
you do several changes, e.g. hide the status bar, show the tool bar, change
position of something else and so on, it's better to call PostSizeEvent()
once from your code than do it several times from inside wxWidgets, which
has no idea which change is the last one.

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Theo Veenker
2014-10-02 14:33:34 UTC
Permalink
Post by Vadim Zeitlin
TV> > Of course, you do need the call to PostSizeEvent() as otherwise the main
TV> > frame wouldn't be relaid out, as it has to be, to account for the status
TV> > bar [dis]appearance.
TV>
TV> Thanks, that did the trick. Shouldn't a wxFrame do this itself when its
TV> toolbar/statusbar/menubar are shown/hidden?
First of all, if you hide the status bar directly, wxFrame has no
knowledge about this happening, so it can hardly do anything. Second, if
you do several changes, e.g. hide the status bar, show the tool bar, change
position of something else and so on, it's better to call PostSizeEvent()
once from your code than do it several times from inside wxWidgets, which
has no idea which change is the last one.
Got it. Thanks.

Theo
--
Theo Veenker | Beexy - Behavioral Experiment Software
+31(0)524-541531 | +31(0)6-42525777 mobile
***@beexy.nl | www.beexy.nl
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Loading...