Improvements for notebooks on various versions of GTK

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1039 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1998-11-25 07:42:11 +00:00
parent 3bef6c4cf3
commit ba4e365239
8 changed files with 114 additions and 106 deletions

View File

@@ -186,15 +186,6 @@ bool wxFrame::Show( bool show )
if (show && !m_sizeSet) if (show && !m_sizeSet)
{ {
// this yield call is required for a configure event
// to be sent by GTK to its windows. this will among
// others prompt all GtkScrolledWidgets to calculate
// if they need scrollbars which in turn is required
// for wxWindows to calculate the client size of its
// windows.
wxYield();
// by calling GtkOnSize here, we don't have to call // by calling GtkOnSize here, we don't have to call
// either after showing the frame, which would entail // either after showing the frame, which would entail
// much ugly flicker nor from within the size_allocate // much ugly flicker nor from within the size_allocate

View File

@@ -38,7 +38,8 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation*
if ((win->m_x == alloc->x) && if ((win->m_x == alloc->x) &&
(win->m_y == alloc->y) && (win->m_y == alloc->y) &&
(win->m_width == alloc->width) && (win->m_width == alloc->width) &&
(win->m_height == alloc->height)) (win->m_height == alloc->height) &&
(win->m_sizeSet))
{ {
return; return;
} }

View File

@@ -73,8 +73,6 @@ static void gtk_notebook_page_change_callback(GtkNotebook *WXUNUSED(widget),
static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win ) static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win )
{ {
if (win->GetAutoLayout()) win->Layout();
if ((win->m_x == alloc->x) && if ((win->m_x == alloc->x) &&
(win->m_y == alloc->y) && (win->m_y == alloc->y) &&
(win->m_width == alloc->width) && (win->m_width == alloc->width) &&
@@ -168,12 +166,10 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 ); gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 );
m_idHandler = gtk_signal_connect m_idHandler = gtk_signal_connect (
(
GTK_OBJECT(m_widget), "switch_page", GTK_OBJECT(m_widget), "switch_page",
GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback),
(gpointer)this (gpointer)this );
);
m_parent->AddChild( this ); m_parent->AddChild( this );
@@ -193,6 +189,7 @@ int wxNotebook::GetSelection() const
if (m_pages.Number() == 0) return -1; if (m_pages.Number() == 0) return -1;
GtkNotebookPage *g_page = GTK_NOTEBOOK(m_widget)->cur_page; GtkNotebookPage *g_page = GTK_NOTEBOOK(m_widget)->cur_page;
if (!g_page) return -1;
wxNotebookPage *page = (wxNotebookPage *) NULL; wxNotebookPage *page = (wxNotebookPage *) NULL;
@@ -200,8 +197,15 @@ int wxNotebook::GetSelection() const
while (node) while (node)
{ {
page = (wxNotebookPage*)node->Data(); page = (wxNotebookPage*)node->Data();
if (page->m_page == g_page)
if ((page->m_page == g_page) || (page->m_page == (GtkNotebookPage*)NULL))
{
// page->m_page is NULL directly after gtk_notebook_append. gtk emits
// "switch_page" then and we ask for GetSelection() in the handler for
// "switch_page". otherwise m_page should never be NULL. all this
// might also be wrong.
break; break;
}
node = node->Next(); node = node->Next();
} }

View File

@@ -1315,12 +1315,19 @@ void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags )
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
wxASSERT_MSG( (m_parent != NULL), "wxWindow::SetSize requires parent.\n" ); wxASSERT_MSG( (m_parent != NULL), "wxWindow::SetSize requires parent.\n" );
// Don't do anything for children of wxNotebook
if (m_parent->m_wxwindow == NULL) return;
if (m_resizing) return; // I don't like recursions if (m_resizing) return; // I don't like recursions
m_resizing = TRUE; m_resizing = TRUE;
if (m_parent->m_wxwindow == NULL) // i.e. wxNotebook
{
// don't set the size for children of wxNotebook, just take the values.
m_x = x;
m_y = y;
m_width = width;
m_height = height;
}
else
{
int old_width = m_width; int old_width = m_width;
int old_height = m_height; int old_height = m_height;
@@ -1359,12 +1366,13 @@ void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags )
if ((old_width != m_width) || (old_height != m_height)) if ((old_width != m_width) || (old_height != m_height))
gtk_widget_set_usize( m_widget, m_width, m_height ); gtk_widget_set_usize( m_widget, m_width, m_height );
}
m_sizeSet = TRUE; m_sizeSet = TRUE;
wxSizeEvent event( wxSize(m_width,m_height), GetId() ); wxSizeEvent event( wxSize(m_width,m_height), GetId() );
event.SetEventObject( this ); event.SetEventObject( this );
ProcessEvent( event ); GetEventHandler()->ProcessEvent( event );
m_resizing = FALSE; m_resizing = FALSE;
} }

