Fixed a notebook crash and added more tests to sample.
Corrected size behaviour of default button. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2559 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -180,6 +180,7 @@ public:
|
|||||||
|
|
||||||
wxImageList* m_imageList;
|
wxImageList* m_imageList;
|
||||||
wxList m_pages;
|
wxList m_pages;
|
||||||
|
int m_lastSelection; /* hack */
|
||||||
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxNotebook)
|
DECLARE_DYNAMIC_CLASS(wxNotebook)
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
@@ -180,6 +180,7 @@ public:
|
|||||||
|
|
||||||
wxImageList* m_imageList;
|
wxImageList* m_imageList;
|
||||||
wxList m_pages;
|
wxList m_pages;
|
||||||
|
int m_lastSelection; /* hack */
|
||||||
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxNotebook)
|
DECLARE_DYNAMIC_CLASS(wxNotebook)
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
@@ -58,7 +58,7 @@ bool MyApp::OnInit(void)
|
|||||||
void MyApp::InitTabView(wxNotebook* notebook, wxWindow* window)
|
void MyApp::InitTabView(wxNotebook* notebook, wxWindow* window)
|
||||||
{
|
{
|
||||||
m_okButton = new wxButton(window, wxID_OK, "Close", wxPoint(-1, -1), wxSize(80, 25));
|
m_okButton = new wxButton(window, wxID_OK, "Close", wxPoint(-1, -1), wxSize(80, 25));
|
||||||
m_cancelButton = new wxButton(window, wxID_CANCEL, "Cancel", wxPoint(-1, -1), wxSize(80, 25));
|
m_cancelButton = new wxButton(window, ID_DELETE_PAGE, "Delete page", wxPoint(-1, -1), wxSize(80, 25));
|
||||||
m_addPageButton = new wxButton(window, ID_ADD_PAGE, "Add page", wxPoint(-1, -1), wxSize(80, 25));
|
m_addPageButton = new wxButton(window, ID_ADD_PAGE, "Add page", wxPoint(-1, -1), wxSize(80, 25));
|
||||||
m_okButton->SetDefault();
|
m_okButton->SetDefault();
|
||||||
|
|
||||||
@@ -108,6 +108,11 @@ void MyApp::InitTabView(wxNotebook* notebook, wxWindow* window)
|
|||||||
wxPanel *panel4 = new wxPanel(notebook, -1);
|
wxPanel *panel4 = new wxPanel(notebook, -1);
|
||||||
panel4->SetBackgroundColour(wxColour("YELLOW"));
|
panel4->SetBackgroundColour(wxColour("YELLOW"));
|
||||||
notebook->AddPage(panel4, "Sheep");
|
notebook->AddPage(panel4, "Sheep");
|
||||||
|
|
||||||
|
wxPanel *panel5 = new wxPanel(notebook, -1);
|
||||||
|
panel5->SetBackgroundColour(wxColour("MAGENTA"));
|
||||||
|
(void)new wxStaticText(panel5, -1, "This page has been inserted, not added", wxPoint(10, 10) );
|
||||||
|
notebook->InsertPage(0, panel5, "Sheep");
|
||||||
}
|
}
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(MyDialog, wxDialog)
|
BEGIN_EVENT_TABLE(MyDialog, wxDialog)
|
||||||
@@ -154,7 +159,7 @@ void MyDialog::Init(void)
|
|||||||
|
|
||||||
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||||
EVT_BUTTON(wxID_OK, MyFrame::OnOK)
|
EVT_BUTTON(wxID_OK, MyFrame::OnOK)
|
||||||
EVT_BUTTON(wxID_CANCEL, MyFrame::OnOK)
|
EVT_BUTTON(ID_DELETE_PAGE, MyFrame::OnDeletePage)
|
||||||
EVT_BUTTON(ID_ADD_PAGE, MyFrame::OnAddPage)
|
EVT_BUTTON(ID_ADD_PAGE, MyFrame::OnAddPage)
|
||||||
EVT_SIZE(MyFrame::OnSize)
|
EVT_SIZE(MyFrame::OnSize)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
@@ -176,6 +181,11 @@ void MyFrame::OnAddPage(wxCommandEvent& WXUNUSED(event))
|
|||||||
m_notebook->SetSelection( m_notebook->GetPageCount()-1 );
|
m_notebook->SetSelection( m_notebook->GetPageCount()-1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnDeletePage(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
m_notebook->DeletePage( m_notebook->GetPageCount()-1 );
|
||||||
|
}
|
||||||
|
|
||||||
void MyFrame::OnOK(wxCommandEvent& WXUNUSED(event) )
|
void MyFrame::OnOK(wxCommandEvent& WXUNUSED(event) )
|
||||||
{
|
{
|
||||||
this->Destroy();
|
this->Destroy();
|
||||||
|
@@ -50,6 +50,7 @@ public:
|
|||||||
void OnOK(wxCommandEvent& event);
|
void OnOK(wxCommandEvent& event);
|
||||||
void OnCloseWindow(wxCloseEvent& event);
|
void OnCloseWindow(wxCloseEvent& event);
|
||||||
void OnAddPage(wxCommandEvent& event);
|
void OnAddPage(wxCommandEvent& event);
|
||||||
|
void OnDeletePage(wxCommandEvent& event);
|
||||||
void OnSize(wxSizeEvent& event);
|
void OnSize(wxSizeEvent& event);
|
||||||
void Init(void);
|
void Init(void);
|
||||||
protected:
|
protected:
|
||||||
@@ -78,4 +79,5 @@ DECLARE_EVENT_TABLE()
|
|||||||
|
|
||||||
#define ID_NOTEBOOK 1000
|
#define ID_NOTEBOOK 1000
|
||||||
#define ID_ADD_PAGE 1200
|
#define ID_ADD_PAGE 1200
|
||||||
|
#define ID_DELETE_PAGE 1201
|
||||||
|
|
||||||
|
@@ -184,6 +184,7 @@ void wxNotebook::Init()
|
|||||||
{
|
{
|
||||||
m_imageList = (wxImageList *) NULL;
|
m_imageList = (wxImageList *) NULL;
|
||||||
m_pages.DeleteContents( TRUE );
|
m_pages.DeleteContents( TRUE );
|
||||||
|
m_lastSelection = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxNotebook::wxNotebook()
|
wxNotebook::wxNotebook()
|
||||||
@@ -251,11 +252,9 @@ int wxNotebook::GetSelection() const
|
|||||||
|
|
||||||
GtkNotebook *notebook = GTK_NOTEBOOK(m_widget);
|
GtkNotebook *notebook = GTK_NOTEBOOK(m_widget);
|
||||||
|
|
||||||
GtkNotebookPage *page = GTK_NOTEBOOK_PAGE( notebook->cur_page );
|
if (notebook->cur_page == NULL) return m_lastSelection;
|
||||||
|
|
||||||
wxCHECK_MSG( page, -1, "no notebook page selected/current" );
|
return g_list_index( pages, (gpointer)(notebook->cur_page) );
|
||||||
|
|
||||||
return g_list_index( pages, (gpointer)page );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxNotebook::GetPageCount() const
|
int wxNotebook::GetPageCount() const
|
||||||
@@ -462,9 +461,14 @@ bool wxNotebook::DeletePage( int page )
|
|||||||
wxNotebookPage* nb_page = GetNotebookPage(page);
|
wxNotebookPage* nb_page = GetNotebookPage(page);
|
||||||
if (!nb_page) return FALSE;
|
if (!nb_page) return FALSE;
|
||||||
|
|
||||||
|
/* GTK sets GtkNotebook.cur_page to NULL before sending
|
||||||
|
the switvh page event */
|
||||||
|
m_lastSelection = GetSelection();
|
||||||
|
|
||||||
nb_page->m_client->Destroy();
|
nb_page->m_client->Destroy();
|
||||||
|
|
||||||
m_pages.DeleteObject( nb_page );
|
m_pages.DeleteObject( nb_page );
|
||||||
|
|
||||||
|
m_lastSelection = -1;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@@ -1982,7 +1982,7 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
|
|||||||
|
|
||||||
int border = 0;
|
int border = 0;
|
||||||
|
|
||||||
if (GTK_WIDGET_HAS_DEFAULT(m_widget))
|
if (GTK_WIDGET_CAN_DEFAULT(m_widget))
|
||||||
{
|
{
|
||||||
/* the default button has a border around it */
|
/* the default button has a border around it */
|
||||||
border = 5;
|
border = 5;
|
||||||
|
@@ -184,6 +184,7 @@ void wxNotebook::Init()
|
|||||||
{
|
{
|
||||||
m_imageList = (wxImageList *) NULL;
|
m_imageList = (wxImageList *) NULL;
|
||||||
m_pages.DeleteContents( TRUE );
|
m_pages.DeleteContents( TRUE );
|
||||||
|
m_lastSelection = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxNotebook::wxNotebook()
|
wxNotebook::wxNotebook()
|
||||||
@@ -251,11 +252,9 @@ int wxNotebook::GetSelection() const
|
|||||||
|
|
||||||
GtkNotebook *notebook = GTK_NOTEBOOK(m_widget);
|
GtkNotebook *notebook = GTK_NOTEBOOK(m_widget);
|
||||||
|
|
||||||
GtkNotebookPage *page = GTK_NOTEBOOK_PAGE( notebook->cur_page );
|
if (notebook->cur_page == NULL) return m_lastSelection;
|
||||||
|
|
||||||
wxCHECK_MSG( page, -1, "no notebook page selected/current" );
|
return g_list_index( pages, (gpointer)(notebook->cur_page) );
|
||||||
|
|
||||||
return g_list_index( pages, (gpointer)page );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxNotebook::GetPageCount() const
|
int wxNotebook::GetPageCount() const
|
||||||
@@ -462,9 +461,14 @@ bool wxNotebook::DeletePage( int page )
|
|||||||
wxNotebookPage* nb_page = GetNotebookPage(page);
|
wxNotebookPage* nb_page = GetNotebookPage(page);
|
||||||
if (!nb_page) return FALSE;
|
if (!nb_page) return FALSE;
|
||||||
|
|
||||||
|
/* GTK sets GtkNotebook.cur_page to NULL before sending
|
||||||
|
the switvh page event */
|
||||||
|
m_lastSelection = GetSelection();
|
||||||
|
|
||||||
nb_page->m_client->Destroy();
|
nb_page->m_client->Destroy();
|
||||||
|
|
||||||
m_pages.DeleteObject( nb_page );
|
m_pages.DeleteObject( nb_page );
|
||||||
|
|
||||||
|
m_lastSelection = -1;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@@ -1982,7 +1982,7 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
|
|||||||
|
|
||||||
int border = 0;
|
int border = 0;
|
||||||
|
|
||||||
if (GTK_WIDGET_HAS_DEFAULT(m_widget))
|
if (GTK_WIDGET_CAN_DEFAULT(m_widget))
|
||||||
{
|
{
|
||||||
/* the default button has a border around it */
|
/* the default button has a border around it */
|
||||||
border = 5;
|
border = 5;
|
||||||
|
Reference in New Issue
Block a user