const wxPoint &pos, const wxSize &size,
long style, const wxString &name )
{
- PreCreation( parent, id, pos, size, style, name );
+ if (!PreCreation( parent, pos, size ) ||
+ !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
+ {
+ wxFAIL_MSG( _T("wxWindow creation failed") );
+ return FALSE;
+ }
m_insertCallback = wxInsertChildInWindow;
}
}
-void wxWindow::PreCreation( wxWindow *parent,
- wxWindowID id,
- const wxPoint &pos,
- const wxSize &size,
- long style,
- const wxString &name )
+bool wxWindow::PreCreation( wxWindow *parent, const wxPoint &pos, const wxSize &size )
{
- wxASSERT_MSG( !m_needParent || parent, _T("Need complete parent.") );
-
- if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) )
- {
- wxFAIL_MSG(_T("window creation failed"));
- }
+ wxCHECK_MSG( !m_needParent || parent, FALSE, _T("Need complete parent.") );
+ /* this turns -1 into 20 so that a minimal window is
+ visible even although -1,-1 has been given as the
+ size of the window. the same trick is used in other
+ ports and should make debugging easier */
m_width = WidthDefault(size.x);
m_height = HeightDefault(size.y);
m_x = (int)pos.x;
m_y = (int)pos.y;
- if (!parent) /* some reasonable defaults */
+ /* some reasonable defaults */
+ if (!parent)
{
if (m_x == -1)
{
if (m_y < 10) m_y = 10;
}
}
+
+ return TRUE;
}
void wxWindow::PostCreation()
{
}
+//-----------------------------------------------------------------------------
+// Pop-up menu stuff
+//-----------------------------------------------------------------------------
+
+static void gtk_pop_hide_callback( GtkWidget *WXUNUSED(widget), bool* is_waiting )
+{
+ *is_waiting = FALSE;
+}
+
static void SetInvokingWindow( wxMenu *menu, wxWindow *win )
{
menu->SetInvokingWindow( win );
gs_pop_x = x;
gs_pop_y = y;
+ bool is_waiting = TRUE;
+
+ gtk_signal_connect( GTK_OBJECT(menu->m_menu), "hide",
+ GTK_SIGNAL_FUNC(gtk_pop_hide_callback), (gpointer)&is_waiting );
+
gtk_menu_popup(
GTK_MENU(menu->m_menu),
(GtkWidget *) NULL, // parent menu shell
0, // button used to activate it
0 //gs_timeLastClick // the time of activation
);
+
+ while (is_waiting)
+ {
+ while (gtk_events_pending())
+ gtk_main_iteration();
+ }
+
return TRUE;
}