View File

@@ -186,15 +186,6 @@ bool wxFrame::Show( bool show )
if (show && !m_sizeSet) if (show && !m_sizeSet)
{ {
// this yield call is required for a configure event
// to be sent by GTK to its windows. this will among
// others prompt all GtkScrolledWidgets to calculate
// if they need scrollbars which in turn is required
// for wxWindows to calculate the client size of its
// windows.
wxYield();
// by calling GtkOnSize here, we don't have to call // by calling GtkOnSize here, we don't have to call
// either after showing the frame, which would entail // either after showing the frame, which would entail
// much ugly flicker nor from within the size_allocate // much ugly flicker nor from within the size_allocate

View File

@@ -38,7 +38,8 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation*
if ((win->m_x == alloc->x) && if ((win->m_x == alloc->x) &&
(win->m_y == alloc->y) && (win->m_y == alloc->y) &&
(win->m_width == alloc->width) && (win->m_width == alloc->width) &&
(win->m_height == alloc->height)) (win->m_height == alloc->height) &&
(win->m_sizeSet))
{ {
return; return;
} }

View File

@@ -73,8 +73,6 @@ static void gtk_notebook_page_change_callback(GtkNotebook *WXUNUSED(widget),
static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win ) static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win )
{ {
if (win->GetAutoLayout()) win->Layout();
if ((win->m_x == alloc->x) && if ((win->m_x == alloc->x) &&
(win->m_y == alloc->y) && (win->m_y == alloc->y) &&
(win->m_width == alloc->width) && (win->m_width == alloc->width) &&
@@ -168,12 +166,10 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 ); gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 );
m_idHandler = gtk_signal_connect m_idHandler = gtk_signal_connect (
(
GTK_OBJECT(m_widget), "switch_page", GTK_OBJECT(m_widget), "switch_page",
GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback),
(gpointer)this (gpointer)this );
);
m_parent->AddChild( this ); m_parent->AddChild( this );
@@ -193,6 +189,7 @@ int wxNotebook::GetSelection() const
if (m_pages.Number() == 0) return -1; if (m_pages.Number() == 0) return -1;
GtkNotebookPage *g_page = GTK_NOTEBOOK(m_widget)->cur_page; GtkNotebookPage *g_page = GTK_NOTEBOOK(m_widget)->cur_page;
if (!g_page) return -1;
wxNotebookPage *page = (wxNotebookPage *) NULL; wxNotebookPage *page = (wxNotebookPage *) NULL;
@@ -200,8 +197,15 @@ int wxNotebook::GetSelection() const
while (node) while (node)
{ {
page = (wxNotebookPage*)node->Data(); page = (wxNotebookPage*)node->Data();
if (page->m_page == g_page)
if ((page->m_page == g_page) || (page->m_page == (GtkNotebookPage*)NULL))
{
// page->m_page is NULL directly after gtk_notebook_append. gtk emits
// "switch_page" then and we ask for GetSelection() in the handler for
// "switch_page". otherwise m_page should never be NULL. all this
// might also be wrong.
break; break;
}
node = node->Next(); node = node->Next();
} }

View File

@@ -1315,12 +1315,19 @@ void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags )
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
wxASSERT_MSG( (m_parent != NULL), "wxWindow::SetSize requires parent.\n" ); wxASSERT_MSG( (m_parent != NULL), "wxWindow::SetSize requires parent.\n" );
// Don't do anything for children of wxNotebook
if (m_parent->m_wxwindow == NULL) return;
if (m_resizing) return; // I don't like recursions if (m_resizing) return; // I don't like recursions
m_resizing = TRUE; m_resizing = TRUE;
if (m_parent->m_wxwindow == NULL) // i.e. wxNotebook
{
// don't set the size for children of wxNotebook, just take the values.
m_x = x;
m_y = y;
m_width = width;
m_height = height;
}
else
{
int old_width = m_width; int old_width = m_width;
int old_height = m_height; int old_height = m_height;
@@ -1359,12 +1366,13 @@ void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags )
if ((old_width != m_width) || (old_height != m_height)) if ((old_width != m_width) || (old_height != m_height))
gtk_widget_set_usize( m_widget, m_width, m_height ); gtk_widget_set_usize( m_widget, m_width, m_height );
}
m_sizeSet = TRUE; m_sizeSet = TRUE;
wxSizeEvent event( wxSize(m_width,m_height), GetId() ); wxSizeEvent event( wxSize(m_width,m_height), GetId() );
event.SetEventObject( this ); event.SetEventObject( this );
ProcessEvent( event ); GetEventHandler()->ProcessEvent( event );
m_resizing = FALSE; m_resizing = FALSE;
} }