From 545176521071a4edd242a2cd4163b363e818ec56 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Thu, 14 Oct 1999 13:09:01 +0000 Subject: [PATCH] Changed time of sending the wxSizeEvent and assorted things, this made wxGLCanvas work, wxMiniFrame looks correct again, Corrected makefile for HTML help git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3989 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/frame.h | 1 + include/wx/gtk/radiobox.h | 8 +-- include/wx/gtk1/frame.h | 1 + include/wx/gtk1/radiobox.h | 8 +-- samples/html/help/Makefile.in | 3 +- src/common/framecmn.cpp | 17 +++--- src/gtk/dialog.cpp | 1 + src/gtk/frame.cpp | 40 +++++++++---- src/gtk/minifram.cpp | 20 ++++--- src/gtk/radiobox.cpp | 10 +--- src/gtk/window.cpp | 67 ++++++++++++++++++++-- src/gtk1/dialog.cpp | 1 + src/gtk1/frame.cpp | 40 +++++++++---- src/gtk1/minifram.cpp | 20 ++++--- src/gtk1/radiobox.cpp | 10 +--- src/gtk1/window.cpp | 67 ++++++++++++++++++++-- utils/glcanvas/gtk/glcanvas.cpp | 17 +++++- utils/glcanvas/samples/penguin/penguin.cpp | 11 ---- 18 files changed, 252 insertions(+), 90 deletions(-) diff --git a/include/wx/gtk/frame.h b/include/wx/gtk/frame.h index 0268757d71..638c506b3d 100644 --- a/include/wx/gtk/frame.h +++ b/include/wx/gtk/frame.h @@ -102,6 +102,7 @@ public: void OnCloseWindow( wxCloseEvent& event ); void OnActivate( wxActivateEvent &WXUNUSED(event) ) { } // called from docview.cpp void OnSize( wxSizeEvent &event ); + void OnIdle( wxIdleEvent &event ); void OnMenuHighlight( wxMenuEvent& event ); diff --git a/include/wx/gtk/radiobox.h b/include/wx/gtk/radiobox.h index 0999008254..06402b021a 100644 --- a/include/wx/gtk/radiobox.h +++ b/include/wx/gtk/radiobox.h @@ -42,9 +42,6 @@ extern const char *wxRadioBoxNameStr; class wxRadioBox: public wxControl { - - DECLARE_DYNAMIC_CLASS(wxRadioBox) - public: wxRadioBox(); inline wxRadioBox( wxWindow *parent, wxWindowID id, const wxString& title, @@ -91,7 +88,6 @@ public: int GetNumberOfRowsOrCols() const; void SetNumberOfRowsOrCols( int n ); - void OnSize( wxSizeEvent &event ); void SetFocus(); // implementation @@ -101,12 +97,14 @@ public: bool IsOwnGtkWindow( GdkWindow *window ); void ApplyWidgetStyle(); wxSize LayoutItems(); + void DoSetSize( int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO ); bool m_alreadySent; int m_majorDim; wxList m_boxes; - DECLARE_EVENT_TABLE() +private: + DECLARE_DYNAMIC_CLASS(wxRadioBox) }; #endif diff --git a/include/wx/gtk1/frame.h b/include/wx/gtk1/frame.h index 0268757d71..638c506b3d 100644 --- a/include/wx/gtk1/frame.h +++ b/include/wx/gtk1/frame.h @@ -102,6 +102,7 @@ public: void OnCloseWindow( wxCloseEvent& event ); void OnActivate( wxActivateEvent &WXUNUSED(event) ) { } // called from docview.cpp void OnSize( wxSizeEvent &event ); + void OnIdle( wxIdleEvent &event ); void OnMenuHighlight( wxMenuEvent& event ); diff --git a/include/wx/gtk1/radiobox.h b/include/wx/gtk1/radiobox.h index 0999008254..06402b021a 100644 --- a/include/wx/gtk1/radiobox.h +++ b/include/wx/gtk1/radiobox.h @@ -42,9 +42,6 @@ extern const char *wxRadioBoxNameStr; class wxRadioBox: public wxControl { - - DECLARE_DYNAMIC_CLASS(wxRadioBox) - public: wxRadioBox(); inline wxRadioBox( wxWindow *parent, wxWindowID id, const wxString& title, @@ -91,7 +88,6 @@ public: int GetNumberOfRowsOrCols() const; void SetNumberOfRowsOrCols( int n ); - void OnSize( wxSizeEvent &event ); void SetFocus(); // implementation @@ -101,12 +97,14 @@ public: bool IsOwnGtkWindow( GdkWindow *window ); void ApplyWidgetStyle(); wxSize LayoutItems(); + void DoSetSize( int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO ); bool m_alreadySent; int m_majorDim; wxList m_boxes; - DECLARE_EVENT_TABLE() +private: + DECLARE_DYNAMIC_CLASS(wxRadioBox) }; #endif diff --git a/samples/html/help/Makefile.in b/samples/html/help/Makefile.in index d108cd68a8..3ceb53a80a 100644 --- a/samples/html/help/Makefile.in +++ b/samples/html/help/Makefile.in @@ -17,7 +17,8 @@ VPATH = :$(top_srcdir)/samples/html/help DATADIRS = helpfiles DATAFILES = helpfiles/Index.hhk helpfiles/book1.htm helpfiles/book2.htm \ - helpfiles/contents.hhc helpfiles/main.htm helpfiles/page2-b.htm helpfiles/testing.hhp + helpfiles/contents.hhc helpfiles/main.htm helpfiles/page2-b.htm helpfiles/testing.hhp \ + helpfiles/another.hhc helpfiles/another.hhp helpfiles/another.htm PROGRAM=help diff --git a/src/common/framecmn.cpp b/src/common/framecmn.cpp index 591382e187..24819cfa34 100644 --- a/src/common/framecmn.cpp +++ b/src/common/framecmn.cpp @@ -19,23 +19,22 @@ #include "wx/menu.h" #include "wx/menuitem.h" -#ifndef __WXGTK__ void wxFrame::OnIdle(wxIdleEvent& WXUNUSED(event) ) { - DoMenuUpdates(); + DoMenuUpdates(); } -#endif // update all menus void wxFrame::DoMenuUpdates() { - wxMenuBar* bar = GetMenuBar(); + wxMenuBar* bar = GetMenuBar(); - if ( bar != NULL ) { - int nCount = bar->GetMenuCount(); - for (int n = 0; n < nCount; n++) - DoMenuUpdates(bar->GetMenu(n), (wxWindow*) NULL); - } + if ( bar != NULL ) + { + int nCount = bar->GetMenuCount(); + for (int n = 0; n < nCount; n++) + DoMenuUpdates(bar->GetMenu(n), (wxWindow*) NULL); + } } // update a menu and all submenus recursively diff --git a/src/gtk/dialog.cpp b/src/gtk/dialog.cpp index 75852bf968..a528c57da7 100644 --- a/src/gtk/dialog.cpp +++ b/src/gtk/dialog.cpp @@ -246,6 +246,7 @@ void wxDialog::Init() m_returnCode = 0; m_sizeSet = FALSE; m_modalShowing = FALSE; + m_isFrame = TRUE; } wxDialog::wxDialog( wxWindow *parent, diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 780a098659..6ecd18ed73 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -71,10 +71,20 @@ static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* if (g_isIdle) wxapp_install_idle_handler(); - if (!win->m_hasVMT) return; + if (!win->m_hasVMT) + return; if ((win->m_width != alloc->width) || (win->m_height != alloc->height)) { +/* + wxPrintf( "OnSize from " ); + if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) + wxPrintf( win->GetClassInfo()->GetClassName() ); + wxPrintf( " %d %d %d %d\n", (int)alloc->x, + (int)alloc->y, + (int)alloc->width, + (int)alloc->height ); +*/ win->m_width = alloc->width; win->m_height = alloc->height; win->UpdateSize(); @@ -334,6 +344,7 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child ) BEGIN_EVENT_TABLE(wxFrame, wxWindow) EVT_SIZE(wxFrame::OnSize) + EVT_IDLE(wxFrame::OnIdle) EVT_CLOSE(wxFrame::OnCloseWindow) EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight) END_EVENT_TABLE() @@ -356,6 +367,7 @@ void wxFrame::Init() m_menuBarDetached = FALSE; m_toolBarDetached = FALSE; m_insertInClientArea = TRUE; + m_isFrame = TRUE; } wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title, @@ -429,6 +441,10 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, if (m_parent) m_parent->AddChild( this ); + /* the user resized the frame by dragging etc. */ + gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", + GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this ); + PostCreation(); /* we cannot set MWM hints and icons before the widget has @@ -436,10 +452,6 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, gtk_signal_connect( GTK_OBJECT(m_widget), "realize", GTK_SIGNAL_FUNC(gtk_frame_realized_callback), (gpointer) this ); - /* the user resized the frame by dragging etc. */ - gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", - GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this ); - /* the only way to get the window size is to connect to this event */ gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event", GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this ); @@ -775,20 +787,23 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height /* we actually set the size of a frame here and no-where else */ gtk_widget_set_usize( m_widget, m_width, m_height ); - m_sizeSet = TRUE; - /* send size event to frame */ + m_sizeSet = TRUE; + + // send size event to frame wxSizeEvent event( wxSize(m_width,m_height), GetId() ); event.SetEventObject( this ); GetEventHandler()->ProcessEvent( event ); - /* send size event to status bar */ +/* + // send size event to status bar if (m_frameStatusBar) { wxSizeEvent event2( wxSize(m_frameStatusBar->m_width,m_frameStatusBar->m_height), m_frameStatusBar->GetId() ); event2.SetEventObject( m_frameStatusBar ); m_frameStatusBar->GetEventHandler()->ProcessEvent( event2 ); } +*/ m_resizing = FALSE; } @@ -804,9 +819,14 @@ void wxFrame::MakeModal( bool modal ) void wxFrame::OnInternalIdle() { if (!m_sizeSet && GTK_WIDGET_REALIZED(m_wxwindow)) + { GtkOnSize( m_x, m_y, m_width, m_height ); - - DoMenuUpdates(); + + // we'll come back later + if (g_isIdle) + wxapp_install_idle_handler(); + return; + } if (m_frameMenuBar) m_frameMenuBar->OnInternalIdle(); #if wxUSE_TOOLBAR diff --git a/src/gtk/minifram.cpp b/src/gtk/minifram.cpp index 9da9393c89..a59e05cd8d 100644 --- a/src/gtk/minifram.cpp +++ b/src/gtk/minifram.cpp @@ -71,8 +71,10 @@ static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *g if (!win->m_hasVMT) return; if (gdk_event->count > 0) return; + GtkMyFixed *myfixed = GTK_MYFIXED(widget); + gtk_draw_shadow( widget->style, - widget->window, + myfixed->bin_window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, 0, 0, @@ -83,20 +85,20 @@ static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *g (win->GetWindowStyle() & wxTINY_CAPTION_HORIZ) || (win->GetWindowStyle() & wxTINY_CAPTION_VERT))) { - GdkGC *gc = gdk_gc_new( widget->window ); + GdkGC *gc = gdk_gc_new( myfixed->bin_window ); GdkFont *font = wxSMALL_FONT->GetInternalFont(1.0); int x = 2; if (win->GetWindowStyle() & wxSYSTEM_MENU) x = 18; gdk_gc_set_foreground( gc, &widget->style->bg[GTK_STATE_SELECTED] ); - gdk_draw_rectangle( widget->window, gc, TRUE, + gdk_draw_rectangle( myfixed->bin_window, gc, TRUE, x, 3, win->m_width - 4 - x, font->ascent + font->descent+1 ); gdk_gc_set_foreground( gc, &widget->style->white ); - gdk_draw_string( widget->window, font, gc, + gdk_draw_string( myfixed->bin_window, font, gc, x+2, 3+font->ascent, win->m_title.mb_str() ); @@ -115,8 +117,10 @@ static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNU if (!win->m_hasVMT) return; + GtkMyFixed *myfixed = GTK_MYFIXED(widget); + gtk_draw_shadow( widget->style, - widget->window, + myfixed->bin_window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, 0, 0, @@ -127,20 +131,20 @@ static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNU (win->GetWindowStyle() & wxTINY_CAPTION_HORIZ) || (win->GetWindowStyle() & wxTINY_CAPTION_VERT))) { - GdkGC *gc = gdk_gc_new( widget->window ); + GdkGC *gc = gdk_gc_new( myfixed->bin_window ); GdkFont *font = wxSMALL_FONT->GetInternalFont(1.0); int x = 2; if (win->GetWindowStyle() & wxSYSTEM_MENU) x = 17; gdk_gc_set_foreground( gc, &widget->style->bg[GTK_STATE_SELECTED] ); - gdk_draw_rectangle( widget->window, gc, TRUE, + gdk_draw_rectangle( myfixed->bin_window, gc, TRUE, x, 3, win->m_width - 4 - x, font->ascent + font->descent+1 ); gdk_gc_set_foreground( gc, &widget->style->white ); - gdk_draw_string( widget->window, font, gc, + gdk_draw_string( myfixed->bin_window, font, gc, x+2, 3+font->ascent, win->m_title.mb_str() ); diff --git a/src/gtk/radiobox.cpp b/src/gtk/radiobox.cpp index 43b4ae7803..d96aff1a1d 100644 --- a/src/gtk/radiobox.cpp +++ b/src/gtk/radiobox.cpp @@ -67,10 +67,6 @@ static void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRad IMPLEMENT_DYNAMIC_CLASS(wxRadioBox,wxControl) -BEGIN_EVENT_TABLE(wxRadioBox, wxControl) - EVT_SIZE(wxRadioBox::OnSize) -END_EVENT_TABLE() - wxRadioBox::wxRadioBox() { } @@ -161,11 +157,11 @@ wxRadioBox::~wxRadioBox() } } -void wxRadioBox::OnSize( wxSizeEvent &event ) +void wxRadioBox::DoSetSize( int x, int y, int width, int height, int sizeFlags ) { + wxWindow::DoSetSize( x, y, width, height, sizeFlags ); + LayoutItems(); - - event.Skip(); } wxSize wxRadioBox::LayoutItems() diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 5c6a1422e1..1e1dcdc207 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -313,6 +313,39 @@ static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNU #endif // GTK_MINOR_VERSION > 0 + +//----------------------------------------------------------------------------- +// "size_allocate" +//----------------------------------------------------------------------------- + +static void gtk_window_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win ) +{ + if (g_isIdle) + wxapp_install_idle_handler(); + + if (!win->m_hasVMT) + return; + + if (win->m_sizeSet) + return; + + win->m_sizeSet = TRUE; + +/* + wxPrintf( "OnSize from " ); + if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) + wxPrintf( win->GetClassInfo()->GetClassName() ); + wxPrintf( " %d %d %d %d\n", (int)alloc->x, + (int)alloc->y, + (int)alloc->width, + (int)alloc->height ); +*/ + + wxSizeEvent event( win->GetSize(), win->GetId() ); + event.SetEventObject( win ); + win->GetEventHandler()->ProcessEvent( event ); +} + //----------------------------------------------------------------------------- // key event conversion routines //----------------------------------------------------------------------------- @@ -694,6 +727,10 @@ static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExp (int)gdk_event->area.height ); */ + wxEraseEvent eevent( win->GetId() ); + eevent.SetEventObject( win ); + win->GetEventHandler()->ProcessEvent(eevent); + wxPaintEvent event( win->GetId() ); event.SetEventObject( win ); win->GetEventHandler()->ProcessEvent( event ); @@ -726,6 +763,10 @@ static void gtk_window_draw_callback( GtkWidget *widget, GdkRectangle *rect, wxW (int)rect->height ); */ + wxEraseEvent eevent( win->GetId() ); + eevent.SetEventObject( win ); + win->GetEventHandler()->ProcessEvent(eevent); + wxPaintEvent event( win->GetId() ); event.SetEventObject( win ); win->GetEventHandler()->ProcessEvent( event ); @@ -1784,6 +1825,7 @@ void wxWindow::Init() m_isStaticBox = FALSE; m_isRadioButton = FALSE; + m_isFrame = FALSE; m_acceptsFocus = FALSE; m_cursor = *wxSTANDARD_CURSOR; @@ -2027,6 +2069,13 @@ void wxWindow::PostCreation() { wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") ); + if (!m_isFrame) + { + /* frames have their own callback */ + gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", + GTK_SIGNAL_FUNC(gtk_window_size_callback), (gpointer)this ); + } + if (m_wxwindow) { if (!m_noExpose) @@ -2115,9 +2164,14 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags ) m_y = y; m_width = width; m_height = height; + + m_sizeSet = FALSE; } else { + int old_width = m_width; + int old_height = m_height; + GtkMyFixed *myfixed = GTK_MYFIXED(m_parent->m_wxwindow); if ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0) @@ -2166,14 +2220,19 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags ) m_y-border, m_width+2*border, m_height+border+bottom_border ); - } - m_sizeSet = TRUE; + if ((old_width != m_width) || + (old_height != m_height)) + { + m_sizeSet = FALSE; + } + } +/* wxSizeEvent event( wxSize(m_width,m_height), GetId() ); event.SetEventObject( this ); GetEventHandler()->ProcessEvent( event ); - +*/ m_resizing = FALSE; } @@ -2929,7 +2988,7 @@ bool wxWindow::DoPopupMenu( wxMenu *menu, int x, int y ) (GtkMenuPositionFunc) pop_pos_callback, (gpointer) this, // client data 0, // button used to activate it - 0 //gs_timeLastClick // the time of activation + gs_timeLastClick // the time of activation ); while (is_waiting) diff --git a/src/gtk1/dialog.cpp b/src/gtk1/dialog.cpp index 75852bf968..a528c57da7 100644 --- a/src/gtk1/dialog.cpp +++ b/src/gtk1/dialog.cpp @@ -246,6 +246,7 @@ void wxDialog::Init() m_returnCode = 0; m_sizeSet = FALSE; m_modalShowing = FALSE; + m_isFrame = TRUE; } wxDialog::wxDialog( wxWindow *parent, diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index 780a098659..6ecd18ed73 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -71,10 +71,20 @@ static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* if (g_isIdle) wxapp_install_idle_handler(); - if (!win->m_hasVMT) return; + if (!win->m_hasVMT) + return; if ((win->m_width != alloc->width) || (win->m_height != alloc->height)) { +/* + wxPrintf( "OnSize from " ); + if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) + wxPrintf( win->GetClassInfo()->GetClassName() ); + wxPrintf( " %d %d %d %d\n", (int)alloc->x, + (int)alloc->y, + (int)alloc->width, + (int)alloc->height ); +*/ win->m_width = alloc->width; win->m_height = alloc->height; win->UpdateSize(); @@ -334,6 +344,7 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child ) BEGIN_EVENT_TABLE(wxFrame, wxWindow) EVT_SIZE(wxFrame::OnSize) + EVT_IDLE(wxFrame::OnIdle) EVT_CLOSE(wxFrame::OnCloseWindow) EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight) END_EVENT_TABLE() @@ -356,6 +367,7 @@ void wxFrame::Init() m_menuBarDetached = FALSE; m_toolBarDetached = FALSE; m_insertInClientArea = TRUE; + m_isFrame = TRUE; } wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title, @@ -429,6 +441,10 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, if (m_parent) m_parent->AddChild( this ); + /* the user resized the frame by dragging etc. */ + gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", + GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this ); + PostCreation(); /* we cannot set MWM hints and icons before the widget has @@ -436,10 +452,6 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, gtk_signal_connect( GTK_OBJECT(m_widget), "realize", GTK_SIGNAL_FUNC(gtk_frame_realized_callback), (gpointer) this ); - /* the user resized the frame by dragging etc. */ - gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", - GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this ); - /* the only way to get the window size is to connect to this event */ gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event", GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this ); @@ -775,20 +787,23 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height /* we actually set the size of a frame here and no-where else */ gtk_widget_set_usize( m_widget, m_width, m_height ); - m_sizeSet = TRUE; - /* send size event to frame */ + m_sizeSet = TRUE; + + // send size event to frame wxSizeEvent event( wxSize(m_width,m_height), GetId() ); event.SetEventObject( this ); GetEventHandler()->ProcessEvent( event ); - /* send size event to status bar */ +/* + // send size event to status bar if (m_frameStatusBar) { wxSizeEvent event2( wxSize(m_frameStatusBar->m_width,m_frameStatusBar->m_height), m_frameStatusBar->GetId() ); event2.SetEventObject( m_frameStatusBar ); m_frameStatusBar->GetEventHandler()->ProcessEvent( event2 ); } +*/ m_resizing = FALSE; } @@ -804,9 +819,14 @@ void wxFrame::MakeModal( bool modal ) void wxFrame::OnInternalIdle() { if (!m_sizeSet && GTK_WIDGET_REALIZED(m_wxwindow)) + { GtkOnSize( m_x, m_y, m_width, m_height ); - - DoMenuUpdates(); + + // we'll come back later + if (g_isIdle) + wxapp_install_idle_handler(); + return; + } if (m_frameMenuBar) m_frameMenuBar->OnInternalIdle(); #if wxUSE_TOOLBAR diff --git a/src/gtk1/minifram.cpp b/src/gtk1/minifram.cpp index 9da9393c89..a59e05cd8d 100644 --- a/src/gtk1/minifram.cpp +++ b/src/gtk1/minifram.cpp @@ -71,8 +71,10 @@ static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *g if (!win->m_hasVMT) return; if (gdk_event->count > 0) return; + GtkMyFixed *myfixed = GTK_MYFIXED(widget); + gtk_draw_shadow( widget->style, - widget->window, + myfixed->bin_window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, 0, 0, @@ -83,20 +85,20 @@ static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *g (win->GetWindowStyle() & wxTINY_CAPTION_HORIZ) || (win->GetWindowStyle() & wxTINY_CAPTION_VERT))) { - GdkGC *gc = gdk_gc_new( widget->window ); + GdkGC *gc = gdk_gc_new( myfixed->bin_window ); GdkFont *font = wxSMALL_FONT->GetInternalFont(1.0); int x = 2; if (win->GetWindowStyle() & wxSYSTEM_MENU) x = 18; gdk_gc_set_foreground( gc, &widget->style->bg[GTK_STATE_SELECTED] ); - gdk_draw_rectangle( widget->window, gc, TRUE, + gdk_draw_rectangle( myfixed->bin_window, gc, TRUE, x, 3, win->m_width - 4 - x, font->ascent + font->descent+1 ); gdk_gc_set_foreground( gc, &widget->style->white ); - gdk_draw_string( widget->window, font, gc, + gdk_draw_string( myfixed->bin_window, font, gc, x+2, 3+font->ascent, win->m_title.mb_str() ); @@ -115,8 +117,10 @@ static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNU if (!win->m_hasVMT) return; + GtkMyFixed *myfixed = GTK_MYFIXED(widget); + gtk_draw_shadow( widget->style, - widget->window, + myfixed->bin_window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, 0, 0, @@ -127,20 +131,20 @@ static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNU (win->GetWindowStyle() & wxTINY_CAPTION_HORIZ) || (win->GetWindowStyle() & wxTINY_CAPTION_VERT))) { - GdkGC *gc = gdk_gc_new( widget->window ); + GdkGC *gc = gdk_gc_new( myfixed->bin_window ); GdkFont *font = wxSMALL_FONT->GetInternalFont(1.0); int x = 2; if (win->GetWindowStyle() & wxSYSTEM_MENU) x = 17; gdk_gc_set_foreground( gc, &widget->style->bg[GTK_STATE_SELECTED] ); - gdk_draw_rectangle( widget->window, gc, TRUE, + gdk_draw_rectangle( myfixed->bin_window, gc, TRUE, x, 3, win->m_width - 4 - x, font->ascent + font->descent+1 ); gdk_gc_set_foreground( gc, &widget->style->white ); - gdk_draw_string( widget->window, font, gc, + gdk_draw_string( myfixed->bin_window, font, gc, x+2, 3+font->ascent, win->m_title.mb_str() ); diff --git a/src/gtk1/radiobox.cpp b/src/gtk1/radiobox.cpp index 43b4ae7803..d96aff1a1d 100644 --- a/src/gtk1/radiobox.cpp +++ b/src/gtk1/radiobox.cpp @@ -67,10 +67,6 @@ static void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRad IMPLEMENT_DYNAMIC_CLASS(wxRadioBox,wxControl) -BEGIN_EVENT_TABLE(wxRadioBox, wxControl) - EVT_SIZE(wxRadioBox::OnSize) -END_EVENT_TABLE() - wxRadioBox::wxRadioBox() { } @@ -161,11 +157,11 @@ wxRadioBox::~wxRadioBox() } } -void wxRadioBox::OnSize( wxSizeEvent &event ) +void wxRadioBox::DoSetSize( int x, int y, int width, int height, int sizeFlags ) { + wxWindow::DoSetSize( x, y, width, height, sizeFlags ); + LayoutItems(); - - event.Skip(); } wxSize wxRadioBox::LayoutItems() diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 5c6a1422e1..1e1dcdc207 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -313,6 +313,39 @@ static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNU #endif // GTK_MINOR_VERSION > 0 + +//----------------------------------------------------------------------------- +// "size_allocate" +//----------------------------------------------------------------------------- + +static void gtk_window_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win ) +{ + if (g_isIdle) + wxapp_install_idle_handler(); + + if (!win->m_hasVMT) + return; + + if (win->m_sizeSet) + return; + + win->m_sizeSet = TRUE; + +/* + wxPrintf( "OnSize from " ); + if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) + wxPrintf( win->GetClassInfo()->GetClassName() ); + wxPrintf( " %d %d %d %d\n", (int)alloc->x, + (int)alloc->y, + (int)alloc->width, + (int)alloc->height ); +*/ + + wxSizeEvent event( win->GetSize(), win->GetId() ); + event.SetEventObject( win ); + win->GetEventHandler()->ProcessEvent( event ); +} + //----------------------------------------------------------------------------- // key event conversion routines //----------------------------------------------------------------------------- @@ -694,6 +727,10 @@ static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExp (int)gdk_event->area.height ); */ + wxEraseEvent eevent( win->GetId() ); + eevent.SetEventObject( win ); + win->GetEventHandler()->ProcessEvent(eevent); + wxPaintEvent event( win->GetId() ); event.SetEventObject( win ); win->GetEventHandler()->ProcessEvent( event ); @@ -726,6 +763,10 @@ static void gtk_window_draw_callback( GtkWidget *widget, GdkRectangle *rect, wxW (int)rect->height ); */ + wxEraseEvent eevent( win->GetId() ); + eevent.SetEventObject( win ); + win->GetEventHandler()->ProcessEvent(eevent); + wxPaintEvent event( win->GetId() ); event.SetEventObject( win ); win->GetEventHandler()->ProcessEvent( event ); @@ -1784,6 +1825,7 @@ void wxWindow::Init() m_isStaticBox = FALSE; m_isRadioButton = FALSE; + m_isFrame = FALSE; m_acceptsFocus = FALSE; m_cursor = *wxSTANDARD_CURSOR; @@ -2027,6 +2069,13 @@ void wxWindow::PostCreation() { wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") ); + if (!m_isFrame) + { + /* frames have their own callback */ + gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", + GTK_SIGNAL_FUNC(gtk_window_size_callback), (gpointer)this ); + } + if (m_wxwindow) { if (!m_noExpose) @@ -2115,9 +2164,14 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags ) m_y = y; m_width = width; m_height = height; + + m_sizeSet = FALSE; } else { + int old_width = m_width; + int old_height = m_height; + GtkMyFixed *myfixed = GTK_MYFIXED(m_parent->m_wxwindow); if ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0) @@ -2166,14 +2220,19 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags ) m_y-border, m_width+2*border, m_height+border+bottom_border ); - } - m_sizeSet = TRUE; + if ((old_width != m_width) || + (old_height != m_height)) + { + m_sizeSet = FALSE; + } + } +/* wxSizeEvent event( wxSize(m_width,m_height), GetId() ); event.SetEventObject( this ); GetEventHandler()->ProcessEvent( event ); - +*/ m_resizing = FALSE; } @@ -2929,7 +2988,7 @@ bool wxWindow::DoPopupMenu( wxMenu *menu, int x, int y ) (GtkMenuPositionFunc) pop_pos_callback, (gpointer) this, // client data 0, // button used to activate it - 0 //gs_timeLastClick // the time of activation + gs_timeLastClick // the time of activation ); while (is_waiting) diff --git a/utils/glcanvas/gtk/glcanvas.cpp b/utils/glcanvas/gtk/glcanvas.cpp index 9ee7d28543..a59ceaed95 100644 --- a/utils/glcanvas/gtk/glcanvas.cpp +++ b/utils/glcanvas/gtk/glcanvas.cpp @@ -34,6 +34,13 @@ extern "C" { XVisualInfo *g_vi = (XVisualInfo*) NULL; +//----------------------------------------------------------------------------- +// idle system +//----------------------------------------------------------------------------- + +extern void wxapp_install_idle_handler(); +extern bool g_isIdle; + //--------------------------------------------------------------------------- // wxGLContext //--------------------------------------------------------------------------- @@ -152,6 +159,9 @@ gtk_glwindow_realized_callback( GtkWidget * WXUNUSED(widget), wxGLCanvas *win ) static void gtk_glwindow_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxGLCanvas *win ) { + if (g_isIdle) + wxapp_install_idle_handler(); + win->m_exposed = TRUE; win->GetUpdateRegion().Union( gdk_event->area.x, @@ -167,6 +177,9 @@ gtk_glwindow_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_e static void gtk_glwindow_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxGLCanvas *win ) { + if (g_isIdle) + wxapp_install_idle_handler(); + win->m_exposed = TRUE; win->GetUpdateRegion().Union( rect->x, rect->y, @@ -337,4 +350,6 @@ void wxGLCanvas::OnInternalIdle() m_exposed = FALSE; GetUpdateRegion().Clear(); } -} \ No newline at end of file + + wxWindow::OnInternalIdle(); +} diff --git a/utils/glcanvas/samples/penguin/penguin.cpp b/utils/glcanvas/samples/penguin/penguin.cpp index 0d49b80611..8eaed6a1d9 100644 --- a/utils/glcanvas/samples/penguin/penguin.cpp +++ b/utils/glcanvas/samples/penguin/penguin.cpp @@ -27,7 +27,6 @@ #include "penguin.h" #include -#include "wx/gtk/win_gtk.h" #define VIEW_ASPECT 1.3 @@ -106,14 +105,6 @@ void TestGLCanvas::OnPaint( wxPaintEvent& event ) if (!GetContext()) return; #endif - printf( "on refresh.\n" ); - int x,y; - GtkMyFixed *fixed = GTK_MYFIXED(m_wxwindow); - gdk_window_get_size( m_wxwindow->window, &x, &y ); - printf( "-> window %d %d.\n", x, y ); - gdk_window_get_size( fixed->bin_window, &x, &y ); - printf( "-> bin_window %d %d.\n", x, y ); - SetCurrent(); /* initialize OpenGL */ @@ -155,8 +146,6 @@ void TestGLCanvas::OnSize(wxSizeEvent& event) int width, height; GetClientSize(& width, & height); - printf( "onsize %d %d.\n", width, height ); - #ifndef __WXMOTIF__ if (GetContext()) #endif -- 2.45.2