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));
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();
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 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