+ m_pages.Insert(win, position);
+
+ // set the label image and text
+ // this must be done before adding the page, as GetPageText
+ // and GetPageImage will otherwise return wrong values in
+ // the page-changed event that results from inserting the
+ // first page.
+ nb_page->m_image = imageId;
+ nb_page->m_text = wxStripMenuCodes(text);
+
+ nb_page->m_box = gtk_hbox_new( FALSE, 1 );
+ gtk_container_set_border_width((GtkContainer*)nb_page->m_box, 2);
+
+ gint idx = gtk_notebook_insert_page(notebook, win->m_widget,
+ nb_page->m_box, position);
+
+ nb_page->m_page = (GtkNotebookPage *)gtk_notebook_get_nth_page(notebook, idx);
+
+ if (imageId != -1)
+ {
+ wxASSERT( m_imageList != NULL );
+
+ const wxBitmap *bmp = m_imageList->GetBitmapPtr(imageId);
+ GtkWidget* pixmapwid = gtk_image_new_from_pixbuf(bmp->GetPixbuf());
+ gtk_box_pack_start(GTK_BOX(nb_page->m_box), pixmapwid, FALSE, FALSE, m_padding);
+ gtk_widget_show(pixmapwid);
+ }
+
+ /* set the label text */
+ nb_page->m_label = GTK_LABEL( gtk_label_new(wxGTK_CONV(nb_page->m_text)) );
+ gtk_box_pack_end( GTK_BOX(nb_page->m_box), GTK_WIDGET(nb_page->m_label), FALSE, FALSE, m_padding );
+
+ /* apply current style */
+ GtkRcStyle *style = CreateWidgetStyle();
+ if ( style )
+ {
+ gtk_widget_modify_style(GTK_WIDGET(nb_page->m_label), style);
+ gtk_rc_style_unref(style);
+ }
+
+ /* show the label */
+ gtk_widget_show( GTK_WIDGET(nb_page->m_label) );
+
+ if (select && (m_pagesData.GetCount() > 1))
+ {
+ SetSelection( position );
+ }
+
+ InvalidateBestSize();
+ return true;
+}
+
+// helper for HitTest(): check if the point lies inside the given widget which
+// is the child of the notebook whose position and border size are passed as
+// parameters
+static bool
+IsPointInsideWidget(const wxPoint& pt, GtkWidget *w,
+ gint x, gint y, gint border = 0)