From: Vadim Zeitlin Date: Thu, 3 Sep 1998 16:59:51 +0000 (+0000) Subject: wxNotebook now supports the item images (except for the mask problem!) X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/24d20a8f73c28b8a443c783fac24290edb2f6c11?ds=sidebyside wxNotebook now supports the item images (except for the mask problem!) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@661 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/gtk/notebook.cpp b/src/gtk/notebook.cpp index cd33a23f62..e102ce8409 100644 --- a/src/gtk/notebook.cpp +++ b/src/gtk/notebook.cpp @@ -34,6 +34,7 @@ public: m_page = (GtkNotebookPage *) NULL; m_client = (wxWindow *) NULL; m_parent = (GtkNotebook *) NULL; + m_box = (GtkWidget *) NULL; } //private: @@ -44,6 +45,7 @@ public: GtkLabel *m_label; wxWindow *m_client; GtkNotebook *m_parent; + GtkWidget *m_box; // in which the label and image are packed }; //----------------------------------------------------------------------------- @@ -370,7 +372,7 @@ bool wxNotebook::AddPage(wxWindow* win, const wxString& text, } wxCHECK_MSG(page != NULL, FALSE, - _("Can't add a page whose parent is not the notebook!")); + "Can't add a page whose parent is not the notebook!"); // then set the attributes page->m_text = text; @@ -379,6 +381,19 @@ bool wxNotebook::AddPage(wxWindow* win, const wxString& text, page->m_image = imageId; gtk_label_set(page->m_label, page->m_text); + // create the image if any + if ( imageId != -1 ) { + wxASSERT( m_imageList != NULL ); + + wxBitmap *bmp = m_imageList->GetBitmap(imageId); + GdkPixmap *pixmap = bmp->GetPixmap(); + GtkWidget *pixmapwid = gtk_pixmap_new (pixmap, NULL /* @@@@ */); + + gtk_box_pack_start(GTK_BOX(page->m_box), pixmapwid, FALSE, FALSE, 3); + + gtk_widget_show(pixmapwid); + } + if ( bSelect ) { SetSelection(GetPageCount()); } @@ -402,10 +417,18 @@ void wxNotebook::AddChild( wxWindow *win ) wxNotebookPage *page = new wxNotebookPage(); page->m_id = GetPageCount(); - page->m_label = (GtkLabel *)gtk_label_new(_("Handle")); + + page->m_box = gtk_hbox_new (FALSE, 0); + gtk_container_border_width(GTK_CONTAINER(page->m_box), 2); + + page->m_label = (GtkLabel *)gtk_label_new(""); + gtk_box_pack_start(GTK_BOX(page->m_box), (GtkWidget *)page->m_label, + FALSE, FALSE, 3); + gtk_widget_show((GtkWidget *)page->m_label); + page->m_client = win; gtk_notebook_append_page( GTK_NOTEBOOK(m_widget), win->m_widget, - (GtkWidget *)page->m_label); + page->m_box ); gtk_misc_set_alignment(GTK_MISC(page->m_label), 0.0, 0.5); page->m_page = diff --git a/src/gtk1/notebook.cpp b/src/gtk1/notebook.cpp index cd33a23f62..e102ce8409 100644 --- a/src/gtk1/notebook.cpp +++ b/src/gtk1/notebook.cpp @@ -34,6 +34,7 @@ public: m_page = (GtkNotebookPage *) NULL; m_client = (wxWindow *) NULL; m_parent = (GtkNotebook *) NULL; + m_box = (GtkWidget *) NULL; } //private: @@ -44,6 +45,7 @@ public: GtkLabel *m_label; wxWindow *m_client; GtkNotebook *m_parent; + GtkWidget *m_box; // in which the label and image are packed }; //----------------------------------------------------------------------------- @@ -370,7 +372,7 @@ bool wxNotebook::AddPage(wxWindow* win, const wxString& text, } wxCHECK_MSG(page != NULL, FALSE, - _("Can't add a page whose parent is not the notebook!")); + "Can't add a page whose parent is not the notebook!"); // then set the attributes page->m_text = text; @@ -379,6 +381,19 @@ bool wxNotebook::AddPage(wxWindow* win, const wxString& text, page->m_image = imageId; gtk_label_set(page->m_label, page->m_text); + // create the image if any + if ( imageId != -1 ) { + wxASSERT( m_imageList != NULL ); + + wxBitmap *bmp = m_imageList->GetBitmap(imageId); + GdkPixmap *pixmap = bmp->GetPixmap(); + GtkWidget *pixmapwid = gtk_pixmap_new (pixmap, NULL /* @@@@ */); + + gtk_box_pack_start(GTK_BOX(page->m_box), pixmapwid, FALSE, FALSE, 3); + + gtk_widget_show(pixmapwid); + } + if ( bSelect ) { SetSelection(GetPageCount()); } @@ -402,10 +417,18 @@ void wxNotebook::AddChild( wxWindow *win ) wxNotebookPage *page = new wxNotebookPage(); page->m_id = GetPageCount(); - page->m_label = (GtkLabel *)gtk_label_new(_("Handle")); + + page->m_box = gtk_hbox_new (FALSE, 0); + gtk_container_border_width(GTK_CONTAINER(page->m_box), 2); + + page->m_label = (GtkLabel *)gtk_label_new(""); + gtk_box_pack_start(GTK_BOX(page->m_box), (GtkWidget *)page->m_label, + FALSE, FALSE, 3); + gtk_widget_show((GtkWidget *)page->m_label); + page->m_client = win; gtk_notebook_append_page( GTK_NOTEBOOK(m_widget), win->m_widget, - (GtkWidget *)page->m_label); + page->m_box ); gtk_misc_set_alignment(GTK_MISC(page->m_label), 0.0, 0.5); page->m_page =