void SetPadding( const wxSize& padding );
bool DeleteAllPages(void);
bool DeletePage( const int page );
- bool AddPage( const int page, const wxString& text, wxWindow* win, const int imageId = -1, void* data = NULL );
+ bool AddPage(wxWindow* win, const wxString& text, const int imageId = -1, void* data = NULL );
wxWindow *GetPageWindow( const int page ) const;
// overriden to do nothing
wxImageList* m_imageList;
wxList m_pages;
- GtkWidget *m_frame;
DECLARE_EVENT_TABLE()
};
void SetPadding( const wxSize& padding );
bool DeleteAllPages(void);
bool DeletePage( const int page );
- bool AddPage( const int page, const wxString& text, wxWindow* win, const int imageId = -1, void* data = NULL );
+ bool AddPage(wxWindow* win, const wxString& text, const int imageId = -1, void* data = NULL );
wxWindow *GetPageWindow( const int page ) const;
// overriden to do nothing
wxImageList* m_imageList;
wxList m_pages;
- GtkWidget *m_frame;
DECLARE_EVENT_TABLE()
};
"think?"
};
- wxPanel *panel = m_notebook->CreatePage( 0, "wxList" );
-
+ wxPanel *panel = new wxPanel(m_notebook);
m_listbox = new wxListBox( panel, ID_LISTBOX, wxPoint(10,10), wxSize(120,70), 9, choices );
(void)new wxButton( panel, ID_LISTBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(100,30) );
(void)new wxButton( panel, ID_LISTBOX_SEL_STR, "Select 'This'", wxPoint(300,30), wxSize(100,30) );
(void)new wxButton( panel, ID_LISTBOX_CLEAR, "Clear", wxPoint(180,80), wxSize(100,30) );
(void)new wxButton( panel, ID_LISTBOX_APPEND, "Append 'Hi!'", wxPoint(300,80), wxSize(100,30) );
+ m_notebook->AddPage(panel, "wxList");
- panel = m_notebook->CreatePage( 1, "wxChoice" );
-
+ panel = new wxPanel(m_notebook);
m_choice = new wxChoice( panel, ID_CHOICE, wxPoint(10,10), wxSize(120,-1), 9, choices );
+ m_notebook->AddPage(panel, "wxChoice");
- panel = m_notebook->CreatePage( 2, "wxComboBox" );
-
+ panel = new wxPanel(m_notebook);
m_combo = new wxComboBox( panel, ID_COMBO, "This", wxPoint(10,10), wxSize(120,-1), 9, choices );
+ m_notebook->AddPage(panel, "wxComboBox");
}
void MyPanel::OnSize( wxSizeEvent& WXUNUSED(event) )
#include "wx/panel.h"
#include "wx/utils.h"
#include "wx/imaglist.h"
+#include "wx/intl.h"
+#include "wx/log.h"
//-----------------------------------------------------------------------------
// wxNotebookPage
int m_image;
void *m_clientData;
GtkNotebookPage *m_page;
+ GtkLabel *m_label;
wxWindow *m_clientPanel;
- wxNotebookPage(void)
+ wxNotebookPage()
{
m_id = -1;
m_text = "";
wxNotebook::wxNotebook(void)
{
m_imageList = NULL;
- m_frame = NULL;
m_pages.DeleteContents( TRUE );
};
const long style, const wxString& name )
{
m_imageList = NULL;
- m_frame = NULL;
m_pages.DeleteContents( TRUE );
Create( parent, id, pos, size, style, name );
};
if (nb_page)
return nb_page->m_image;
else
- return NULL;
+ return 0;
};
void* wxNotebook::GetPageData( const int page ) const
return TRUE;
};
-bool wxNotebook::AddPage( const int item, const wxString &text, wxWindow* win, const int imageId, void* data )
+bool wxNotebook::AddPage(wxWindow* win, const wxString& text, const int imageId, void* data)
{
- wxNotebookPage *page = new wxNotebookPage;
+ // we've created the notebook page in AddChild(). Now we just have to set
+ // the caption for the page and set the others parameters.
- page->m_text = text;
- if (page->m_text.IsNull()) page->m_text = "";
- page->m_id = item;
- page->m_image = imageId;
- page->m_clientData = data;
-
- m_frame = gtk_label_new( page->m_text );
- gtk_notebook_append_page( GTK_NOTEBOOK(m_widget), win->m_widget, m_frame );
-
- gtk_misc_set_alignment( GTK_MISC(m_frame), 0.0, 0.5 );
+ // first, find the page
+ wxNotebookPage *page = NULL;
- page->m_clientPanel = win;
-// page->m_clientPanel = new wxPanel( this, -1, wxPoint(0,0), wxSize(100,100) );
-
- m_frame = NULL;
-
- page->m_page = (GtkNotebookPage*)( g_list_last( GTK_NOTEBOOK(m_widget)->children )->data );
-
- if (!page->m_page)
+ wxNode *node = m_pages.First();
+ while (node)
{
- wxFatalError( "Notebook page creation error" );
- return FALSE;
- }
+ page = (wxNotebookPage*)node->Data();
+ if ( page->m_clientPanel == win )
+ break; // found
+ node = node->Next();
+ };
+
+ if ( page == NULL ) {
+ wxFAIL_MSG("Can't add a page whose parent is not the notebook!");
- m_pages.Append( page );
+ return FALSE;
+ }
+
+ // then set the attributes
+ page->m_text = text;
+ if ( page->m_text.IsEmpty() )
+ page->m_text = "";
+ page->m_image = imageId;
+ page->m_clientData = data;
+ gtk_label_set(page->m_label, page->m_text);
return TRUE;
};
void wxNotebook::AddChild( wxWindow *win )
{
- if (!m_frame) wxFatalError( "Notebook::Addchild() must not be called directly." );
+ wxNotebookPage *page = new wxNotebookPage();
+
+ page->m_id = GetPageCount();
+ page->m_label = (GtkLabel *)gtk_label_new("no caption");
+ page->m_clientPanel = win;
+ gtk_notebook_append_page(GTK_NOTEBOOK(m_widget), win->m_widget,
+ (GtkWidget *)page->m_label);
+ gtk_misc_set_alignment(GTK_MISC(page->m_label), 0.0, 0.5);
+
+ page->m_page = (GtkNotebookPage*)
+ (
+ g_list_last(GTK_NOTEBOOK(m_widget)->children)->data
+ );
-// gtk_notebook_append_page( GTK_NOTEBOOK(m_widget), win->m_widget, m_frame );
+ if (!page->m_page)
+ {
+ wxLogFatalError( "Notebook page creation error" );
+ return;
+ }
+
+ m_pages.Append( page );
};
//-----------------------------------------------------------------------------
#include "wx/panel.h"
#include "wx/utils.h"
#include "wx/imaglist.h"
+#include "wx/intl.h"
+#include "wx/log.h"
//-----------------------------------------------------------------------------
// wxNotebookPage
int m_image;
void *m_clientData;
GtkNotebookPage *m_page;
+ GtkLabel *m_label;
wxWindow *m_clientPanel;
- wxNotebookPage(void)
+ wxNotebookPage()
{
m_id = -1;
m_text = "";
wxNotebook::wxNotebook(void)
{
m_imageList = NULL;
- m_frame = NULL;
m_pages.DeleteContents( TRUE );
};
const long style, const wxString& name )
{
m_imageList = NULL;
- m_frame = NULL;
m_pages.DeleteContents( TRUE );
Create( parent, id, pos, size, style, name );
};
if (nb_page)
return nb_page->m_image;
else
- return NULL;
+ return 0;
};
void* wxNotebook::GetPageData( const int page ) const
return TRUE;
};
-bool wxNotebook::AddPage( const int item, const wxString &text, wxWindow* win, const int imageId, void* data )
+bool wxNotebook::AddPage(wxWindow* win, const wxString& text, const int imageId, void* data)
{
- wxNotebookPage *page = new wxNotebookPage;
+ // we've created the notebook page in AddChild(). Now we just have to set
+ // the caption for the page and set the others parameters.
- page->m_text = text;
- if (page->m_text.IsNull()) page->m_text = "";
- page->m_id = item;
- page->m_image = imageId;
- page->m_clientData = data;
-
- m_frame = gtk_label_new( page->m_text );
- gtk_notebook_append_page( GTK_NOTEBOOK(m_widget), win->m_widget, m_frame );
-
- gtk_misc_set_alignment( GTK_MISC(m_frame), 0.0, 0.5 );
+ // first, find the page
+ wxNotebookPage *page = NULL;
- page->m_clientPanel = win;
-// page->m_clientPanel = new wxPanel( this, -1, wxPoint(0,0), wxSize(100,100) );
-
- m_frame = NULL;
-
- page->m_page = (GtkNotebookPage*)( g_list_last( GTK_NOTEBOOK(m_widget)->children )->data );
-
- if (!page->m_page)
+ wxNode *node = m_pages.First();
+ while (node)
{
- wxFatalError( "Notebook page creation error" );
- return FALSE;
- }
+ page = (wxNotebookPage*)node->Data();
+ if ( page->m_clientPanel == win )
+ break; // found
+ node = node->Next();
+ };
+
+ if ( page == NULL ) {
+ wxFAIL_MSG("Can't add a page whose parent is not the notebook!");
- m_pages.Append( page );
+ return FALSE;
+ }
+
+ // then set the attributes
+ page->m_text = text;
+ if ( page->m_text.IsEmpty() )
+ page->m_text = "";
+ page->m_image = imageId;
+ page->m_clientData = data;
+ gtk_label_set(page->m_label, page->m_text);
return TRUE;
};
void wxNotebook::AddChild( wxWindow *win )
{
- if (!m_frame) wxFatalError( "Notebook::Addchild() must not be called directly." );
+ wxNotebookPage *page = new wxNotebookPage();
+
+ page->m_id = GetPageCount();
+ page->m_label = (GtkLabel *)gtk_label_new("no caption");
+ page->m_clientPanel = win;
+ gtk_notebook_append_page(GTK_NOTEBOOK(m_widget), win->m_widget,
+ (GtkWidget *)page->m_label);
+ gtk_misc_set_alignment(GTK_MISC(page->m_label), 0.0, 0.5);
+
+ page->m_page = (GtkNotebookPage*)
+ (
+ g_list_last(GTK_NOTEBOOK(m_widget)->children)->data
+ );
-// gtk_notebook_append_page( GTK_NOTEBOOK(m_widget), win->m_widget, m_frame );
+ if (!page->m_page)
+ {
+ wxLogFatalError( "Notebook page creation error" );
+ return;
+ }
+
+ m_pages.Append( page );
};
//-----------------------------------------------------------------------------