X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6a008b33c4943a259f9d953598a82d12bcc04dbf..22d6efa851642c6a69174278fc50f712f41e2271:/src/gtk/window.cpp diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index a0eff69c74..dfeb16b66f 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -1799,6 +1799,7 @@ void wxWindow::Init() m_insertCallback = (wxInsertChildFunction) NULL; m_isStaticBox = FALSE; + m_isRadioButton = FALSE; m_acceptsFocus = FALSE; } @@ -1820,7 +1821,12 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id, 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; @@ -2001,27 +2007,22 @@ wxWindow::~wxWindow() } } -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, 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) { @@ -2034,6 +2035,8 @@ void wxWindow::PreCreation( wxWindow *parent, if (m_y < 10) m_y = 10; } } + + return TRUE; } void wxWindow::PostCreation() @@ -2213,6 +2216,8 @@ void wxWindow::OnInternalIdle() if (cursor.Ok() && m_currentGdkCursor != cursor) { + m_currentGdkCursor = cursor; + if (m_wxwindow) { GdkWindow *window = m_wxwindow->window; @@ -2232,8 +2237,6 @@ void wxWindow::OnInternalIdle() if (window) gdk_window_set_cursor( window, cursor.GetCursor() ); } - - m_currentGdkCursor = cursor; } UpdateWindowUI(); @@ -2260,17 +2263,20 @@ void wxWindow::DoSetClientSize( int width, int height ) int dw = 0; int dh = 0; - GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(m_widget); - GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass ); - #if (GTK_MINOR_VERSION == 0) - GtkWidget *viewport = scroll_window->viewport; - GtkStyleClass *viewport_class = viewport->style->klass; - if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER)) { - dw += 2 * viewport_class->xthickness; - dh += 2 * viewport_class->ythickness; + if (HasScrolling()) + { + GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(m_widget); + GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass ); + + GtkWidget *viewport = scroll_window->viewport; + GtkStyleClass *viewport_class = viewport->style->klass; + + dw += 2 * viewport_class->xthickness; + dh += 2 * viewport_class->ythickness; + } } #else if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER)) @@ -2290,6 +2296,9 @@ void wxWindow::DoSetClientSize( int width, int height ) we use this instead: range.slider_width = 11 + 2*2pts edge */ + GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(m_widget); + GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass ); + if (scroll_window->vscrollbar_visible) { dw += 15; /* dw += vscrollbar->allocation.width; */ @@ -2836,6 +2845,15 @@ void wxWindow::ApplyWidgetStyle() { } +//----------------------------------------------------------------------------- +// 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 ); @@ -2863,7 +2881,7 @@ static void pop_pos_callback( GtkMenu * WXUNUSED(menu), *y = gs_pop_y; } -bool wxWindow::PopupMenu( wxMenu *menu, int x, int y ) +bool wxWindow::DoPopupMenu( wxMenu *menu, int x, int y ) { wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") ); @@ -2876,6 +2894,11 @@ bool wxWindow::PopupMenu( wxMenu *menu, int x, int y ) 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 @@ -2885,6 +2908,13 @@ bool wxWindow::PopupMenu( wxMenu *menu, int x, int y ) 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; }