Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: polygon7 on August 12, 2006, 06:06:51 pm

Title: How to add new page to the editor (something like wxSmith does)?
Post by: polygon7 on August 12, 2006, 06:06:51 pm
Hi,
I'm trying to add simple blank wxFlatNotebook page to the Editor (something like wxSmith does), but with this code:
Code: cpp
class PluginTest : public cbPlugin
{
(...)
 private:
        DECLARE_EVENT_TABLE();
        void OnMenuClick(wxCommandEvent& event);
        wxFlatNotebook* m_Notebook;
        wxPanel* m_Panel;
};
//-------------------------------------------------------------------------------------------
static int NewPanelId = wxNewId();

void PluginTest::OnMenuClick(wxCommandEvent& event)
{
    Manager::Get()->GetMessageManager()->Log(_("\nPluginTest::OnMenuClick() clicked.\n"));
    m_Notebook = Manager::Get()->GetEditorManager()->GetNotebook();
    //wxFlatNotebook* Notebook = Manager::Get()->GetProjectManager()->GetNotebook();
    if (m_Notebook)
    {
        Manager::Get()->GetMessageManager()->Log(_("\nManager::Get()->GetProjectManager()->GetNotebook() == TRUE\n"));
        m_Panel = new wxPanel(m_Notebook, NewPanelId, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER);
        m_Notebook->AddPage(m_Panel, _("Testing, testing..."));
    }
}
I have alot of "crash" messageboxes (endless-loop?) when I click on newly created page. :(
Could somebody tell me (in simple words please :P, I'm wxWidgets newbie) what is wrong with my code?
Title: Re: How to add new page to the editor (something like wxSmith does)?
Post by: mandrav on August 12, 2006, 06:47:11 pm
In order to add a new page in the editors' notebook, your page must derive from EditorBase (not from wxPanel).
When you create your EditorBase-derived page, it is automatically added to the notebook...
Title: Re: How to add new page to the editor (something like wxSmith does)?
Post by: polygon7 on August 12, 2006, 09:04:59 pm
Thank you, it works :)