X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a81258bee4e20d3fa9b3d2f6bf3bcd1200d1e5e0..f5e27805de786dbb3976782ba2a3365c27256031:/src/gtk/notebook.cpp?ds=sidebyside diff --git a/src/gtk/notebook.cpp b/src/gtk/notebook.cpp index f318ba6d2c..feb8c042c5 100644 --- a/src/gtk/notebook.cpp +++ b/src/gtk/notebook.cpp @@ -36,7 +36,6 @@ public: m_box = (GtkWidget *) NULL; } -//private: int m_id; wxString m_text; int m_image; @@ -87,6 +86,40 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height ); } +//----------------------------------------------------------------------------- +// InsertChild callback for wxNotebook +//----------------------------------------------------------------------------- + +static void wxInsertChildInNotebook( wxNotebook* parent, wxWindow* child ) +{ + wxNotebookPage *page = new wxNotebookPage(); + + page->m_id = parent->GetPageCount(); + + page->m_box = gtk_hbox_new (FALSE, 0); + gtk_container_border_width(GTK_CONTAINER(page->m_box), 2); + + GtkNotebook *notebook = GTK_NOTEBOOK(parent->m_widget); + + page->m_client = child; + gtk_notebook_append_page( notebook, child->m_widget, page->m_box ); + + page->m_page = (GtkNotebookPage*) (g_list_last(notebook->children)->data); + + page->m_parent = notebook; + + gtk_signal_connect( GTK_OBJECT(child->m_widget), "size_allocate", + GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)child ); + + if (!page->m_page) + { + wxLogFatalError( "Notebook page creation error" ); + return; + } + + parent->m_pages.Append( page ); +} + //----------------------------------------------------------------------------- // wxNotebook //----------------------------------------------------------------------------- @@ -127,6 +160,7 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id, long style, const wxString& name ) { m_needParent = TRUE; + m_insertCallback = (wxInsertChildFunction)wxInsertChildInNotebook; PreCreation( parent, id, pos, size, style, name ); @@ -141,6 +175,10 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id, (gpointer)this ); + m_parent->AddChild( this ); + + (m_parent->m_insertCallback)( m_parent, this ); + PostCreation(); Show( TRUE ); @@ -411,39 +449,6 @@ wxWindow *wxNotebook::GetPage( int page ) const return nb_page->m_client; } -void wxNotebook::AddChild( wxWindow *win ) -{ - wxCHECK_RET( m_widget != NULL, "invalid notebook" ); - - m_children.Append(win); - - wxNotebookPage *page = new wxNotebookPage(); - - page->m_id = GetPageCount(); - - page->m_box = gtk_hbox_new (FALSE, 0); - gtk_container_border_width(GTK_CONTAINER(page->m_box), 2); - - page->m_client = win; - gtk_notebook_append_page( GTK_NOTEBOOK(m_widget), win->m_widget, page->m_box ); - - page->m_page = - (GtkNotebookPage*) (g_list_last(GTK_NOTEBOOK(m_widget)->children)->data); - - page->m_parent = GTK_NOTEBOOK(m_widget); - - gtk_signal_connect( GTK_OBJECT(win->m_widget), "size_allocate", - GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)win ); - - if (!page->m_page) - { - wxLogFatalError( "Notebook page creation error" ); - return; - } - - m_pages.Append( page ); -} - // override these 2 functions to do nothing: everything is done in OnSize void wxNotebook::SetConstraintSizes( bool WXUNUSED(recurse) ) { @@ -456,23 +461,9 @@ bool wxNotebook::DoPhase( int WXUNUSED(nPhase) ) return TRUE; } -void wxNotebook::SetFont( const wxFont &font ) -{ - wxCHECK_RET( m_widget != NULL, "invalid notebook" ); - - wxControl::SetFont( font ); - - gtk_widget_set_style( m_widget, m_widgetStyle ); -} - -void wxNotebook::SetBackgroundColour( const wxColour &colour ) +void wxNotebook::ApplyWidgetStyle() { - wxCHECK_RET( m_widget != NULL, "invalid notebook" ); - - wxControl::SetBackgroundColour( colour ); - - if (!m_backgroundColour.Ok()) return; - + SetWidgetStyle(); gtk_widget_set_style( m_widget, m_widgetStyle ); }