Author Topic: wxNotebook troubles  (Read 6352 times)

sethjackson

  • Guest
wxNotebook troubles
« on: February 17, 2006, 07:52:28 pm »
Code: cpp
m_pNotebook = new wxNotebook(this,
                                 wxID_ANY,
                                 wxDefaultPosition,
                                 wxDefaultSize);

    // Create a new text control using our member pointer.

m_pTextCtrl = new TextCtrl(m_pNotebook,
                               wxID_ANY,
                           wxEmptyString,
                               wxDefaultPosition,
                               wxDefaultSize,
                               wxTE_MULTILINE | wxHSCROLL);

    m_pNotebook->InsertPage(m_pNotebook->GetPageCount(), m_pTextCtrl);

I get this error.

main.cpp:40: error: no matching function for call to `wxNotebook::InsertPage(size_t, TextCtrl*&)'
C:/wxWidgets-2.6.2/include/wx/msw/notebook.h:136: note: candidates are: virtual bool wxNotebook::InsertPage(size_t, wxNotebookPage*, const wxString&, bool, int)

TextCtrl is my own text control object derived from wxTextCtrl. I wan't to have a tabbed text editor..... How to? Sorry for the dumb question....  :P

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: wxNotebook troubles
« Reply #1 on: February 17, 2006, 08:06:48 pm »
You must provide a wxString for the title, this is not an optional argument.

http://www.wxwidgets.org/manuals/2.6.2/wx_wxnotebook.html#wxnotebookinsertpage
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

sethjackson

  • Guest
Re: wxNotebook troubles
« Reply #2 on: February 17, 2006, 08:13:32 pm »
Ok. Does TextCtrl parent need to be the notebook or this (this = my main frame)?

EDIT:

when TextCtrl parent is the notebook I get SIGSEV.....  :P What am I doing wrong? I want the inserted page to have a wxTextCtrl. How to do this?
« Last Edit: February 17, 2006, 08:17:42 pm by sethjackson »

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: wxNotebook troubles
« Reply #3 on: February 17, 2006, 08:17:37 pm »
I would use this ( = main frame), never sure which is right and which is not, but using the main frame usually works fine with everything :)
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

sethjackson

  • Guest
Re: wxNotebook troubles
« Reply #4 on: February 17, 2006, 08:18:23 pm »
So how do I have my notebook have a tab with a text ctrl?

Offline eranif

  • Regular
  • ***
  • Posts: 256
Re: wxNotebook troubles
« Reply #5 on: February 17, 2006, 08:23:27 pm »
Usually it is better to use the notebook itself as the parent of the page.

In the wxFlatNotebook, for example, the control reparent the page when inserted to it:
Code
AddPage(wxWindow* win, ... )
{
 if(!win)
   return;

 win->Reparent(this);
}

to add text control:

to add a text control just do:
Code
wxTextCtrl *text = new wxTextCtrl(m_pNotebook, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER | wxTE_MULTILINE);
m_pNotebook->AddPage(text, wxT("Page #1"));

Eran
« Last Edit: February 17, 2006, 08:29:07 pm by eranif »

sethjackson

  • Guest
Re: wxNotebook troubles
« Reply #6 on: February 17, 2006, 08:28:26 pm »
I have it working now. Thanks guys.  :D