X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e8375af8ff97a3649361b988a40b991a8cdaab09..056b067f47664969b099e2e07ab9837245827b57:/src/gtk/window.cpp diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index bb6ec9e921..7b24565135 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -190,8 +190,10 @@ // data //----------------------------------------------------------------------------- -extern bool g_blockEventsOnDrag; -extern bool g_blockEventsOnScroll; +// Don't allow event propagation during drag +bool g_blockEventsOnDrag; +// Don't allow mouse event propagation during scroll +bool g_blockEventsOnScroll; extern wxCursor g_globalCursor; // mouse capture state: the window which has it and if the mouse is currently @@ -1129,9 +1131,13 @@ gtk_wxwindow_commit_cb (GtkIMContext *context, wxFillOtherKeyEventFields(event, window, window->m_imData->lastKeyEvent); } + else + { + event.SetEventObject( window ); + } - const wxWxCharBuffer data(wxGTK_CONV_BACK_SYS(str)); - if( !data ) + const wxString data(wxGTK_CONV_BACK_SYS(str)); + if( data.empty() ) return; bool ret = false; @@ -1141,7 +1147,7 @@ gtk_wxwindow_commit_cb (GtkIMContext *context, while (parent && !parent->IsTopLevel()) parent = parent->GetParent(); - for( const wxChar* pstr = data; *pstr; pstr++ ) + for( wxString::const_iterator pstr = data.begin(); pstr != data.end(); ++pstr ) { #if wxUSE_UNICODE event.m_uniChar = *pstr; @@ -1149,7 +1155,7 @@ gtk_wxwindow_commit_cb (GtkIMContext *context, event.m_keyCode = *pstr < 256 ? event.m_uniChar : 0; wxLogTrace(TRACE_KEYS, _T("IM sent character '%c'"), event.m_uniChar); #else - event.m_keyCode = *pstr; + event.m_keyCode = (char)*pstr; #endif // wxUSE_UNICODE // To conform to the docs we need to translate Ctrl-alpha @@ -1579,6 +1585,12 @@ gtk_window_button_press_callback( GtkWidget *widget, if ( ret ) return TRUE; + if ((event_type == wxEVT_LEFT_DOWN) && !win->IsOfStandardClass() && + (g_focusWindow != win) && win->CanAcceptFocus()) + { + gtk_widget_grab_focus( win->m_wxwindow ); + } + if (event_type == wxEVT_RIGHT_DOWN) { // generate a "context menu" event: this is similar to right mouse @@ -2076,9 +2088,6 @@ gtk_scrollbar_button_release_event(GtkRange* range, GdkEventButton*, wxWindow* w // "realize" from m_widget //----------------------------------------------------------------------------- -/* We cannot set colours and fonts before the widget has - been realized, so we do this directly after realization. */ - static void gtk_window_realized_callback( GtkWidget *m_widget, wxWindow *win ) { @@ -2091,6 +2100,16 @@ gtk_window_realized_callback( GtkWidget *m_widget, wxWindow *win ) pizza->bin_window ); } + // We cannot set colours and fonts before the widget + // been realized, so we do this directly after realization + // or otherwise in idle time + + if (win->m_needsStyleChange) + { + win->SetBackgroundStyle(win->GetBackgroundStyle()); + win->m_needsStyleChange = false; + } + wxWindowCreateEvent event( win ); event.SetEventObject( win ); win->GTKProcessEvent( event ); @@ -2227,7 +2246,6 @@ void wxWindowGTK::Init() m_width = 0; m_height = 0; - m_sizeSet = false; m_hasVMT = false; m_isBeingDeleted = false; @@ -2254,7 +2272,7 @@ void wxWindowGTK::Init() m_resizing = false; - m_insertCallback = (wxInsertChildFunction) NULL; + m_insertCallback = wxInsertChildInWindow; m_hasFocus = false; @@ -2299,9 +2317,6 @@ bool wxWindowGTK::Create( wxWindow *parent, return false; } - m_insertCallback = wxInsertChildInWindow; - - if (!HasFlag(wxHSCROLL) && !HasFlag(wxVSCROLL)) { m_wxwindow = gtk_pizza_new_no_scroll(); @@ -2625,6 +2640,23 @@ void wxWindowGTK::DoMoveWindow(int x, int y, int width, int height) } +void wxWindowGTK::ConstrainSize() +{ +#ifdef __WXGPE__ + // GPE's window manager doesn't like size hints at all, esp. when the user + // has to use the virtual keyboard, so don't constrain size there + if (!IsTopLevel()) +#endif + { + const wxSize minSize = GetMinSize(); + const wxSize maxSize = GetMaxSize(); + if (minSize.x > 0 && m_width < minSize.x) m_width = minSize.x; + if (minSize.y > 0 && m_height < minSize.y) m_height = minSize.y; + if (maxSize.x > 0 && m_width > maxSize.x) m_width = maxSize.x; + if (maxSize.y > 0 && m_height > maxSize.y) m_height = maxSize.y; + } +} + void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags ) { wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") ); @@ -2657,15 +2689,7 @@ void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags if (height != -1) m_height = height; - int minWidth = GetMinWidth(), - minHeight = GetMinHeight(), - maxWidth = GetMaxWidth(), - maxHeight = GetMaxHeight(); - - if ((minWidth != -1) && (m_width < minWidth )) m_width = minWidth; - if ((minHeight != -1) && (m_height < minHeight)) m_height = minHeight; - if ((maxWidth != -1) && (m_width > maxWidth )) m_width = maxWidth; - if ((maxHeight != -1) && (m_height > maxHeight)) m_height = maxHeight; + ConstrainSize(); #if wxUSE_TOOLBAR_NATIVE if (wxDynamicCast(GetParent(), wxToolBar)) @@ -2840,25 +2864,9 @@ void wxWindowGTK::DoSetClientSize( int width, int height ) { wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); - if (m_wxwindow) - { - int dw = 0; - int dh = 0; - - if (m_hasScrolling) - { - GetScrollbarWidth(m_widget, dw, dh); - } - - const int border = GTK_CONTAINER(m_wxwindow)->border_width; - dw += 2 * border; - dh += 2 * border; - - width += dw; - height += dh; - } - - SetSize(width, height); + const wxSize size = GetSize(); + const wxSize clientSize = GetClientSize(); + SetSize(width + (size.x - clientSize.x), height + (size.y - clientSize.y)); } void wxWindowGTK::DoGetClientSize( int *width, int *height ) const @@ -3294,11 +3302,8 @@ bool wxWindowGTK::Reparent( wxWindowBase *newParentBase ) void wxWindowGTK::DoAddChild(wxWindowGTK *child) { wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") ); - wxASSERT_MSG( (child != NULL), wxT("invalid child window") ); - wxASSERT_MSG( (m_insertCallback != NULL), wxT("invalid child insertion function") ); - /* add to list */ AddChild( child ); @@ -3807,17 +3812,9 @@ void wxWindowGTK::DoSetToolTip( wxToolTip *tip ) m_tooltip->Apply( (wxWindow *)this ); } -void wxWindowGTK::ApplyToolTip( GtkTooltips *tips, const wxChar *tip ) +void wxWindowGTK::ApplyToolTip( GtkTooltips *tips, const gchar *tip ) { - if (tip) - { - wxString tmp( tip ); - gtk_tooltips_set_tip( tips, GetConnectWidget(), wxGTK_CONV(tmp), (gchar*) NULL ); - } - else - { - gtk_tooltips_set_tip( tips, GetConnectWidget(), NULL, NULL); - } + gtk_tooltips_set_tip(tips, GetConnectWidget(), tip, NULL); } #endif // wxUSE_TOOLTIPS