changed the notebook control to use AddPage() interface (Julian's version
didn't work at all) andupdated the sample to work with it git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@113 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
5bfe9bbc65
commit
4bf58c62d2
@ -68,7 +68,7 @@ class wxNotebook: public wxControl
|
||||
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
|
||||
@ -78,7 +78,6 @@ class wxNotebook: public wxControl
|
||||
|
||||
wxImageList* m_imageList;
|
||||
wxList m_pages;
|
||||
GtkWidget *m_frame;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
@ -68,7 +68,7 @@ class wxNotebook: public wxControl
|
||||
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
|
||||
@ -78,7 +78,6 @@ class wxNotebook: public wxControl
|
||||
|
||||
wxImageList* m_imageList;
|
||||
wxList m_pages;
|
||||
GtkWidget *m_frame;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
@ -162,21 +162,21 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
|
||||
"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) )
|
||||
|
@ -16,6 +16,8 @@
|
||||
#include "wx/panel.h"
|
||||
#include "wx/utils.h"
|
||||
#include "wx/imaglist.h"
|
||||
#include "wx/intl.h"
|
||||
#include "wx/log.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxNotebookPage
|
||||
@ -30,9 +32,10 @@ class wxNotebookPage: public wxObject
|
||||
int m_image;
|
||||
void *m_clientData;
|
||||
GtkNotebookPage *m_page;
|
||||
GtkLabel *m_label;
|
||||
wxWindow *m_clientPanel;
|
||||
|
||||
wxNotebookPage(void)
|
||||
wxNotebookPage()
|
||||
{
|
||||
m_id = -1;
|
||||
m_text = "";
|
||||
@ -56,7 +59,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxNotebook,wxControl)
|
||||
wxNotebook::wxNotebook(void)
|
||||
{
|
||||
m_imageList = NULL;
|
||||
m_frame = NULL;
|
||||
m_pages.DeleteContents( TRUE );
|
||||
};
|
||||
|
||||
@ -65,7 +67,6 @@ wxNotebook::wxNotebook( wxWindow *parent, const wxWindowID id,
|
||||
const long style, const wxString& name )
|
||||
{
|
||||
m_imageList = NULL;
|
||||
m_frame = NULL;
|
||||
m_pages.DeleteContents( TRUE );
|
||||
Create( parent, id, pos, size, style, name );
|
||||
};
|
||||
@ -144,7 +145,7 @@ int wxNotebook::GetPageImage( const int page ) const
|
||||
if (nb_page)
|
||||
return nb_page->m_image;
|
||||
else
|
||||
return NULL;
|
||||
return 0;
|
||||
};
|
||||
|
||||
void* wxNotebook::GetPageData( const int page ) const
|
||||
@ -282,35 +283,36 @@ bool wxNotebook::DeletePage( const int page )
|
||||
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.
|
||||
|
||||
// first, find the page
|
||||
wxNotebookPage *page = NULL;
|
||||
|
||||
wxNode *node = m_pages.First();
|
||||
while (node)
|
||||
{
|
||||
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!");
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// then set the attributes
|
||||
page->m_text = text;
|
||||
if (page->m_text.IsNull()) page->m_text = "";
|
||||
page->m_id = item;
|
||||
if ( page->m_text.IsEmpty() )
|
||||
page->m_text = "";
|
||||
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 );
|
||||
|
||||
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)
|
||||
{
|
||||
wxFatalError( "Notebook page creation error" );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
m_pages.Append( page );
|
||||
gtk_label_set(page->m_label, page->m_text);
|
||||
|
||||
return TRUE;
|
||||
};
|
||||
@ -325,9 +327,27 @@ wxWindow *wxNotebook::GetPageWindow( const int page ) const
|
||||
|
||||
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 );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -16,6 +16,8 @@
|
||||
#include "wx/panel.h"
|
||||
#include "wx/utils.h"
|
||||
#include "wx/imaglist.h"
|
||||
#include "wx/intl.h"
|
||||
#include "wx/log.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxNotebookPage
|
||||
@ -30,9 +32,10 @@ class wxNotebookPage: public wxObject
|
||||
int m_image;
|
||||
void *m_clientData;
|
||||
GtkNotebookPage *m_page;
|
||||
GtkLabel *m_label;
|
||||
wxWindow *m_clientPanel;
|
||||
|
||||
wxNotebookPage(void)
|
||||
wxNotebookPage()
|
||||
{
|
||||
m_id = -1;
|
||||
m_text = "";
|
||||
@ -56,7 +59,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxNotebook,wxControl)
|
||||
wxNotebook::wxNotebook(void)
|
||||
{
|
||||
m_imageList = NULL;
|
||||
m_frame = NULL;
|
||||
m_pages.DeleteContents( TRUE );
|
||||
};
|
||||
|
||||
@ -65,7 +67,6 @@ wxNotebook::wxNotebook( wxWindow *parent, const wxWindowID id,
|
||||
const long style, const wxString& name )
|
||||
{
|
||||
m_imageList = NULL;
|
||||
m_frame = NULL;
|
||||
m_pages.DeleteContents( TRUE );
|
||||
Create( parent, id, pos, size, style, name );
|
||||
};
|
||||
@ -144,7 +145,7 @@ int wxNotebook::GetPageImage( const int page ) const
|
||||
if (nb_page)
|
||||
return nb_page->m_image;
|
||||
else
|
||||
return NULL;
|
||||
return 0;
|
||||
};
|
||||
|
||||
void* wxNotebook::GetPageData( const int page ) const
|
||||
@ -282,35 +283,36 @@ bool wxNotebook::DeletePage( const int page )
|
||||
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.
|
||||
|
||||
// first, find the page
|
||||
wxNotebookPage *page = NULL;
|
||||
|
||||
wxNode *node = m_pages.First();
|
||||
while (node)
|
||||
{
|
||||
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!");
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// then set the attributes
|
||||
page->m_text = text;
|
||||
if (page->m_text.IsNull()) page->m_text = "";
|
||||
page->m_id = item;
|
||||
if ( page->m_text.IsEmpty() )
|
||||
page->m_text = "";
|
||||
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 );
|
||||
|
||||
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)
|
||||
{
|
||||
wxFatalError( "Notebook page creation error" );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
m_pages.Append( page );
|
||||
gtk_label_set(page->m_label, page->m_text);
|
||||
|
||||
return TRUE;
|
||||
};
|
||||
@ -325,9 +327,27 @@ wxWindow *wxNotebook::GetPageWindow( const int page ) const
|
||||
|
||||
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 );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user