diff --git a/docs/changes.txt b/docs/changes.txt index abbadf529d..918ff34326 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -613,11 +613,13 @@ All (GUI): - Accept wxALIGN_CENTRE_HORIZONTAL in wxStaticText XRC handler (David Hart). - Fix appearance after updating a wxGrid with hidden rows/columns (iwbnwif). - Make wxAuiNotebookXmlHandler actually work. +- Fix key handling in wxStyledTextCtrl in non-Unicode build (David Costanzo). wxGTK: - Fix infinite sizing loop with GTK3 when using wxScrolled with a non-default target window. +- Fix wxBitmap ctor from XBM for non-square bitmaps. - Fix crashes in wxGTK3 when running with non-X11 backend (Marco Trevisan). - Fix coordinates of wxSetCursorEvent propagated to parent windows. - Fix GTK+ warnings when refreshing wxListCtrl items (Scott Talbert). @@ -627,6 +629,7 @@ wxGTK: wxMSW: - Fix compilation with g++ 4.9 in non-C++11 mode. +- Fix rendering of owner drawn multi-column menus (Pete Bannister). - Fix regression in accessibility support (Leland Lucius). - Fix regression in wxDC drawing with bottom-to-top y axis (Artur Wieczorek). - Fix compilation with C++Builder XE compiler (Nichka). diff --git a/include/wx/fontutil.h b/include/wx/fontutil.h index 60bb874640..9e4d0235f9 100644 --- a/include/wx/fontutil.h +++ b/include/wx/fontutil.h @@ -227,6 +227,9 @@ public: // init with the parameters of the given font void InitFromFont(const wxFont& font) { +#if wxUSE_PANGO + Init(*font.GetNativeFontInfo()); +#else // translate all font parameters SetStyle((wxFontStyle)font.GetStyle()); SetWeight((wxFontWeight)font.GetWeight()); @@ -252,6 +255,7 @@ public: // deal with encoding now (it may override the font family and facename // so do it after setting them) SetEncoding(font.GetEncoding()); +#endif // !wxUSE_PANGO } // accessors and modifiers for the font elements diff --git a/interface/wx/htmllbox.h b/interface/wx/htmllbox.h index 2f3cdaee16..651f193b8c 100644 --- a/interface/wx/htmllbox.h +++ b/interface/wx/htmllbox.h @@ -200,6 +200,9 @@ protected: @see wxSimpleHtmlListBox::Create */ +#define wxHLB_DEFAULT_STYLE wxBORDER_SUNKEN +#define wxHLB_MULTIPLE wxLB_MULTIPLE + class wxSimpleHtmlListBox : public wxHtmlListBox, public wxItemContainer { diff --git a/interface/wx/utils.h b/interface/wx/utils.h index 0bac1c07a0..f127a74084 100644 --- a/interface/wx/utils.h +++ b/interface/wx/utils.h @@ -372,6 +372,9 @@ wxString wxGetDisplayName(); Even though there are virtual key codes defined for mouse buttons, they cannot be used with this function currently. + In wxGTK, this function can be only used with modifier keys (@c WXK_ALT, @c + WXK_CONTROL and @c WXK_SHIFT) when not using X11 backend currently. + @header{wx/utils.h} */ bool wxGetKeyState(wxKeyCode key); diff --git a/src/common/fileconf.cpp b/src/common/fileconf.cpp index e626c3c0cc..4e77aa983d 100644 --- a/src/common/fileconf.cpp +++ b/src/common/fileconf.cpp @@ -571,7 +571,7 @@ void wxFileConfig::Parse(const wxTextBuffer& buffer, bool bLocal) } if ( *pEnd != wxT(']') ) { - wxLogError(_("file '%s': unexpected character %c at line %d."), + wxLogError(_("file '%s': unexpected character %c at line %zu."), buffer.GetName(), *pEnd, n + 1); continue; // skip this line } @@ -607,7 +607,7 @@ void wxFileConfig::Parse(const wxTextBuffer& buffer, bool bLocal) break; default: - wxLogWarning(_("file '%s', line %d: '%s' ignored after group header."), + wxLogWarning(_("file '%s', line %zu: '%s' ignored after group header."), buffer.GetName(), n + 1, pEnd); bCont = false; } @@ -636,7 +636,7 @@ void wxFileConfig::Parse(const wxTextBuffer& buffer, bool bLocal) pEnd++; if ( *pEnd++ != wxT('=') ) { - wxLogError(_("file '%s', line %d: '=' expected."), + wxLogError(_("file '%s', line %zu: '=' expected."), buffer.GetName(), n + 1); } else { @@ -649,7 +649,7 @@ void wxFileConfig::Parse(const wxTextBuffer& buffer, bool bLocal) else { if ( bLocal && pEntry->IsImmutable() ) { // immutable keys can't be changed by user - wxLogWarning(_("file '%s', line %d: value for immutable key '%s' ignored."), + wxLogWarning(_("file '%s', line %zu: value for immutable key '%s' ignored."), buffer.GetName(), n + 1, strKey.c_str()); continue; } @@ -659,8 +659,8 @@ void wxFileConfig::Parse(const wxTextBuffer& buffer, bool bLocal) // (c) key from global file now found in local one // which is exactly what we want. else if ( !bLocal || pEntry->IsLocal() ) { - wxLogWarning(_("file '%s', line %d: key '%s' was first found at line %d."), - buffer.GetName(), (int)n + 1, strKey.c_str(), pEntry->Line()); + wxLogWarning(_("file '%s', line %zu: key '%s' was first found at line %d."), + buffer.GetName(), n + 1, strKey.c_str(), pEntry->Line()); } } diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index f563a1a5ea..f6e368ee32 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -1092,7 +1092,11 @@ wxCopyFile (const wxString& file1, const wxString& file2, bool overwrite) return false; } - wxDoCopyFile(fileIn, fbuf, file2, overwrite); + if ( !wxDoCopyFile(fileIn, fbuf, file2, overwrite) ) + { + wxLogError(_("Error copying the file '%s' to '%s'."), file1, file2); + return false; + } #if defined(__WXMAC__) || defined(__WXCOCOA__) // copy the resource fork of the file too if it's present diff --git a/src/common/fontenumcmn.cpp b/src/common/fontenumcmn.cpp index 1185a864ab..f0d6f68d7e 100644 --- a/src/common/fontenumcmn.cpp +++ b/src/common/fontenumcmn.cpp @@ -124,7 +124,8 @@ bool wxFontEnumerator::EnumerateEncodingsUTF8(const wxString& facename) for ( size_t n = 0; n < count; n++ ) { - OnFontEncoding(facenames[n], utf8); + if ( !OnFontEncoding(facenames[n], utf8) ) + break; } return true; diff --git a/src/gtk/bitmap.cpp b/src/gtk/bitmap.cpp index f81e7104a8..d3abc4c89b 100644 --- a/src/gtk/bitmap.cpp +++ b/src/gtk/bitmap.cpp @@ -428,17 +428,18 @@ wxBitmap::wxBitmap(const char bits[], int width, int height, int depth) const char* src = bits; guchar* dst = gdk_pixbuf_get_pixels(pixbuf); const int stride_src = (width + 7) / 8; - const int rowinc_dst = gdk_pixbuf_get_rowstride(pixbuf) - 3 * width; - for (int j = 0; j < width; j++, src += stride_src, dst += rowinc_dst) + const int stride_dst = gdk_pixbuf_get_rowstride(pixbuf); + for (int j = 0; j < height; j++, src += stride_src, dst += stride_dst) { - for (int i = 0; i < height; i++) + guchar* d = dst; + for (int i = 0; i < width; i++) { guchar c = 0xff; if (src[i >> 3] & (1 << (i & 7))) c = 0; - *dst++ = c; - *dst++ = c; - *dst++ = c; + *d++ = c; + *d++ = c; + *d++ = c; } } #else diff --git a/src/gtk/control.cpp b/src/gtk/control.cpp index f11b6e80ed..c418af212c 100644 --- a/src/gtk/control.cpp +++ b/src/gtk/control.cpp @@ -250,6 +250,7 @@ wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* widget, stateFlag = GTK_STATE_FLAG_ACTIVE; } GtkStyleContext* sc = gtk_widget_get_style_context(widget); + gtk_style_context_save(sc); GdkRGBA c; gtk_style_context_set_state(sc, stateFlag); gtk_style_context_get_color(sc, stateFlag, &c); @@ -260,6 +261,7 @@ wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* widget, gtk_style_context_get( sc, stateFlag, GTK_STYLE_PROPERTY_FONT, &info.description, NULL); attr.font = wxFont(info); + gtk_style_context_restore(sc); #else GtkStyle* style; diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 50b536c44a..bf8a8940eb 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -280,8 +280,6 @@ void wxFrame::DetachMenuBar() #if wxUSE_LIBHILDON || wxUSE_LIBHILDON2 hildon_window_set_menu(HILDON_WINDOW(m_widget), NULL); #else // !wxUSE_LIBHILDON && !wxUSE_LIBHILDON2 - g_object_ref( m_frameMenuBar->m_widget ); - gtk_container_remove( GTK_CONTAINER(m_mainWidget), m_frameMenuBar->m_widget ); #endif // wxUSE_LIBHILDON || wxUSE_LIBHILDON2 /!wxUSE_LIBHILDON && !wxUSE_LIBHILDON2 } diff --git a/src/gtk/toplevel.cpp b/src/gtk/toplevel.cpp index acd3692d7e..d213cc8dc1 100644 --- a/src/gtk/toplevel.cpp +++ b/src/gtk/toplevel.cpp @@ -38,20 +38,6 @@ #include // XA_CARDINAL #include "wx/unix/utilsx11.h" #endif -#ifdef GDK_WINDOWING_WAYLAND - #include - #define HAS_CLIENT_DECOR -#endif -#ifdef GDK_WINDOWING_MIR - extern "C" { - #include - } - #define HAS_CLIENT_DECOR -#endif -#ifdef GDK_WINDOWING_BROADWAY - #include - #define HAS_CLIENT_DECOR -#endif #include "wx/gtk/private.h" #include "wx/gtk/private/gtk2-compat.h" @@ -93,25 +79,29 @@ static enum { static bool gs_decorCacheValid; #endif -#ifdef HAS_CLIENT_DECOR +#ifdef __WXGTK3__ static bool HasClientDecor(GtkWidget* widget) { - GdkDisplay* display = gtk_widget_get_display(widget); -#ifdef GDK_WINDOWING_WAYLAND - if (GDK_IS_WAYLAND_DISPLAY(display)) - return true; -#endif -#ifdef GDK_WINDOWING_MIR - if (GDK_IS_MIR_DISPLAY(display)) - return true; -#endif -#ifdef GDK_WINDOWING_BROADWAY - if (GDK_IS_BROADWAY_DISPLAY(display)) - return true; -#endif + static bool has; + static bool once; + if (!once) + { + once = true; + GdkDisplay* display = gtk_widget_get_display(widget); + const char* name = g_type_name(G_TYPE_FROM_INSTANCE(display)); + has = + strcmp(name, "GdkWaylandDisplay") == 0 || + strcmp(name, "GdkMirDisplay") == 0 || + strcmp(name, "GdkBroadwayDisplay") == 0; + } + return has; +} +#else +static inline bool HasClientDecor(GtkWidget*) +{ return false; } -#endif // HAS_CLIENT_DECOR +#endif //----------------------------------------------------------------------------- // RequestUserAttention related functions @@ -266,7 +256,6 @@ size_allocate(GtkWidget*, GtkAllocation* alloc, wxTopLevelWindowGTK* win) GtkAllocation a; gtk_widget_get_allocation(win->m_widget, &a); wxSize size(a.width, a.height); -#ifdef HAS_CLIENT_DECOR if (HasClientDecor(win->m_widget)) { GtkAllocation a2; @@ -279,7 +268,6 @@ size_allocate(GtkWidget*, GtkAllocation* alloc, wxTopLevelWindowGTK* win) win->GTKUpdateDecorSize(decorSize); } else -#endif { size.x += win->m_decorSize.left + win->m_decorSize.right; size.y += win->m_decorSize.top + win->m_decorSize.bottom; @@ -760,9 +748,9 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent, if ( style & wxCAPTION ) m_gdkDecor |= GDK_DECOR_TITLE; -#if defined(GDK_WINDOWING_WAYLAND) && GTK_CHECK_VERSION(3,10,0) +#if GTK_CHECK_VERSION(3,10,0) else if ( - GDK_IS_WAYLAND_DISPLAY(gtk_widget_get_display(m_widget)) && + strcmp("GdkWaylandDisplay", g_type_name(G_TYPE_FROM_INSTANCE(gtk_widget_get_display(m_widget)))) == 0 && gtk_check_version(3,10,0) == NULL) { gtk_window_set_titlebar(GTK_WINDOW(m_widget), gtk_header_bar_new()); @@ -1109,9 +1097,7 @@ void wxTopLevelWindowGTK::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXU void wxTopLevelWindowGTK::GTKDoGetSize(int *width, int *height) const { wxSize size(m_width, m_height); -#ifdef HAS_CLIENT_DECOR if (!HasClientDecor(m_widget)) -#endif { size.x -= m_decorSize.left + m_decorSize.right; size.y -= m_decorSize.top + m_decorSize.bottom; @@ -1280,14 +1266,12 @@ void wxTopLevelWindowGTK::DoSetSizeHints( int minW, int minH, hints.max_height = INT_MAX / 16; int decorSize_x; int decorSize_y; -#ifdef HAS_CLIENT_DECOR if (HasClientDecor(m_widget)) { decorSize_x = 0; decorSize_y = 0; } else -#endif { decorSize_x = m_decorSize.left + m_decorSize.right; decorSize_y = m_decorSize.top + m_decorSize.bottom; @@ -1323,13 +1307,11 @@ void wxTopLevelWindowGTK::GTKUpdateDecorSize(const DecorSize& decorSize) if (!IsMaximized() && !IsFullScreen()) GetCachedDecorSize() = decorSize; -#ifdef HAS_CLIENT_DECOR if (HasClientDecor(m_widget)) { m_decorSize = decorSize; return; } -#endif #ifdef GDK_WINDOWING_X11 if (m_updateDecorSize && memcmp(&m_decorSize, &decorSize, sizeof(DecorSize))) { diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 8920d55a22..d27f889f59 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -304,8 +304,10 @@ draw_border(GtkWidget* widget, GdkEventExpose* gdk_event, wxWindow* win) #ifdef __WXGTK3__ GtkStyleContext* sc = gtk_widget_get_style_context(win->m_wxwindow); GdkRGBA c; + gtk_style_context_save(sc); gtk_style_context_set_state(sc, GTK_STATE_FLAG_NORMAL); gtk_style_context_get_border_color(sc, GTK_STATE_FLAG_NORMAL, &c); + gtk_style_context_restore(sc); gdk_cairo_set_source_rgba(cr, &c); cairo_set_line_width(cr, 1); cairo_rectangle(cr, x + 0.5, y + 0.5, w - 1, h - 1); @@ -4444,9 +4446,11 @@ void wxWindowGTK::GTKApplyStyle(GtkWidget* widget, GtkRcStyle* WXUNUSED_IN_GTK3( cairo_pattern_t* pattern = NULL; if (m_backgroundColour.IsOk()) { + gtk_style_context_save(context); gtk_style_context_set_state(context, GTK_STATE_FLAG_NORMAL); gtk_style_context_get(context, GTK_STATE_FLAG_NORMAL, "background-image", &pattern, NULL); + gtk_style_context_restore(context); } if (pattern) { diff --git a/src/msw/menuitem.cpp b/src/msw/menuitem.cpp index f845e3b3d3..2d53e1576d 100644 --- a/src/msw/menuitem.cpp +++ b/src/msw/menuitem.cpp @@ -873,7 +873,8 @@ bool wxMenuItem::OnDrawItem(wxDC& dc, const wxRect& rc, data->SeparatorMargin.ApplyTo(rcSeparator); RECT rcGutter = rcSelection; - rcGutter.right = data->ItemMargin.cxLeftWidth + rcGutter.right = rcGutter.left + + data->ItemMargin.cxLeftWidth + data->CheckBgMargin.cxLeftWidth + data->CheckMargin.cxLeftWidth + imgWidth diff --git a/src/osx/carbon/dataobj.cpp b/src/osx/carbon/dataobj.cpp index c363f23213..1fd98fddf2 100644 --- a/src/osx/carbon/dataobj.cpp +++ b/src/osx/carbon/dataobj.cpp @@ -29,10 +29,6 @@ #include "wx/osx/private.h" -#if wxOSX_USE_COCOA_OR_CARBON - #include -#endif - // ---------------------------------------------------------------------------- // wxDataFormat // ---------------------------------------------------------------------------- diff --git a/src/osx/core/bitmap.cpp b/src/osx/core/bitmap.cpp index c1bf6b7113..228b1d1842 100644 --- a/src/osx/core/bitmap.cpp +++ b/src/osx/core/bitmap.cpp @@ -35,10 +35,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject) #include "wx/osx/private.h" #endif -#ifndef __WXOSX_IPHONE__ -#include -#endif - CGColorSpaceRef wxMacGetGenericRGBColorSpace(); CGDataProviderRef wxMacCGDataProviderCreateWithMemoryBuffer( const wxMemoryBuffer& buf ); diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index 38b9d52e30..e16eaad412 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -4749,7 +4749,7 @@ void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { } #else int key = evt.GetKeyCode(); - if (key <= WXK_START || key > WXK_COMMAND) { + if (key < WXK_START) { m_swx->DoAddChar(key); return; } diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index cd4ee94e94..50c2dab618 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -887,7 +887,7 @@ void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { } #else int key = evt.GetKeyCode(); - if (key <= WXK_START || key > WXK_COMMAND) { + if (key < WXK_START) { m_swx->DoAddChar(key); return; } diff --git a/src/unix/fontenum.cpp b/src/unix/fontenum.cpp index cc7ee1dad4..e3739ed497 100644 --- a/src/unix/fontenum.cpp +++ b/src/unix/fontenum.cpp @@ -89,7 +89,10 @@ bool wxFontEnumerator::EnumerateFacenames(wxFontEncoding encoding, #endif { const gchar *name = pango_font_family_get_name(families[i]); - OnFacename(wxString(name, wxConvUTF8)); + if ( !OnFacename(wxString(name, wxConvUTF8)) ) + { + break; + } } } g_free(families); diff --git a/src/unix/mimetype.cpp b/src/unix/mimetype.cpp index 265f86aae0..72c8d4850f 100644 --- a/src/unix/mimetype.cpp +++ b/src/unix/mimetype.cpp @@ -561,7 +561,7 @@ void wxMimeTypesManagerImpl::Initialize(int mailcapStyles, } wxArrayString dirs; - wxStringTokenizer tokenizer(xdgDataDirs, ":"); + wxStringTokenizer tokenizer(xdgDataDirs, ":", wxTOKEN_STRTOK); while ( tokenizer.HasMoreTokens() ) { wxString p = tokenizer.GetNextToken(); diff --git a/src/unix/utilsx11.cpp b/src/unix/utilsx11.cpp index 6b35551647..efc0837431 100644 --- a/src/unix/utilsx11.cpp +++ b/src/unix/utilsx11.cpp @@ -809,7 +809,7 @@ WXKeySym wxCharCodeWXToX(int id) // check current state of a key // ---------------------------------------------------------------------------- -bool wxGetKeyState(wxKeyCode key) +static bool wxGetKeyStateX11(wxKeyCode key) { wxASSERT_MSG(key != WXK_LBUTTON && key != WXK_RBUTTON && key != WXK_MBUTTON, wxT("can't use wxGetKeyState() for mouse buttons")); @@ -851,11 +851,69 @@ bool wxGetKeyState(wxKeyCode key) // with the least-significant bit in the byte representing key 8N. char key_vector[32]; XQueryKeymap(pDisplay, key_vector); - return key_vector[keyCode >> 3] & (1 << (keyCode & 7)); + return (key_vector[keyCode >> 3] & (1 << (keyCode & 7))) != 0; } #endif // !defined(__WXGTK__) || defined(GDK_WINDOWING_X11) +// We need to use GDK functions when using wxGTK with a non-X11 backend, the +// X11 code above can't work in this case. +#ifdef __WXGTK__ + +// gdk_keymap_get_modifier_state() is only available since 3.4 +#if GTK_CHECK_VERSION(3,4,0) + +#define wxHAS_GETKEYSTATE_GTK + +extern GtkWidget *wxGetRootWindow(); + +static bool wxGetKeyStateGTK(wxKeyCode key) +{ + if (gtk_check_version(3,4,0) != NULL) + return false; + + GdkDisplay* display = gtk_widget_get_display(wxGetRootWindow()); + GdkKeymap* keymap = gdk_keymap_get_for_display(display); + guint state = gdk_keymap_get_modifier_state(keymap); + guint mask = 0; + switch (key) + { + case WXK_ALT: + mask = GDK_MOD1_MASK; + break; + + case WXK_CONTROL: + mask = GDK_CONTROL_MASK; + break; + + case WXK_SHIFT: + mask = GDK_SHIFT_MASK; + break; + + default: + wxFAIL_MSG(wxS("Unsupported key, only modifiers can be used")); + return false; + } + return (state & mask) != 0; +} + +#endif // GTK+ 3.4 +#endif // __WXGTK__ + +bool wxGetKeyState(wxKeyCode key) +{ +#ifdef wxHAS_GETKEYSTATE_GTK + GdkDisplay* display = gtk_widget_get_display(wxGetRootWindow()); + const char* name = g_type_name(G_TYPE_FROM_INSTANCE(display)); + if (strcmp(name, "GdkX11Display") != 0) + { + return wxGetKeyStateGTK(key); + } +#endif // GTK+ 3.4+ + + return wxGetKeyStateX11(key); +} + // ---------------------------------------------------------------------------- // Launch document with default app // ---------------------------------------------------------------------------- diff --git a/src/xrc/xh_auinotbk.cpp b/src/xrc/xh_auinotbk.cpp index df7498394f..0a2c178f53 100644 --- a/src/xrc/xh_auinotbk.cpp +++ b/src/xrc/xh_auinotbk.cpp @@ -35,6 +35,7 @@ wxAuiNotebookXmlHandler::wxAuiNotebookXmlHandler() XRC_ADD_STYLE(wxAUI_NB_CLOSE_BUTTON); XRC_ADD_STYLE(wxAUI_NB_CLOSE_ON_ACTIVE_TAB); XRC_ADD_STYLE(wxAUI_NB_CLOSE_ON_ALL_TABS); + XRC_ADD_STYLE(wxAUI_NB_MIDDLE_CLICK_CLOSE); XRC_ADD_STYLE(wxAUI_NB_TOP); XRC_ADD_STYLE(wxAUI_NB_BOTTOM);