Showing & Hiding of a managed pane.

Post here wxCrafter related issues / features / bugs
coder99
CodeLite Expert
Posts: 143
Joined: Wed Oct 22, 2008 6:50 am
Contact:

Showing & Hiding of a managed pane.

Post by coder99 » Mon Nov 20, 2017 1:10 am

Using wxCrafter 2.7
As part of my projects in general, I want to be able to include a log window which the user can chose to show or hide.
When I use wxCrafter to build the GUI, I have, simply included a pane at the bottom with a sizer and a multi-line text control.

Up to now, I have not even tried to hide or show this control, but when I recently I decided to do so,I was unable to hide or show this pane via a menu item or shortcut key.
If I include a 'close' button. I can close the pane, but I have not found any way to to show it again.

After a discussion on the wxWidgets forum - see https://forums.wxwidgets.org/viewtopic. ... 37#p180537
I have managed to get this functionality to work by not adding the log window code in wxCrafter, but rather manually adding it in my main frame constructor.

The big difference seems to be in the way the log window is added in these two cases.
Under wxCrafter, the following code is generated:

Code: Select all

m_panelLog = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1,-1)), wxTAB_TRAVERSAL);
    
    m_auimgrMain->AddPane(m_panelLog, wxAuiPaneInfo().Direction(wxAUI_DOCK_BOTTOM).Layer(0).Row(0).Position(0).BestSize(100,100).MinSize(100,100).MaxSize(100,100).CaptionVisible(true).MaximizeButton(false).CloseButton(true).MinimizeButton(false).PinButton(false));
    m_auimgrMain->Update();
    
    wxBoxSizer* boxSizer76 = new wxBoxSizer(wxVERTICAL);
    m_panelLog->SetSizer(boxSizer76);
    
    m_textCtrlLog = new wxTextCtrl(m_panelLog, wxID_ANY, wxT(""), wxDefaultPosition, wxDLG_UNIT(m_panelLog, wxSize(-1,-1)), wxTE_READONLY|wxTE_MULTILINE);
    
    boxSizer76->Add(m_textCtrlLog, 1, wxALL|wxEXPAND, WXC_FROM_DIP(5));
When I manually add the code in the main frame ctor, all I need is

Code: Select all

 m_textCtrlLog = new wxTextCtrl(this, wxID_ANY, wxT(""), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1,-1)), wxTE_READONLY|wxTE_MULTILINE);
   
    m_auimgrMain->AddPane(m_textCtrlLog, wxAuiPaneInfo().Name("logwin").Caption("log").Bottom());
    m_auimgrMain->Update();
The code I use to hide or show the window invoke as an event handler from the menu item or keyboard shortcut:

Code: Select all

void MyFrame::OnMenuLogShow( wxCommandEvent& event) 
{
  wxAuiPaneInfo& info = GetAuimgrMain()->GetPane("logwin");

    if ( info.IsShown() )
    {
        if ( !event.IsChecked() )
        {
            info.Show(false);
            GetAuimgrMain()->Update();
        }
    }
    else
    {
        if ( event.IsChecked() )
        {
            info.Show(true);
            GetAuimgrMain()->Update();
        }
    }
}
The above handler shows/hides the log pane when its code is added manually, but not when it is added by wxCrafter, even when I adjust for the two different names of the text control
The main problem seems to be that wxCrafter dows not allow adding a plain wxTextCtrl, but only 'containers'.
Then again, perhaps the difference is that the wxCrafter code does not 'name' the text ctrl??
Any comments or corrections ?
TIA
Win 10 64-bit, MSVC 2010/2015/2017, wxWidgets 3.1.0, CodeLite 12.0
Fight Spam, report it with wxSR

User avatar
eranif
CodeLite Plugin
Posts: 5863
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Showing & Hiding of a managed pane.

Post by eranif » Mon Nov 20, 2017 10:33 am

Why don't you set the container name to: 'logwin' in wxCrafter?
It will work exactly the same
Make sure you have read the HOW TO POST thread

coder99
CodeLite Expert
Posts: 143
Joined: Wed Oct 22, 2008 6:50 am
Contact:

Re: Showing & Hiding of a managed pane.

Post by coder99 » Mon Nov 20, 2017 9:55 pm

Thank you, Eran
I had missed the separate wxAUI name for the panel and instead used the name (wrong) of the control in my efforts.
Once I filled in the name in wxAuiPanelInfo, I was able to get the code to work as expected - as least as far as showing & hiding goes. :D
Win 10 64-bit, MSVC 2010/2015/2017, wxWidgets 3.1.0, CodeLite 12.0
Fight Spam, report it with wxSR

Post Reply