Merge branch 'WX_3_0_BRANCH' into wxPy-3.0-branch

This commit is contained in:
Robin Dunn
2016-09-19 13:43:03 -07:00
21 changed files with 130 additions and 70 deletions

View File

@@ -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).

View File

@@ -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

View File

@@ -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
{

View File

@@ -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);

View File

@@ -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());
}
}

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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;

View File

@@ -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
}

View File

@@ -38,20 +38,6 @@
#include <X11/Xatom.h> // XA_CARDINAL
#include "wx/unix/utilsx11.h"
#endif
#ifdef GDK_WINDOWING_WAYLAND
#include <gdk/gdkwayland.h>
#define HAS_CLIENT_DECOR
#endif
#ifdef GDK_WINDOWING_MIR
extern "C" {
#include <gdk/gdkmir.h>
}
#define HAS_CLIENT_DECOR
#endif
#ifdef GDK_WINDOWING_BROADWAY
#include <gdk/gdkbroadway.h>
#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)))
{

View File

@@ -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)
{

View File

@@ -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

View File

@@ -29,10 +29,6 @@
#include "wx/osx/private.h"
#if wxOSX_USE_COCOA_OR_CARBON
#include <QuickTime/QuickTime.h>
#endif
// ----------------------------------------------------------------------------
// wxDataFormat
// ----------------------------------------------------------------------------

View File

@@ -35,10 +35,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
#include "wx/osx/private.h"
#endif
#ifndef __WXOSX_IPHONE__
#include <QuickTime/QuickTime.h>
#endif
CGColorSpaceRef wxMacGetGenericRGBColorSpace();
CGDataProviderRef wxMacCGDataProviderCreateWithMemoryBuffer( const wxMemoryBuffer& buf );

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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();

View File

@@ -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
// ----------------------------------------------------------------------------

View File

@@ -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);