diff --git a/.mailmap b/.mailmap index 79a840e34a..122cdf3c75 100644 --- a/.mailmap +++ b/.mailmap @@ -1,34 +1,55 @@ +AliKet +Anil Kumar ARATA Mizuki +Artur Sochirca Artur Wieczorek Daniel Kulp Blake Eryx Bogdan Iordanescu Cătălin Răceanu -Danny Scott + +Danny Scott + Dimitri Schoolwerth +Hashir Ahmad Frédéric Bron Hubert Talbot +Igor Korot Ilya Bizyaev +Jens Göpfert John Roberts Jouk Jansen +Jose Lorenzo Julian Smart Jevgenijs Protopopovs Hartwig Wiesmann Kinaou Hervé +Kolya Kosenko +Lauri Nurmi Lynn C. Rees Maarten Bent Manuel Martin -Martin Ettl +Markus Juergens Martin Ettl +Martin Ettl +Martin Ettl +Mathew Maidment Micha Ahrweiler ousnius Paul Cornett Paul Kulchenko +Pavel O. +Pavel O. +Pavel Tyunin <36256989+pavel-t@users.noreply.github.com> PB +Prashant Kumar Nirmal +René Kijewski Richard Fath +Richard Powell +Roberto Boriotti Steve Browne Tim Kosse @@ -41,4 +62,6 @@ Václav Slavík Václav Slavík Vadim Zeitlin +Wolfgang Stöggl Xlord2 +Iwbnwif Yiw diff --git a/3rdparty/catch b/3rdparty/catch index 011f6e6458..b46f260f81 160000 --- a/3rdparty/catch +++ b/3rdparty/catch @@ -1 +1 @@ -Subproject commit 011f6e6458d888246f94643e293f002073cff489 +Subproject commit b46f260f810bb693825c026269636e82b0a50722 diff --git a/Makefile.in b/Makefile.in index 04eaa957f2..e44bc57695 100644 --- a/Makefile.in +++ b/Makefile.in @@ -206,8 +206,10 @@ WXTIFF_OBJECTS = \ wxtiff_tif_tile.o \ wxtiff_tif_version.o \ wxtiff_tif_warning.o \ + wxtiff_tif_webp.o \ wxtiff_tif_write.o \ - wxtiff_tif_zip.o + wxtiff_tif_zip.o \ + wxtiff_tif_zstd.o WXEXPAT_CFLAGS = -DNDEBUG -I./src/expat/expat -DHAVE_EXPAT_CONFIG_H \ $(____SHARED) $(CPPFLAGS) $(CFLAGS) WXEXPAT_OBJECTS = \ @@ -15026,12 +15028,18 @@ wxtiff_tif_version.o: $(srcdir)/src/tiff/libtiff/tif_version.c wxtiff_tif_warning.o: $(srcdir)/src/tiff/libtiff/tif_warning.c $(CCC) -c -o $@ $(WXTIFF_CFLAGS) $(srcdir)/src/tiff/libtiff/tif_warning.c +wxtiff_tif_webp.o: $(srcdir)/src/tiff/libtiff/tif_webp.c + $(CCC) -c -o $@ $(WXTIFF_CFLAGS) $(srcdir)/src/tiff/libtiff/tif_webp.c + wxtiff_tif_write.o: $(srcdir)/src/tiff/libtiff/tif_write.c $(CCC) -c -o $@ $(WXTIFF_CFLAGS) $(srcdir)/src/tiff/libtiff/tif_write.c wxtiff_tif_zip.o: $(srcdir)/src/tiff/libtiff/tif_zip.c $(CCC) -c -o $@ $(WXTIFF_CFLAGS) $(srcdir)/src/tiff/libtiff/tif_zip.c +wxtiff_tif_zstd.o: $(srcdir)/src/tiff/libtiff/tif_zstd.c + $(CCC) -c -o $@ $(WXTIFF_CFLAGS) $(srcdir)/src/tiff/libtiff/tif_zstd.c + @COND_PLATFORM_UNIX_1@wxtiff_tif_unix.o: $(srcdir)/src/tiff/libtiff/tif_unix.c @COND_PLATFORM_UNIX_1@ $(CCC) -c -o $@ $(WXTIFF_CFLAGS) $(srcdir)/src/tiff/libtiff/tif_unix.c diff --git a/README-GIT.md b/README-GIT.md index dca9fb2a94..af30263943 100644 --- a/README-GIT.md +++ b/README-GIT.md @@ -13,5 +13,5 @@ control. After doing this, please proceed with the build as with any official release, i.e. follow the instructions in the port-specific files, e.g. -[wxMSW](docs/msw/install.txt), [wxGTK](docs/gtk/install.txt), -[wxOSX](docs/osx/install.txt) and so on. +[wxMSW](docs/msw/install.md), [wxGTK](docs/gtk/install.md), +[wxOSX](docs/osx/install.md) and so on. diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index 863a733a94..3f84e21ae5 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -3287,7 +3287,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! - + src/unix/sound_sdl.cpp @@ -3708,7 +3708,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! - $(UNIX_SOUND_SRC_SDL) + $(UNIX_SOUND_SDL_SRC) diff --git a/build/bakefiles/plugins.bkl b/build/bakefiles/plugins.bkl index b346903be1..3820980dbb 100644 --- a/build/bakefiles/plugins.bkl +++ b/build/bakefiles/plugins.bkl @@ -7,7 +7,7 @@ - $(UNIX_SOUND_SRC_SDL) + $(UNIX_SOUND_SDL_SRC) $(EXTRALIBS_SDL) diff --git a/build/bakefiles/tiff.bkl b/build/bakefiles/tiff.bkl index df6629e34f..ae321f4439 100644 --- a/build/bakefiles/tiff.bkl +++ b/build/bakefiles/tiff.bkl @@ -93,8 +93,10 @@ src/tiff/libtiff/tif_tile.c src/tiff/libtiff/tif_version.c src/tiff/libtiff/tif_warning.c + src/tiff/libtiff/tif_webp.c src/tiff/libtiff/tif_write.c src/tiff/libtiff/tif_zip.c + src/tiff/libtiff/tif_zstd.c diff --git a/build/cmake/config.cmake b/build/cmake/config.cmake index 04db51a020..b89cbac302 100644 --- a/build/cmake/config.cmake +++ b/build/cmake/config.cmake @@ -44,7 +44,7 @@ function(wx_write_config) # TODO: set variables set(includedir "$") - wx_string_append(libdir "{prefix}/include") + wx_string_append(includedir "{prefix}/include") set(libdir "$") wx_string_append(libdir "{exec_prefix}/lib") set(bindir "$") diff --git a/build/cmake/files.cmake b/build/cmake/files.cmake index 455e2d2f11..3111a384c2 100644 --- a/build/cmake/files.cmake +++ b/build/cmake/files.cmake @@ -2869,6 +2869,14 @@ set(WEBVIEW_GTK_SRC src/gtk/webview_webkit.cpp ) +set(WEBVIEW2_GTK_SRC + src/gtk/webview_webkit2.cpp +) + +set(WEBVIEW_WEBKIT2_EXTENSION_SRC + src/gtk/webview_webkit2_extension.cpp +) + set(XRC_SRC src/xrc/xh_activityindicator.cpp src/xrc/xh_animatctrl.cpp @@ -3049,7 +3057,7 @@ set(OPENGL_OSX_SHARED_SRC src/osx/glcanvas_osx.cpp ) -set(UNIX_SOUND_SRC_SDL +set(UNIX_SOUND_SDL_SRC src/unix/sound_sdl.cpp ) diff --git a/build/cmake/init.cmake b/build/cmake/init.cmake index 292440380f..b5b207924a 100644 --- a/build/cmake/init.cmake +++ b/build/cmake/init.cmake @@ -223,12 +223,39 @@ if(wxUSE_GUI) endif() endif() - if(wxUSE_WEBVIEW AND WXGTK) - find_package(LibSoup) - find_package(Webkit) - if(NOT WEBKIT_FOUND OR NOT LIBSOUP_FOUND) - message(WARNING "webkit not found, wxWebview won't be available") - wx_option_force_value(wxUSE_WEBVIEW OFF) + if(wxUSE_WEBVIEW) + if(WXGTK) + if(wxUSE_WEBVIEW_WEBKIT) + find_package(LibSoup) + if(WXGTK2) + find_package(Webkit 1.0) + elseif(WXGTK3) + find_package(Webkit2) + if(NOT WEBKIT2_FOUND) + find_package(Webkit 3.0) + endif() + endif() + endif() + set(wxUSE_WEBVIEW_WEBKIT OFF) + set(wxUSE_WEBVIEW_WEBKIT2 OFF) + if(WEBKIT_FOUND AND LIBSOUP_FOUND) + set(wxUSE_WEBVIEW_WEBKIT ON) + elseif(WEBKIT2_FOUND AND LIBSOUP_FOUND) + set(wxUSE_WEBVIEW_WEBKIT2 ON) + else() + message(WARNING "webkit not found or enabled, wxWebview won't be available") + wx_option_force_value(wxUSE_WEBVIEW OFF) + endif() + elseif(WXMSW) + if(NOT wxUSE_WEBVIEW_IE) + message(WARNING "WebviewIE not found or enabled, wxWebview won't be available") + wx_option_force_value(wxUSE_WEBVIEW OFF) + endif() + elseif(APPLE) + if(NOT wxUSE_WEBVIEW_WEBKIT) + message(WARNING "webkit not found or enabled, wxWebview won't be available") + wx_option_force_value(wxUSE_WEBVIEW OFF) + endif() endif() endif() @@ -257,4 +284,15 @@ if(wxUSE_GUI) wx_option_force_value(wxUSE_MEDIACTRL OFF) endif() endif() + + if(UNIX AND wxUSE_LIBSDL) + find_package(SDL2) + if(NOT SDL2_FOUND) + find_package(SDL) + endif() + if(NOT SDL2_FOUND AND NOT SDL_FOUND) + message(WARNING "SDL not found, SDL Audio back-end won't be available") + wx_option_force_value(wxUSE_LIBSDL OFF) + endif() + endif() endif() diff --git a/build/cmake/install.cmake b/build/cmake/install.cmake index 3e038c8fcf..734a2af88a 100644 --- a/build/cmake/install.cmake +++ b/build/cmake/install.cmake @@ -20,10 +20,32 @@ if(MSVC) DIRECTORY "${wxSOURCE_DIR}/include/msvc" DESTINATION "include") endif() + +# setup header and wx-config if(MSVC OR MINGW) wx_install( DIRECTORY "${wxSETUP_HEADER_PATH}" DESTINATION "lib${wxPLATFORM_LIB_DIR}") +elseif(UNIX) + wx_install( + DIRECTORY "${wxSETUP_HEADER_PATH}" + DESTINATION "lib/wx/include") + + wx_install( + FILES "${wxOUTPUT_DIR}/wx/config/${wxBUILD_FILE_ID}" + DESTINATION "lib/wx/config" + PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ + GROUP_EXECUTE GROUP_READ + WORLD_EXECUTE WORLD_READ + ) + + install(DIRECTORY DESTINATION "bin") + install(CODE "execute_process( \ + COMMAND ${CMAKE_COMMAND} -E create_symlink \ + ${CMAKE_INSTALL_PREFIX}/lib/wx/config/${wxBUILD_FILE_ID} \ + ${CMAKE_INSTALL_PREFIX}/bin/wx-config \ + )" + ) endif() # uninstall target @@ -34,6 +56,12 @@ else() endif() if(NOT TARGET ${UNINST_NAME}) + # these files are not added to the install manifest + set(WX_EXTRA_UNINSTALL_FILES + "${CMAKE_INSTALL_PREFIX}/bin/wx-config" + "${CMAKE_INSTALL_PREFIX}/bin/wxrc-${wxMAJOR_VERSION}.${wxMINOR_VERSION}" + ) + configure_file( "${wxSOURCE_DIR}/build/cmake/uninstall.cmake.in" "${wxBINARY_DIR}/uninstall.cmake" diff --git a/build/cmake/lib/base/CMakeLists.txt b/build/cmake/lib/base/CMakeLists.txt index ec38b8947a..8f526afebe 100644 --- a/build/cmake/lib/base/CMakeLists.txt +++ b/build/cmake/lib/base/CMakeLists.txt @@ -27,28 +27,35 @@ elseif(UNIX) endif() wx_add_library(base IS_BASE ${BASE_FILES}) -wx_lib_link_libraries(base PRIVATE - ${ZLIB_LIBRARIES} - ${REGEX_LIBRARIES} -) + if(NOT wxBUILD_MONOLITHIC) wx_lib_compile_definitions(base PRIVATE wxUSE_BASE=1) endif() + if(wxUSE_ZLIB) wx_lib_include_directories(base PRIVATE ${ZLIB_INCLUDE_DIRS}) + wx_lib_link_libraries(base PRIVATE ${ZLIB_LIBRARIES}) endif() if(wxUSE_REGEX) wx_lib_include_directories(base PRIVATE ${REGEX_INCLUDE_DIRS}) + wx_lib_link_libraries(base PRIVATE ${REGEX_LIBRARIES}) endif() -if(LIBSECRET_FOUND) +if(wxUSE_LIBLZMA) + wx_lib_include_directories(base PRIVATE ${LIBLZMA_INCLUDE_DIRS}) + wx_lib_link_libraries(base PRIVATE ${LIBLZMA_LIBRARIES}) +endif() +if(UNIX AND wxUSE_SECRETSTORE) wx_lib_include_directories(base PRIVATE ${LIBSECRET_INCLUDE_DIRS}) + wx_lib_link_libraries(base PRIVATE ${LIBSECRET_LIBRARIES}) endif() -if(wxUSE_LIBICONV AND ICONV_LIBRARIES) +if(wxUSE_LIBICONV AND ICONV_FOUND) + wx_lib_include_directories(base PRIVATE ${ICONV_INCLUDE_DIRS}) wx_lib_link_libraries(base PRIVATE ${ICONV_LIBRARIES}) endif() if(wxUSE_THREADS AND CMAKE_THREAD_LIBS_INIT) wx_lib_link_libraries(base PRIVATE ${CMAKE_THREAD_LIBS_INIT}) endif() + if(APPLE) wx_lib_link_libraries(base PRIVATE @@ -60,10 +67,7 @@ if(APPLE) "-framework IOKit" ) elseif(UNIX) - wx_lib_link_libraries(base PRIVATE - dl - ${LIBSECRET_LIBRARIES} - ) + wx_lib_link_libraries(base PRIVATE dl) endif() wx_finalize_lib(base) diff --git a/build/cmake/lib/core/CMakeLists.txt b/build/cmake/lib/core/CMakeLists.txt index e0a0a2a52e..54c2810051 100644 --- a/build/cmake/lib/core/CMakeLists.txt +++ b/build/cmake/lib/core/CMakeLists.txt @@ -15,6 +15,9 @@ if(WIN32) wx_append_sources(CORE_SRC BASE_AND_GUI_WIN32) elseif(UNIX) wx_append_sources(CORE_SRC UNIX) + if(wxUSE_LIBSDL) + wx_append_sources(CORE_SRC UNIX_SOUND_SDL) + endif() endif() if(WXMSW) @@ -62,27 +65,26 @@ foreach(lib JPEG PNG TIFF) endforeach() if(WIN32) - wx_lib_link_libraries(core PRIVATE - winmm - ) + wx_lib_link_libraries(core PRIVATE winmm) endif() if(WXOSX_COCOA) - wx_lib_link_libraries(core PUBLIC - "-framework AudioToolbox" - ) + wx_lib_link_libraries(core PUBLIC "-framework AudioToolbox") if(wxUSE_WEBKIT) - wx_lib_link_libraries(core PUBLIC - "-framework WebKit" - ) + wx_lib_link_libraries(core PUBLIC "-framework WebKit") endif() endif() if(WXGTK AND wxUSE_PRIVATE_FONTS) - wx_lib_include_directories(core PUBLIC - ${FONTCONFIG_INCLUDE_DIR} - ) - wx_lib_link_libraries(core PUBLIC - ${FONTCONFIG_LIBRARIES} - ) + wx_lib_include_directories(core PUBLIC ${FONTCONFIG_INCLUDE_DIR}) + wx_lib_link_libraries(core PUBLIC ${FONTCONFIG_LIBRARIES}) +endif() +if(UNIX AND wxUSE_LIBSDL) + if(SDL2_FOUND) + wx_lib_include_directories(core PUBLIC ${SDL2_INCLUDE_DIR}) + wx_lib_link_libraries(core PUBLIC ${SDL2_LIBRARY}) + elseif(SDL_FOUND) + wx_lib_include_directories(core PUBLIC ${SDL_INCLUDE_DIR}) + wx_lib_link_libraries(core PUBLIC ${SDL_LIBRARY}) + endif() endif() wx_finalize_lib(core) diff --git a/build/cmake/lib/stc/CMakeLists.txt b/build/cmake/lib/stc/CMakeLists.txt index 27af21bb79..8def395466 100644 --- a/build/cmake/lib/stc/CMakeLists.txt +++ b/build/cmake/lib/stc/CMakeLists.txt @@ -167,10 +167,10 @@ target_compile_definitions(wxscintilla PUBLIC if(wxBUILD_PRECOMP) # The auto-generated header causes undefined members and identifiers in the - # standard c++ headers when using clang on macOS or Windows. + # standard c++ headers when using clang. # Do not disable precompiled headers entirely but use the main Scintilla # header as prefix header so there is at least a small speedup. - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND (APPLE OR WIN32)) + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") set(wxSCINTILLA_PREC_HEADER "${wxSOURCE_DIR}/src/stc/scintilla/include/Scintilla.h") endif() wx_target_enable_precomp(wxscintilla ${wxSCINTILLA_PREC_HEADER}) diff --git a/build/cmake/lib/tiff.cmake b/build/cmake/lib/tiff.cmake index d1ef8d51f6..289390db73 100644 --- a/build/cmake/lib/tiff.cmake +++ b/build/cmake/lib/tiff.cmake @@ -59,8 +59,10 @@ if(wxUSE_LIBTIFF STREQUAL "builtin") src/tiff/libtiff/tif_tile.c src/tiff/libtiff/tif_version.c src/tiff/libtiff/tif_warning.c + src/tiff/libtiff/tif_webp.c src/tiff/libtiff/tif_write.c src/tiff/libtiff/tif_zip.c + src/tiff/libtiff/tif_zstd.c ) if(WIN32) # define this to get rid of a warning about using POSIX lfind(): diff --git a/build/cmake/lib/webview/CMakeLists.txt b/build/cmake/lib/webview/CMakeLists.txt index 317bb1be62..ac4caca35e 100644 --- a/build/cmake/lib/webview/CMakeLists.txt +++ b/build/cmake/lib/webview/CMakeLists.txt @@ -14,25 +14,70 @@ wx_append_sources(WEBVIEW_FILES WEBVIEW_CMN) if(WXMSW) wx_append_sources(WEBVIEW_FILES WEBVIEW_MSW) elseif(WXGTK) - wx_append_sources(WEBVIEW_FILES WEBVIEW_GTK) + if(wxUSE_WEBVIEW_WEBKIT2) + wx_append_sources(WEBVIEW_FILES WEBVIEW2_GTK) + elseif(wxUSE_WEBVIEW_WEBKIT) + wx_append_sources(WEBVIEW_FILES WEBVIEW_GTK) + endif() elseif(APPLE) wx_append_sources(WEBVIEW_FILES WEBVIEW_OSX_SHARED) endif() wx_add_library(webview ${WEBVIEW_FILES}) -if(APPLE) - wx_lib_link_libraries(webview PUBLIC - "-framework WebKit" - ) -elseif(WXGTK) - wx_lib_include_directories(webview PUBLIC - ${WEBKIT_INCLUDE_DIR} - ${LIBSOUP_INCLUDE_DIRS} - ) - wx_lib_link_libraries(webview PUBLIC - ${WEBKIT_LIBRARIES} - ${LIBSOUP_LIBRARIES} + +if(WXGTK AND wxUSE_WEBVIEW_WEBKIT2) + set(WX_WEB_EXTENSIONS_DIRECTORY "lib/wx/${wxMAJOR_VERSION}.${wxMINOR_VERSION}/web-extensions") + wx_lib_compile_definitions(webview PRIVATE + -DWX_WEB_EXTENSIONS_DIRECTORY="${CMAKE_INSTALL_PREFIX}/${WX_WEB_EXTENSIONS_DIRECTORY}" ) endif() +if(APPLE) + wx_lib_link_libraries(webview PUBLIC "-framework WebKit") +elseif(WXGTK) + if(LIBSOUP_FOUND) + wx_lib_include_directories(webview PUBLIC ${LIBSOUP_INCLUDE_DIRS}) + wx_lib_link_libraries(webview PUBLIC ${LIBSOUP_LIBRARIES}) + endif() + if(wxUSE_WEBVIEW_WEBKIT2) + wx_lib_include_directories(webview PUBLIC ${WEBKIT2_INCLUDE_DIR}) + wx_lib_link_libraries(webview PUBLIC ${WEBKIT2_LIBRARIES}) + elseif(wxUSE_WEBVIEW_WEBKIT) + wx_lib_include_directories(webview PUBLIC ${WEBKIT_INCLUDE_DIR}) + wx_lib_link_libraries(webview PUBLIC ${WEBKIT_LIBRARIES}) + endif() +endif() + wx_finalize_lib(webview) + +# webkit extension plugin +# we can't use (all of the) macros and functions because this library should +# always be build as a shared libary, and not included in the monolithic build. +if(WXGTK AND wxUSE_WEBVIEW_WEBKIT2) + wx_append_sources(WEBKIT2_EXT_FILES WEBVIEW_WEBKIT2_EXTENSION) + add_library(webkit2_ext SHARED ${WEBKIT2_EXT_FILES}) + wx_set_target_properties(webkit2_ext false) + + # Change output name to match expected name in webview_webkit2.cpp: webkit2_ext* + if(wxUSE_UNICODE) + set(lib_unicode u) + endif() + set_target_properties(webkit2_ext PROPERTIES PREFIX "") + set_target_properties(webkit2_ext PROPERTIES + OUTPUT_NAME "webkit2_ext${lib_unicode}-${wxMAJOR_VERSION}.${wxMINOR_VERSION}" + OUTPUT_NAME_DEBUG "webkit2_ext${lib_unicode}d-${wxMAJOR_VERSION}.${wxMINOR_VERSION}" + ) + + target_include_directories(webkit2_ext PUBLIC + ${LIBSOUP_INCLUDE_DIRS} + ${WEBKIT2_INCLUDE_DIR} + ) + target_link_libraries(webkit2_ext PUBLIC + ${LIBSOUP_LIBRARIES} + ${WEBKIT2_LIBRARIES} + ) + + wx_install(TARGETS webkit2_ext LIBRARY DESTINATION ${WX_WEB_EXTENSIONS_DIRECTORY}) + + add_dependencies(webview webkit2_ext) +endif() diff --git a/build/cmake/lib/xml/CMakeLists.txt b/build/cmake/lib/xml/CMakeLists.txt index 21173c5ad1..3eaae0b5d1 100644 --- a/build/cmake/lib/xml/CMakeLists.txt +++ b/build/cmake/lib/xml/CMakeLists.txt @@ -11,9 +11,7 @@ include(../../source_groups.cmake) wx_append_sources(XML_FILES XML) wx_add_library(xml IS_BASE ${XML_FILES}) -wx_lib_link_libraries(xml - PRIVATE ${EXPAT_LIBRARIES} - ) +wx_lib_link_libraries(xml PRIVATE ${EXPAT_LIBRARIES}) wx_lib_include_directories(xml PRIVATE ${EXPAT_INCLUDE_DIRS}) wx_finalize_lib(xml) diff --git a/build/cmake/modules/FindSDL2.cmake b/build/cmake/modules/FindSDL2.cmake new file mode 100644 index 0000000000..3878427d8c --- /dev/null +++ b/build/cmake/modules/FindSDL2.cmake @@ -0,0 +1,175 @@ + +# This module defines +# SDL2_LIBRARY, the name of the library to link against +# SDL2_FOUND, if false, do not try to link to SDL2 +# SDL2_INCLUDE_DIR, where to find SDL.h +# +# This module responds to the the flag: +# SDL2_BUILDING_LIBRARY +# If this is defined, then no SDL2main will be linked in because +# only applications need main(). +# Otherwise, it is assumed you are building an application and this +# module will attempt to locate and set the the proper link flags +# as part of the returned SDL2_LIBRARY variable. +# +# Don't forget to include SDLmain.h and SDLmain.m your project for the +# OS X framework based version. (Other versions link to -lSDL2main which +# this module will try to find on your behalf.) Also for OS X, this +# module will automatically add the -framework Cocoa on your behalf. +# +# +# Additional Note: If you see an empty SDL2_LIBRARY_TEMP in your configuration +# and no SDL2_LIBRARY, it means CMake did not find your SDL2 library +# (SDL2.dll, libsdl2.so, SDL2.framework, etc). +# Set SDL2_LIBRARY_TEMP to point to your SDL2 library, and configure again. +# Similarly, if you see an empty SDL2MAIN_LIBRARY, you should set this value +# as appropriate. These values are used to generate the final SDL2_LIBRARY +# variable, but when these values are unset, SDL2_LIBRARY does not get created. +# +# +# $SDL2DIR is an environment variable that would +# correspond to the ./configure --prefix=$SDL2DIR +# used in building SDL2. +# l.e.galup 9-20-02 +# +# Modified by Eric Wing. +# Added code to assist with automated building by using environmental variables +# and providing a more controlled/consistent search behavior. +# Added new modifications to recognize OS X frameworks and +# additional Unix paths (FreeBSD, etc). +# Also corrected the header search path to follow "proper" SDL guidelines. +# Added a search for SDL2main which is needed by some platforms. +# Added a search for threads which is needed by some platforms. +# Added needed compile switches for MinGW. +# +# On OSX, this will prefer the Framework version (if found) over others. +# People will have to manually change the cache values of +# SDL2_LIBRARY to override this selection or set the CMake environment +# CMAKE_INCLUDE_PATH to modify the search paths. +# +# Note that the header path has changed from SDL2/SDL.h to just SDL.h +# This needed to change because "proper" SDL convention +# is #include "SDL.h", not . This is done for portability +# reasons because not all systems place things in SDL2/ (see FreeBSD). + +#============================================================================= +# Copyright 2003-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# message("") + +SET(SDL2_SEARCH_PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt + ${SDL2_PATH} +) + +FIND_PATH(SDL2_INCLUDE_DIR SDL.h + HINTS + $ENV{SDL2DIR} + PATH_SUFFIXES include/SDL2 include + PATHS ${SDL2_SEARCH_PATHS} +) + +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(PATH_SUFFIXES lib64 lib/x64 lib) +else() + set(PATH_SUFFIXES lib/x86 lib) +endif() + +FIND_LIBRARY(SDL2_LIBRARY_TEMP + NAMES SDL2 + HINTS + $ENV{SDL2DIR} + PATH_SUFFIXES ${PATH_SUFFIXES} + PATHS ${SDL2_SEARCH_PATHS} +) + +IF(NOT SDL2_BUILDING_LIBRARY) + IF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework") + # Non-OS X framework versions expect you to also dynamically link to + # SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms + # seem to provide SDL2main for compatibility even though they don't + # necessarily need it. + FIND_LIBRARY(SDL2MAIN_LIBRARY + NAMES SDL2main + HINTS + $ENV{SDL2DIR} + PATH_SUFFIXES ${PATH_SUFFIXES} + PATHS ${SDL2_SEARCH_PATHS} + ) + ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework") +ENDIF(NOT SDL2_BUILDING_LIBRARY) + +# SDL2 may require threads on your system. +# The Apple build may not need an explicit flag because one of the +# frameworks may already provide it. +# But for non-OSX systems, I will use the CMake Threads package. +IF(NOT APPLE) + FIND_PACKAGE(Threads) +ENDIF(NOT APPLE) + +# MinGW needs an additional link flag, -mwindows +# It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -mwindows +IF(MINGW) + SET(MINGW32_LIBRARY mingw32 "-mwindows" CACHE STRING "mwindows for MinGW") +ENDIF(MINGW) + +IF(SDL2_LIBRARY_TEMP) + # For SDL2main + IF(NOT SDL2_BUILDING_LIBRARY) + IF(SDL2MAIN_LIBRARY) + SET(SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY_TEMP}) + ENDIF(SDL2MAIN_LIBRARY) + ENDIF(NOT SDL2_BUILDING_LIBRARY) + + # For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa. + # CMake doesn't display the -framework Cocoa string in the UI even + # though it actually is there if I modify a pre-used variable. + # I think it has something to do with the CACHE STRING. + # So I use a temporary variable until the end so I can set the + # "real" variable in one-shot. + IF(APPLE) + SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa") + ENDIF(APPLE) + + # For threads, as mentioned Apple doesn't need this. + # In fact, there seems to be a problem if I used the Threads package + # and try using this line, so I'm just skipping it entirely for OS X. + IF(NOT APPLE) + SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT}) + ENDIF(NOT APPLE) + + # For MinGW library + IF(MINGW) + SET(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP}) + ENDIF(MINGW) + + # Set the final string here so the GUI reflects the final state. + SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found") + # Set the temp variable to INTERNAL so it is not seen in the CMake GUI + SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "") +ENDIF(SDL2_LIBRARY_TEMP) + +# message("") + +INCLUDE(FindPackageHandleStandardArgs) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR) + +MARK_AS_ADVANCED(SDL2MAIN_LIBRARY SDL2_LIBRARY SDL2_INCLUDE_DIR) diff --git a/build/cmake/modules/FindWebkit.cmake b/build/cmake/modules/FindWebkit.cmake index 1bb331cf69..8b6e6ccef7 100644 --- a/build/cmake/modules/FindWebkit.cmake +++ b/build/cmake/modules/FindWebkit.cmake @@ -1,16 +1,18 @@ -# - Find Webkit-3.0 -# Find the Webkit-3.0 includes and library +# - Find Webkit +# Find the Webkit includes and library # # WEBKIT_INCLUDE_DIR - Where to find webkit include sub-directory. -# WEBKIT_LIBRARIES - List of libraries when using Webkit-3.0. -# WEBKIT_FOUND - True if Webkit-3.0 found. +# WEBKIT_LIBRARIES - List of libraries when using Webkit. +# WEBKIT_FOUND - True if Webkit found. -SET( WEBKIT_VERSION "1.0") +SET(WEBKIT_VERSION 1.0) +if(DEFINED Webkit_FIND_VERSION) + SET(WEBKIT_VERSION ${Webkit_FIND_VERSION}) +endif() -IF (WEBKIT_INCLUDE_DIR) - # Already in cache, be silent. - SET(WEBKIT_FIND_QUIETLY TRUE) -ENDIF (WEBKIT_INCLUDE_DIR) +SET(WEBKIT_INCLUDE_DIR WEBKIT_INCLUDE_DIR-NOTFOUND) +SET(WEBKIT_LIBRARY WEBKIT_LIBRARY-NOTFOUND) +SET(WEBKIT_LIBRARIES WEBKIT_LIBRARIES-NOTFOUND) FIND_PATH(WEBKIT_INCLUDE_DIR webkit/webkit.h PATH_SUFFIXES "webkitgtk-${WEBKIT_VERSION}" @@ -35,4 +37,4 @@ ELSE(WEBKIT_FOUND) SET( WEBKIT_LIBRARIES ) ENDIF(WEBKIT_FOUND) -MARK_AS_ADVANCED( WEBKIT_LIBRARY WEBKIT_INCLUDE_DIR ) +MARK_AS_ADVANCED(WEBKIT_LIBRARY WEBKIT_LIBRARIES WEBKIT_INCLUDE_DIR) diff --git a/build/cmake/modules/FindWebkit2.cmake b/build/cmake/modules/FindWebkit2.cmake new file mode 100644 index 0000000000..33a8e4a863 --- /dev/null +++ b/build/cmake/modules/FindWebkit2.cmake @@ -0,0 +1,37 @@ +# - Find Webkit2 +# Find the Webkit2 includes and library +# +# WEBKIT2_INCLUDE_DIR - Where to find Webkit2 include sub-directory. +# WEBKIT2_LIBRARIES - List of libraries when using Webkit2. +# WEBKIT2_FOUND - True if Webkit2 found. + +SET( WEBKIT2_VERSION 4.0) + +set(WEBKIT2_INCLUDE_DIR WEBKIT2_INCLUDE_DIR-NOTFOUND) +set(WEBKIT2_LIBRARY WEBKIT2_LIBRARY-NOTFOUND) +set(WEBKIT2_LIBRARIES WEBKIT2_LIBRARIES-NOTFOUND) + +FIND_PATH(WEBKIT2_INCLUDE_DIR webkit2/webkit2.h + PATH_SUFFIXES "webkitgtk-${WEBKIT2_VERSION}" +) + +SET(WEBKIT2_NAMES "webkit2gtk-${WEBKIT2_VERSION}") +FIND_LIBRARY(WEBKIT2_LIBRARY + NAMES ${WEBKIT2_NAMES} +) + +# Handle the QUIETLY and REQUIRED arguments and set WEBKIT2_FOUND to +# TRUE if all listed variables are TRUE. +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS( + WEBKIT2 DEFAULT_MSG + WEBKIT2_LIBRARY WEBKIT2_INCLUDE_DIR +) + +IF(WEBKIT2_FOUND) + SET( WEBKIT2_LIBRARIES ${WEBKIT2_LIBRARY} ) +ELSE(WEBKIT2_FOUND) + SET( WEBKIT2_LIBRARIES ) +ENDIF(WEBKIT2_FOUND) + +MARK_AS_ADVANCED(WEBKIT2_LIBRARY WEBKIT2_LIBRARIES WEBKIT2_INCLUDE_DIR) diff --git a/build/cmake/options.cmake b/build/cmake/options.cmake index 6b03f2b068..1ea8458bda 100644 --- a/build/cmake/options.cmake +++ b/build/cmake/options.cmake @@ -37,7 +37,7 @@ else() set(wxCXX_STANDARD_DEFAULT COMPILER_DEFAULT) endif() wx_option(wxBUILD_CXX_STANDARD "C++ standard used to build wxWidgets targets" - ${wxCXX_STANDARD_DEFAULT} STRINGS COMPILER_DEFAULT 98 11 14) + ${wxCXX_STANDARD_DEFAULT} STRINGS COMPILER_DEFAULT 98 11 14 17) endif() if(WIN32) @@ -74,6 +74,7 @@ wx_option(wxUSE_LIBLZMA "use LZMA compression" OFF) set(wxTHIRD_PARTY_LIBRARIES ${wxTHIRD_PARTY_LIBRARIES} wxUSE_LIBLZMA "use liblzma for LZMA compression") wx_option(wxUSE_OPENGL "use OpenGL (or Mesa)") +wx_option(wxUSE_LIBSDL "use SDL for audio on Unix") if(NOT WIN32) wx_option(wxUSE_LIBICONV "use libiconv (character conversion)") @@ -356,7 +357,6 @@ wx_option(wxUSE_DRAGIMAGE "use wxDragImage") wx_option(wxUSE_UIACTIONSIMULATOR "use wxUIActionSimulator (experimental)") wx_option(wxUSE_DC_TRANSFORM_MATRIX "use wxDC::SetTransformMatrix and related") wx_option(wxUSE_WEBVIEW_WEBKIT "use wxWebView WebKit backend") -# TODO: wxUSE_WEBVIEW_WEBKIT2 if(WIN32 OR APPLE) set(wxUSE_PRIVATE_FONTS_DEFAULT ON) else() diff --git a/build/cmake/policies.cmake b/build/cmake/policies.cmake index 46c35011a4..496aae7507 100644 --- a/build/cmake/policies.cmake +++ b/build/cmake/policies.cmake @@ -53,3 +53,8 @@ if(POLICY CMP0067) # Honor language standard in try_compile() source-file signature. cmake_policy(SET CMP0067 NEW) endif() + +if(POLICY CMP0072) + # FindOpenGL prefers GLVND by default when available. + cmake_policy(SET CMP0072 NEW) +endif() diff --git a/build/cmake/samples/CMakeLists.txt b/build/cmake/samples/CMakeLists.txt index 47230283ba..2f8d28070a 100644 --- a/build/cmake/samples/CMakeLists.txt +++ b/build/cmake/samples/CMakeLists.txt @@ -152,7 +152,10 @@ wx_add_sample(typetest typetest.cpp typetest.h) wx_add_sample(uiaction DEPENDS wxUSE_UIACTIONSIMULATOR) wx_add_sample(validate validate.cpp validate.h DEPENDS wxUSE_VALIDATORS) wx_add_sample(vscroll vstest.cpp) -wx_add_sample(webview LIBRARIES webview stc NAME webviewsample DEPENDS wxUSE_WEBVIEW) +wx_add_sample(webview LIBRARIES webview NAME webviewsample DEPENDS wxUSE_WEBVIEW) +if(TARGET webviewsample AND wxUSE_STC) + wx_exe_link_libraries(webviewsample stc) +endif() # widgets Sample set(SAMPLE_WIDGETS_SRC activityindicator.cpp diff --git a/build/cmake/uninstall.cmake.in b/build/cmake/uninstall.cmake.in index b03059ad52..7d21a385d9 100644 --- a/build/cmake/uninstall.cmake.in +++ b/build/cmake/uninstall.cmake.in @@ -13,6 +13,7 @@ endif() file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) string(REGEX REPLACE "\n" ";" files "${files}") +list(APPEND files @WX_EXTRA_UNINSTALL_FILES@) foreach(file ${files}) message(STATUS "Uninstalling $ENV{DESTDIR}${file}") if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") diff --git a/build/cmake/utils/CMakeLists.txt b/build/cmake/utils/CMakeLists.txt index bf29f72156..a242fdec66 100644 --- a/build/cmake/utils/CMakeLists.txt +++ b/build/cmake/utils/CMakeLists.txt @@ -17,8 +17,24 @@ if(wxUSE_XRC) wx_exe_link_libraries(wxrc xml) endif() wx_exe_link_libraries(wxrc base) - # TODO: install + set_target_properties(wxrc PROPERTIES FOLDER "Utilities") + + if(UNIX) + wx_install(TARGETS wxrc RUNTIME DESTINATION "bin") + install(CODE "execute_process( \ + COMMAND ${CMAKE_COMMAND} -E rename \ + ${CMAKE_INSTALL_PREFIX}/bin/wxrc \ + ${CMAKE_INSTALL_PREFIX}/bin/wxrc-${wxMAJOR_VERSION}.${wxMINOR_VERSION} \ + )" + ) + install(CODE "execute_process( \ + COMMAND ${CMAKE_COMMAND} -E create_symlink \ + ${CMAKE_INSTALL_PREFIX}/bin/wxrc-${wxMAJOR_VERSION}.${wxMINOR_VERSION} \ + ${CMAKE_INSTALL_PREFIX}/bin/wxrc \ + )" + ) + endif() endif() # TODO: build targets for other utils diff --git a/build/files b/build/files index 93c9fec7dd..d774633b94 100644 --- a/build/files +++ b/build/files @@ -2812,6 +2812,12 @@ WEBVIEW_GTK_HDR = WEBVIEW_GTK_SRC = src/gtk/webview_webkit.cpp +WEBVIEW2_GTK_SRC = + src/gtk/webview_webkit2.cpp + +WEBVIEW_WEBKIT2_EXTENSION_SRC = + src/gtk/webview_webkit2_extension.cpp + # wxXRC XRC_SRC = @@ -2991,7 +2997,7 @@ OPENGL_OSX_SHARED_SRC = # Misc plugin sources: -UNIX_SOUND_SRC_SDL = +UNIX_SOUND_SDL_SRC = src/unix/sound_sdl.cpp # wxAUI diff --git a/build/msw/makefile.bcc b/build/msw/makefile.bcc index 24a3687ebe..8112f30f89 100644 --- a/build/msw/makefile.bcc +++ b/build/msw/makefile.bcc @@ -185,8 +185,10 @@ WXTIFF_OBJECTS = \ $(OBJS)\wxtiff_tif_tile.obj \ $(OBJS)\wxtiff_tif_version.obj \ $(OBJS)\wxtiff_tif_warning.obj \ + $(OBJS)\wxtiff_tif_webp.obj \ $(OBJS)\wxtiff_tif_write.obj \ - $(OBJS)\wxtiff_tif_zip.obj + $(OBJS)\wxtiff_tif_zip.obj \ + $(OBJS)\wxtiff_tif_zstd.obj WXEXPAT_CFLAGS = $(__RUNTIME_LIBS) -I$(BCCDIR)\include $(__DEBUGINFO) \ $(__OPTIMIZEFLAG) $(__THREADSFLAG) -DNDEBUG -I$(LIBDIRNAME) -w-8004 -w-8008 \ -w-8012 -w-8057 -w-8066 $(CPPFLAGS) $(CFLAGS) @@ -5950,12 +5952,18 @@ $(OBJS)\wxtiff_tif_version.obj: ..\..\src\tiff\libtiff\tif_version.c $(OBJS)\wxtiff_tif_warning.obj: ..\..\src\tiff\libtiff\tif_warning.c $(CC) -q -c -P- -o$@ $(WXTIFF_CFLAGS) ..\..\src\tiff\libtiff\tif_warning.c +$(OBJS)\wxtiff_tif_webp.obj: ..\..\src\tiff\libtiff\tif_webp.c + $(CC) -q -c -P- -o$@ $(WXTIFF_CFLAGS) ..\..\src\tiff\libtiff\tif_webp.c + $(OBJS)\wxtiff_tif_write.obj: ..\..\src\tiff\libtiff\tif_write.c $(CC) -q -c -P- -o$@ $(WXTIFF_CFLAGS) ..\..\src\tiff\libtiff\tif_write.c $(OBJS)\wxtiff_tif_zip.obj: ..\..\src\tiff\libtiff\tif_zip.c $(CC) -q -c -P- -o$@ $(WXTIFF_CFLAGS) ..\..\src\tiff\libtiff\tif_zip.c +$(OBJS)\wxtiff_tif_zstd.obj: ..\..\src\tiff\libtiff\tif_zstd.c + $(CC) -q -c -P- -o$@ $(WXTIFF_CFLAGS) ..\..\src\tiff\libtiff\tif_zstd.c + $(OBJS)\wxexpat_xmlparse.obj: ..\..\src\expat\expat\lib\xmlparse.c $(CC) -q -c -P- -o$@ $(WXEXPAT_CFLAGS) ..\..\src\expat\expat\lib\xmlparse.c diff --git a/build/msw/makefile.gcc b/build/msw/makefile.gcc index 18792ec66d..c6a2042c6b 100644 --- a/build/msw/makefile.gcc +++ b/build/msw/makefile.gcc @@ -174,8 +174,10 @@ WXTIFF_OBJECTS = \ $(OBJS)\wxtiff_tif_tile.o \ $(OBJS)\wxtiff_tif_version.o \ $(OBJS)\wxtiff_tif_warning.o \ + $(OBJS)\wxtiff_tif_webp.o \ $(OBJS)\wxtiff_tif_write.o \ - $(OBJS)\wxtiff_tif_zip.o + $(OBJS)\wxtiff_tif_zip.o \ + $(OBJS)\wxtiff_tif_zstd.o WXEXPAT_CFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(__THREADSFLAG) $(GCCFLAGS) \ -DHAVE_W32API_H -DNDEBUG -I$(LIBDIRNAME) $(CPPFLAGS) $(CFLAGS) WXEXPAT_OBJECTS = \ @@ -6132,12 +6134,18 @@ $(OBJS)\wxtiff_tif_version.o: ../../src/tiff/libtiff/tif_version.c $(OBJS)\wxtiff_tif_warning.o: ../../src/tiff/libtiff/tif_warning.c $(CC) -c -o $@ $(WXTIFF_CFLAGS) $(CPPDEPS) $< +$(OBJS)\wxtiff_tif_webp.o: ../../src/tiff/libtiff/tif_webp.c + $(CC) -c -o $@ $(WXTIFF_CFLAGS) $(CPPDEPS) $< + $(OBJS)\wxtiff_tif_write.o: ../../src/tiff/libtiff/tif_write.c $(CC) -c -o $@ $(WXTIFF_CFLAGS) $(CPPDEPS) $< $(OBJS)\wxtiff_tif_zip.o: ../../src/tiff/libtiff/tif_zip.c $(CC) -c -o $@ $(WXTIFF_CFLAGS) $(CPPDEPS) $< +$(OBJS)\wxtiff_tif_zstd.o: ../../src/tiff/libtiff/tif_zstd.c + $(CC) -c -o $@ $(WXTIFF_CFLAGS) $(CPPDEPS) $< + $(OBJS)\wxexpat_xmlparse.o: ../../src/expat/expat/lib/xmlparse.c $(CC) -c -o $@ $(WXEXPAT_CFLAGS) $(CPPDEPS) $< diff --git a/build/msw/makefile.vc b/build/msw/makefile.vc index 60db1ec578..c1ce7f10bd 100644 --- a/build/msw/makefile.vc +++ b/build/msw/makefile.vc @@ -191,8 +191,10 @@ WXTIFF_OBJECTS = \ $(OBJS)\wxtiff_tif_tile.obj \ $(OBJS)\wxtiff_tif_version.obj \ $(OBJS)\wxtiff_tif_warning.obj \ + $(OBJS)\wxtiff_tif_webp.obj \ $(OBJS)\wxtiff_tif_write.obj \ - $(OBJS)\wxtiff_tif_zip.obj + $(OBJS)\wxtiff_tif_zip.obj \ + $(OBJS)\wxtiff_tif_zstd.obj WXEXPAT_CFLAGS = /M$(__RUNTIME_LIBS_85)$(__DEBUGRUNTIME) /DWIN32 \ $(__DEBUGINFO) /Fd$(LIBDIRNAME)\wxexpat$(WXDEBUGFLAG).pdb \ $(____DEBUGRUNTIME) $(__OPTIMIZEFLAG) /D_CRT_SECURE_NO_DEPRECATE=1 \ @@ -6659,12 +6661,18 @@ $(OBJS)\wxtiff_tif_version.obj: ..\..\src\tiff\libtiff\tif_version.c $(OBJS)\wxtiff_tif_warning.obj: ..\..\src\tiff\libtiff\tif_warning.c $(CC) /c /nologo /TC /Fo$@ $(WXTIFF_CFLAGS) ..\..\src\tiff\libtiff\tif_warning.c +$(OBJS)\wxtiff_tif_webp.obj: ..\..\src\tiff\libtiff\tif_webp.c + $(CC) /c /nologo /TC /Fo$@ $(WXTIFF_CFLAGS) ..\..\src\tiff\libtiff\tif_webp.c + $(OBJS)\wxtiff_tif_write.obj: ..\..\src\tiff\libtiff\tif_write.c $(CC) /c /nologo /TC /Fo$@ $(WXTIFF_CFLAGS) ..\..\src\tiff\libtiff\tif_write.c $(OBJS)\wxtiff_tif_zip.obj: ..\..\src\tiff\libtiff\tif_zip.c $(CC) /c /nologo /TC /Fo$@ $(WXTIFF_CFLAGS) ..\..\src\tiff\libtiff\tif_zip.c +$(OBJS)\wxtiff_tif_zstd.obj: ..\..\src\tiff\libtiff\tif_zstd.c + $(CC) /c /nologo /TC /Fo$@ $(WXTIFF_CFLAGS) ..\..\src\tiff\libtiff\tif_zstd.c + $(OBJS)\wxexpat_xmlparse.obj: ..\..\src\expat\expat\lib\xmlparse.c $(CC) /c /nologo /TC /Fo$@ $(WXEXPAT_CFLAGS) ..\..\src\expat\expat\lib\xmlparse.c diff --git a/build/msw/wx_vc7_wxtiff.vcproj b/build/msw/wx_vc7_wxtiff.vcproj index 24ff2fe8e7..e38387d7e3 100644 --- a/build/msw/wx_vc7_wxtiff.vcproj +++ b/build/msw/wx_vc7_wxtiff.vcproj @@ -351,6 +351,9 @@ + + @@ -360,6 +363,9 @@ + + diff --git a/build/msw/wx_vc8_wxtiff.vcproj b/build/msw/wx_vc8_wxtiff.vcproj index a0dd040d57..ad88651710 100644 --- a/build/msw/wx_vc8_wxtiff.vcproj +++ b/build/msw/wx_vc8_wxtiff.vcproj @@ -814,6 +814,10 @@ RelativePath="..\..\src\tiff\libtiff\tif_warning.c" > + + @@ -826,6 +830,10 @@ RelativePath="..\..\src\tiff\libtiff\tif_zip.c" > + + diff --git a/build/msw/wx_vc9_wxtiff.vcproj b/build/msw/wx_vc9_wxtiff.vcproj index 98b10bf9d5..bd58142dbc 100644 --- a/build/msw/wx_vc9_wxtiff.vcproj +++ b/build/msw/wx_vc9_wxtiff.vcproj @@ -810,6 +810,10 @@ RelativePath="..\..\src\tiff\libtiff\tif_warning.c" > + + @@ -822,6 +826,10 @@ RelativePath="..\..\src\tiff\libtiff\tif_zip.c" > + + diff --git a/build/msw/wx_wxtiff.vcxproj b/build/msw/wx_wxtiff.vcxproj index 68ba078db1..a4a9ce61ce 100644 --- a/build/msw/wx_wxtiff.vcxproj +++ b/build/msw/wx_wxtiff.vcxproj @@ -418,8 +418,11 @@ + + + @@ -435,9 +438,11 @@ + + diff --git a/build/msw/wx_wxtiff.vcxproj.filters b/build/msw/wx_wxtiff.vcxproj.filters index 9294e7c179..c45fe2cbe1 100644 --- a/build/msw/wx_wxtiff.vcxproj.filters +++ b/build/msw/wx_wxtiff.vcxproj.filters @@ -115,5 +115,20 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + \ No newline at end of file diff --git a/build/osx/wxcocoa.xcodeproj/project.pbxproj b/build/osx/wxcocoa.xcodeproj/project.pbxproj index b713560798..a7b2275d59 100644 --- a/build/osx/wxcocoa.xcodeproj/project.pbxproj +++ b/build/osx/wxcocoa.xcodeproj/project.pbxproj @@ -3885,7 +3885,7 @@ 0116581B77DF3A5D889B8D17 /* dndcmn.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = dndcmn.cpp; path = ../../src/common/dndcmn.cpp; sourceTree = ""; }; 018B15DE6F3A3D49B9CDE9DE /* hidjoystick.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = hidjoystick.cpp; path = ../../src/osx/core/hidjoystick.cpp; sourceTree = ""; }; 01BA6D45FE4C381493EB4372 /* validate.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = validate.cpp; path = ../../src/common/validate.cpp; sourceTree = ""; }; - 027D2F04BE933ED6B9BA1518 /* imaglist.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = imaglist.cpp; path = ../../src/osx/imaglist.cpp; sourceTree = ""; }; + 027D2F04BE933ED6B9BA1518 /* imaglist.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = imaglist.cpp; path = ../../src/generic/imaglist.cpp; sourceTree = ""; }; 029486D6A2EC3DE0902A6A24 /* jfdctfst.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = jfdctfst.c; path = ../../src/jpeg/jfdctfst.c; sourceTree = ""; }; 02D2E8B5C89939CE90B99E2B /* archive.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = archive.cpp; path = ../../src/common/archive.cpp; sourceTree = ""; }; 02D9332D5C5632E981936E29 /* jquant2.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = jquant2.c; path = ../../src/jpeg/jquant2.c; sourceTree = ""; }; diff --git a/configure b/configure index 2378cc74fd..18146f9527 100755 --- a/configure +++ b/configure @@ -23373,8 +23373,11 @@ fi fi fi -if test "$wxUSE_LIBLZMA" = "no" -a "$wxUSE_LIBTIFF" = "builtin"; then - ac_configure_args="$ac_configure_args --disable-lzma" +if test "$wxUSE_LIBTIFF" = "builtin"; then + ac_configure_args="$ac_configure_args --disable-webp --disable-zstd" + if test "$wxUSE_LIBLZMA" = "no"; then + ac_configure_args="$ac_configure_args --disable-lzma" + fi fi diff --git a/configure.in b/configure.in index 1159b013c6..2c91781ff0 100644 --- a/configure.in +++ b/configure.in @@ -2585,12 +2585,15 @@ if test "$wxUSE_LIBLZMA" != "no"; then fi fi -dnl We need to disable the use of lzma in built-in libtiff explicitly, as -dnl otherwise we'd depend on the system lzma library, which is typically -dnl undesirable when using builtin libraries. We also disable the use of lzma -dnl if it's not available anyhow, just to speed up libtiff configure a little. -if test "$wxUSE_LIBLZMA" = "no" -a "$wxUSE_LIBTIFF" = "builtin"; then - ac_configure_args="$ac_configure_args --disable-lzma" +dnl Disable the use of lzma, webp and zstd in built-in libtiff explicitly, as +dnl otherwise we'd depend on the system libraries, which is typically +dnl undesirable when using builtin libraries. If we use lzma ourselves, keep it +dnl enabled. +if test "$wxUSE_LIBTIFF" = "builtin"; then + ac_configure_args="$ac_configure_args --disable-webp --disable-zstd" + if test "$wxUSE_LIBLZMA" = "no"; then + ac_configure_args="$ac_configure_args --disable-lzma" + fi fi dnl ------------------------------------------------------------------------ diff --git a/demos/bombs/game.h b/demos/bombs/game.h index 0f062c6027..0463ddfd25 100644 --- a/demos/bombs/game.h +++ b/demos/bombs/game.h @@ -27,17 +27,17 @@ public: { m_width = m_height = 0; m_field = NULL; - }; + } ~BombsGame(); - int GetWidth() const { return m_width; }; - int GetHeight() const { return m_height; }; + int GetWidth() const { return m_width; } + int GetHeight() const { return m_height; } int Get(int x, int y) const { return m_field[x+y*m_width]; - }; + } int IsFocussed(int x, int y) const { @@ -47,42 +47,42 @@ public: int IsHidden(int x, int y) const { return Get(x,y) & BG_HIDDEN; - }; + } int IsMarked(int x, int y) const { return Get(x,y) & BG_MARKED; - }; + } int IsBomb(int x, int y) const { return Get(x,y) & BG_BOMB; - }; + } int IsExploded(int x, int y) const { return Get(x,y) & BG_EXPLODED; - }; + } int IsSelected(int x, int y) const { return Get(x,y) & BG_SELECTED; - }; + } int GetNumBombs() const { return m_numBombCells; - }; + } int GetNumRemainingCells() const { return m_numRemainingCells; - }; + } int GetNumMarkedCells() const { return m_numMarkedCells; - }; + } bool Init(int width, int height, bool easyCorner = false); diff --git a/demos/forty/card.cpp b/demos/forty/card.cpp index 316c49361b..6b08cf850e 100644 --- a/demos/forty/card.cpp +++ b/demos/forty/card.cpp @@ -165,7 +165,7 @@ void Card::Draw(wxDC& dc, int x, int y) if (m_wayUp == facedown) { dc.SetBackground(* wxRED_BRUSH); - dc.SetBackgroundMode(wxSOLID); + dc.SetBackgroundMode(wxBRUSHSTYLE_SOLID); wxBrush* brush = wxTheBrushList->FindOrCreateBrush( *wxBLACK, wxBRUSHSTYLE_CROSSDIAG_HATCH ); @@ -183,7 +183,7 @@ void Card::Draw(wxDC& dc, int x, int y) memoryDC.SelectObject(*m_symbolBmap); -// dc.SetBackgroundMode(wxTRANSPARENT); +// dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); dc.SetTextBackground(*wxWHITE); switch (m_suit) diff --git a/demos/forty/card.h b/demos/forty/card.h index bb64d279dc..65c8f854ba 100644 --- a/demos/forty/card.h +++ b/demos/forty/card.h @@ -43,7 +43,7 @@ class Card { public: Card(int value, WayUp way_up = facedown); - virtual ~Card(){}; + virtual ~Card(){} void Draw(wxDC& pDC, int x, int y); static void DrawNullCard(wxDC& pDC, int x, int y); // Draw card place-holder @@ -55,9 +55,9 @@ public: Suit GetSuit() const { return m_suit; } SuitColour GetColour() const { return m_colour; } static void SetScale(double scale); - static int GetHeight() { return m_height; }; - static int GetWidth() { return m_width; }; - static double GetScale() { return m_scale; }; + static int GetHeight() { return m_height; } + static int GetWidth() { return m_width; } + static double GetScale() { return m_scale; } private: Suit m_suit; diff --git a/demos/forty/forty.h b/demos/forty/forty.h index 815514d0a5..6753b19417 100644 --- a/demos/forty/forty.h +++ b/demos/forty/forty.h @@ -38,7 +38,7 @@ class FortyFrame: public wxFrame { public: FortyFrame(wxFrame* frame, const wxString& title, const wxPoint& pos, const wxSize& size, bool largecards); - virtual ~FortyFrame(){}; + virtual ~FortyFrame(){} void OnCloseWindow(wxCloseEvent& event); diff --git a/demos/forty/game.cpp b/demos/forty/game.cpp index 894077e8b7..c99ba72ba9 100644 --- a/demos/forty/game.cpp +++ b/demos/forty/game.cpp @@ -795,7 +795,7 @@ void Pack::Redraw(wxDC& dc) wxString str; str.Printf(wxT("%d "), m_topCard + 1); - dc.SetBackgroundMode( wxSOLID ); + dc.SetBackgroundMode( wxBRUSHSTYLE_SOLID ); dc.SetTextBackground(FortyApp::BackgroundColour()); dc.SetTextForeground(FortyApp::TextColour()); dc.DrawText(str, m_x + CardWidth + 5, m_y + CardHeight / 2); diff --git a/demos/forty/pile.h b/demos/forty/pile.h index 21f35ba08b..3aeb517bc7 100644 --- a/demos/forty/pile.h +++ b/demos/forty/pile.h @@ -41,7 +41,7 @@ const int NumCards = 2 * PackSize; class Pile { public: Pile(int x, int y, int dx = 0, int dy = 0); - virtual ~Pile(){}; + virtual ~Pile(){} // General functions virtual void ResetPile() { m_topCard = -1; } @@ -68,7 +68,7 @@ public: virtual bool AcceptCard(Card*) { return false; } virtual void AddCard(Card* card); // Add card to top of pile virtual void AddCard(wxDC& pDC, Card* card); // Add card + redraw it - void SetPos(int x,int y) {m_x = x;m_y = y;}; + void SetPos(int x,int y) {m_x = x;m_y = y;} protected: int m_x, m_y; // Position of the pile on the screen diff --git a/demos/forty/playerdg.h b/demos/forty/playerdg.h index 59836ae141..1be65322e5 100644 --- a/demos/forty/playerdg.h +++ b/demos/forty/playerdg.h @@ -16,7 +16,7 @@ class PlayerSelectionDialog : public wxDialog { public: PlayerSelectionDialog(wxWindow* parent, ScoreFile* file); - virtual ~PlayerSelectionDialog(){}; + virtual ~PlayerSelectionDialog(){} const wxString& GetPlayersName(); void ButtonCallback(wxCommandEvent& event); diff --git a/demos/forty/scoredg.h b/demos/forty/scoredg.h index 1b1c7d2ba3..06a3b69ef4 100644 --- a/demos/forty/scoredg.h +++ b/demos/forty/scoredg.h @@ -16,7 +16,7 @@ class ScoreDialog : public wxDialog { public: ScoreDialog(wxWindow* parent, ScoreFile* file); - virtual ~ScoreDialog(){}; + virtual ~ScoreDialog(){} void Display(); diff --git a/demos/life/game.cpp b/demos/life/game.cpp index 62440bd53b..b509a259f5 100644 --- a/demos/life/game.cpp +++ b/demos/life/game.cpp @@ -925,7 +925,7 @@ class LifeModule: public wxModule wxDECLARE_DYNAMIC_CLASS(LifeModule); public: - LifeModule() {}; + LifeModule() {} bool OnInit() wxOVERRIDE; void OnExit() wxOVERRIDE; }; diff --git a/demos/life/game.h b/demos/life/game.h index 6fbf1fedd6..35e28a74e0 100644 --- a/demos/life/game.h +++ b/demos/life/game.h @@ -29,7 +29,7 @@ public: m_description = description; m_rules = rules; m_shape = shape; - }; + } // A more convenient ctor for the built-in samples LifePattern(wxString name, @@ -58,7 +58,7 @@ public: m_shape.Add( tmp ); } - }; + } wxString m_name; wxString m_description; @@ -90,9 +90,9 @@ public: ~Life(); // accessors - inline wxUint32 GetNumCells() const { return m_numcells; }; - inline wxString GetRules() const { return m_rules; }; - inline wxString GetDescription() const { return m_description; }; + inline wxUint32 GetNumCells() const { return m_numcells; } + inline wxString GetRules() const { return m_rules; } + inline wxString GetDescription() const { return m_description; } bool IsAlive(wxInt32 x, wxInt32 y); void SetCell(wxInt32 x, wxInt32 y, bool alive = true); void SetPattern(const LifePattern &pattern); diff --git a/demos/life/life.cpp b/demos/life/life.cpp index c36e9c99d9..60f14a40ca 100644 --- a/demos/life/life.cpp +++ b/demos/life/life.cpp @@ -534,7 +534,7 @@ void LifeFrame::OnNavigate(wxCommandEvent& event) case ID_CENTER: c = m_life->FindCenter(); break; default : wxFAIL; - // Fall through! + wxFALLTHROUGH; case ID_ORIGIN: c.i = c.j = 0; break; } diff --git a/demos/life/life.h b/demos/life/life.h index 1d4d2f1f0a..b2144f5170 100644 --- a/demos/life/life.h +++ b/demos/life/life.h @@ -31,7 +31,7 @@ public: virtual ~LifeCanvas(); // view management - int GetCellSize() const { return m_cellsize; }; + int GetCellSize() const { return m_cellsize; } void SetCellSize(int cellsize); void Recenter(wxInt32 i, wxInt32 j); @@ -54,10 +54,10 @@ private: void OnEraseBackground(wxEraseEvent& event); // conversion between cell and screen coordinates - inline wxInt32 XToCell(wxCoord x) const { return (x / m_cellsize) + m_viewportX; }; - inline wxInt32 YToCell(wxCoord y) const { return (y / m_cellsize) + m_viewportY; }; - inline wxCoord CellToX(wxInt32 i) const { return (i - m_viewportX) * m_cellsize; }; - inline wxCoord CellToY(wxInt32 j) const { return (j - m_viewportY) * m_cellsize; }; + inline wxInt32 XToCell(wxCoord x) const { return (x / m_cellsize) + m_viewportX; } + inline wxInt32 YToCell(wxCoord y) const { return (y / m_cellsize) + m_viewportY; } + inline wxCoord CellToX(wxInt32 i) const { return (i - m_viewportX) * m_cellsize; } + inline wxCoord CellToY(wxInt32 j) const { return (j - m_viewportY) * m_cellsize; } // what is the user doing? enum MouseStatus diff --git a/demos/life/reader.h b/demos/life/reader.h index 4480af5ed1..4ae6e33a76 100644 --- a/demos/life/reader.h +++ b/demos/life/reader.h @@ -22,14 +22,14 @@ class LifeReader public: LifeReader(wxInputStream& is); - inline bool IsOk() const { return m_ok; }; - inline wxString GetDescription() const { return m_description; }; - inline wxString GetRules() const { return m_rules; }; - inline wxArrayString GetShape() const { return m_shape; }; + inline bool IsOk() const { return m_ok; } + inline wxString GetDescription() const { return m_description; } + inline wxString GetRules() const { return m_rules; } + inline wxArrayString GetShape() const { return m_shape; } inline LifePattern GetPattern() const { return LifePattern(wxEmptyString, m_description, m_rules, m_shape); - }; + } private: bool m_ok; diff --git a/demos/poem/wxpoem.cpp b/demos/poem/wxpoem.cpp index 36206c8753..9f24e2566a 100644 --- a/demos/poem/wxpoem.cpp +++ b/demos/poem/wxpoem.cpp @@ -168,7 +168,7 @@ void MainWindow::ScanBuffer(wxDC *dc, bool DrawIt, int *max_x, int *max_y) dc->SetBrush(*wxLIGHT_GREY_BRUSH); dc->SetPen(*wxGREY_PEN); dc->DrawRectangle(0, 0, width, height); - dc->SetBackgroundMode(wxTRANSPARENT); + dc->SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); } // See what ACTUAL char height is @@ -686,6 +686,8 @@ void MyCanvas::OnChar(wxKeyEvent& event) case WXK_ESCAPE: TheMainWindow->Close(true); + break; + default: break; } diff --git a/docs/changes.txt b/docs/changes.txt index 25d36877e0..57a5769bcc 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -54,6 +54,12 @@ Changes in behaviour not resulting in compilation errors - wxEVT_AUINOTEBOOK_PAGE_CHANGED event is now sent after changing the page, as expected, and not before doing it. +- wxJoystickEvent::GetButtonChange() now returns "1 << N" for the events + generated by the button number N under all platforms, whereas it used to + return just "N" under Linux and macOS. Use the new GetButtonOrdinal() to + update the existing code if necessary. + + Changes in behaviour which may result in build errors ----------------------------------------------------- @@ -109,6 +115,7 @@ All: - Avoid spurious errors on thread creation under NetBSD. - Improve high DPI support in wxAui (Simon Rozman). - Fix a bug with parsing time zones in wxDateTime::ParseFormat() (evileye). +- Update all 3rd party libraries to their latest versions (Maarten Bent). All (GUI): @@ -131,6 +138,11 @@ All (GUI): - Add wxGrid::SetCornerLabelValue() (Pavel Kalugin). - Add strikethrough support for fonts defined in XRC. - Add wxDisplay::GetPPI(). +- Add wxJoystickEvent::GetButtonOrdinal() (Mick Phillips). +- Add wxGraphicsContext::GetWindow() and implement wxGraphicsContext::GetDPI(). +- Add wxToolbook::EnablePage() (Stefan Ziegler). +- Adapt AUI colours to system colour changes (Daniel Kulp). +- Fix removing and inserting pages in wxToolbook (Stefan Ziegler). wxGTK: @@ -141,6 +153,7 @@ wxGTK: - Fix the build with glib < 2.32 (e.g. CentOS 6). - Fix field widths in wxStatusBar showing a size grip. - Fill column value in wxEVT_DATAVIEW_ITEM_ACTIVATED events. +- Implement wxDataViewCtrl::GetItemRect() (MrMeesek). wxMSW: @@ -158,14 +171,16 @@ wxMSW: - Improve wxNotebook themed background drawing (Arrigo Marchiori). - Send wxEVT_WEBVIEW_NAVIGATING when redirecting (Josue Andrade Gomes). - Fix build with MSVS 2005 broken in 3.1.1. +- Add wxwidgets.props property sheet file for MSVS users. wxOSX: - Fix dispatching pending events (and CallAfter()) in console applications. - Implement wxDataViewColumn::UnsetAsSortKey() (Daniel Kulp). -- supporting native image formst like NSImage and UIImage in wxBitmap -- native implementation for wxStaticBitmap for correct rendering of template images +- Change wxBitmap to use native image format like NSImage and UIImage. +- Implement wxStaticBitmap natively for correct rendering of template images. - Fill column value in wxEVT_DATAVIEW_ITEM_ACTIVATED events (Igor Korot). +- Make wxFrame::EnableFullScreenView() work under macOS 10.11+ (Andy Robinson). wxQt: diff --git a/docs/contributing/how-to-update-third-party-library.md b/docs/contributing/how-to-update-third-party-library.md index ad9dde29bd..0736502714 100644 --- a/docs/contributing/how-to-update-third-party-library.md +++ b/docs/contributing/how-to-update-third-party-library.md @@ -42,7 +42,14 @@ one: $ git push --set-upstream git@github.com:wxWidgets/libexpat.git wx -3. Updating the main repository +3. Generating build files (libexpat, libtiff) +--------------------------------------------- + +We include the generated build files of libexpat and libtiff. For libexpat run +`buildconf.sh`. For libtiff run `autogen.sh`. Commit the changes. + + +4. Updating the main repository ------------------------------- If there are any changes to the source files used by the library, update the @@ -54,7 +61,7 @@ manually. Commit these changes and the submodule and create a PR to test them as usual. -4. Special instructions for libpng +5. Special instructions for libpng ---------------------------------- We use a special hack for libpng as we want to prefix all its symbols with diff --git a/docs/doxygen/overviews/commondialogs.h b/docs/doxygen/overviews/commondialogs.h index 5a69090d3d..e1affa2f63 100644 --- a/docs/doxygen/overviews/commondialogs.h +++ b/docs/doxygen/overviews/commondialogs.h @@ -78,7 +78,7 @@ if (dialog.ShowModal() == wxID_OK) { wxColourData retData = dialog.GetColourData(); wxColour col = retData.GetColour(); - wxBrush brush(col, wxSOLID); + wxBrush brush(col, wxBRUSHSTYLE_SOLID); myWindow->SetBackground(brush); myWindow->Clear(); myWindow->Refresh(); diff --git a/docs/msw/install.md b/docs/msw/install.md index 2399ffbbe2..d06c5c10e2 100644 --- a/docs/msw/install.md +++ b/docs/msw/install.md @@ -271,7 +271,7 @@ debugger is very good. To avoid linker errors you will need to add The version 5.6 included in Borland C++ Builder 2006 works as well after the following small change: please remove the test for `__WINDOWS__` from line 88 -of the file BCCDIR\include\stl\_threads.h. +of the file `BCCDIR\include\stl\_threads.h`. Compiling using the makefiles: @@ -505,6 +505,10 @@ The full list of the build settings follows: Building Applications Using wxWidgets {#msw_build_apps} ===================================== +If you use MSVS 2010 or later IDE for building your project, simply add +`wxwidgets.props` property sheet to (all) your project(s) using wxWidgets. +You don't need to do anything else. + If you want to use CMake for building your project, please see @ref overview_cmake. @@ -535,11 +539,11 @@ Here is what you need to do: be used for debug builds only. * Define the following symbols for the preprocessor: - `__WXMSW__` to ensure you use the correct wxWidgets port. - - _UNICODE unless you want to use deprecated ANSI build of wxWidgets. - - NDEBUG if you want to build in release mode, i.e. disable asserts. - - WXUSINGDLL if you are using DLL build of wxWidgets. + - `_UNICODE` unless you want to use deprecated ANSI build of wxWidgets. + - `NDEBUG` if you want to build in release mode, i.e. disable asserts. + - `WXUSINGDLL` if you are using DLL build of wxWidgets. * If using MSVC 7 only (i.e. not for later versions), also define - wxUSE_RC_MANIFEST=1 and WX_CPU_X86. + `wxUSE_RC_MANIFEST=1` and `WX_CPU_X86`. * Add \ directory described above to the libraries path. When using MSVC, the libraries are linked automatically using "#pragma diff --git a/include/wx/aui/auibar.h b/include/wx/aui/auibar.h index 2ee3c02d24..274757d88e 100644 --- a/include/wx/aui/auibar.h +++ b/include/wx/aui/auibar.h @@ -344,6 +344,10 @@ public: virtual int ShowDropDown( wxWindow* wnd, const wxAuiToolBarItemArray& items) = 0; + + // Provide opportunity for subclasses to recalculate colours + virtual void UpdateColoursFromSystem() {} + }; @@ -429,6 +433,8 @@ public: virtual int ShowDropDown(wxWindow* wnd, const wxAuiToolBarItemArray& items) wxOVERRIDE; + virtual void UpdateColoursFromSystem() wxOVERRIDE; + protected: wxBitmap m_buttonDropDownBmp; @@ -651,6 +657,7 @@ protected: // handlers void OnLeaveWindow(wxMouseEvent& evt); void OnCaptureLost(wxMouseCaptureLostEvent& evt); void OnSetCursor(wxSetCursorEvent& evt); + void OnSysColourChanged(wxSysColourChangedEvent& event); protected: diff --git a/include/wx/aui/auibook.h b/include/wx/aui/auibook.h index c6d232e48d..2571f7d9ac 100644 --- a/include/wx/aui/auibook.h +++ b/include/wx/aui/auibook.h @@ -226,6 +226,7 @@ protected: void OnKillFocus(wxFocusEvent& event); void OnChar(wxKeyEvent& event); void OnCaptureLost(wxMouseCaptureLostEvent& evt); + void OnSysColourChanged(wxSysColourChangedEvent& event); protected: @@ -408,6 +409,7 @@ protected: void OnTabRightUp(wxAuiNotebookEvent& evt); void OnTabBgDClick(wxAuiNotebookEvent& evt); void OnNavigationKeyNotebook(wxNavigationKeyEvent& event); + void OnSysColourChanged(wxSysColourChangedEvent& event); // set selection to the given window (which must be non-NULL and be one of // our pages, otherwise an assert is raised) diff --git a/include/wx/aui/dockart.h b/include/wx/aui/dockart.h index 48ee31bc25..bb931d7acc 100644 --- a/include/wx/aui/dockart.h +++ b/include/wx/aui/dockart.h @@ -76,6 +76,9 @@ public: int buttonState, const wxRect& rect, wxAuiPaneInfo& pane) = 0; + + // Provide opportunity for subclasses to recalculate colours + virtual void UpdateColoursFromSystem() {} }; @@ -136,6 +139,9 @@ public: wxAuiPaneInfo& pane); #endif + virtual void UpdateColoursFromSystem() wxOVERRIDE; + + protected: void DrawCaptionBackground(wxDC& dc, const wxRect& rect, bool active); diff --git a/include/wx/aui/framemanager.h b/include/wx/aui/framemanager.h index a21fdf9ce7..eccc6603c1 100644 --- a/include/wx/aui/framemanager.h +++ b/include/wx/aui/framemanager.h @@ -616,6 +616,7 @@ protected: void OnChildFocus(wxChildFocusEvent& evt); void OnHintFadeTimer(wxTimerEvent& evt); void OnFindManager(wxAuiManagerEvent& evt); + void OnSysColourChanged(wxSysColourChangedEvent& event); protected: diff --git a/include/wx/aui/tabart.h b/include/wx/aui/tabart.h index 47efe359e3..f11e75b4ba 100644 --- a/include/wx/aui/tabart.h +++ b/include/wx/aui/tabart.h @@ -109,6 +109,9 @@ public: wxWindow* wnd, const wxAuiNotebookPageArray& pages, const wxSize& requiredBmpSize) = 0; + + // Provide opportunity for subclasses to recalculate colours + virtual void UpdateColoursFromSystem() {} }; @@ -185,6 +188,9 @@ public: const wxAuiNotebookPageArray& pages, const wxSize& requiredBmpSize) wxOVERRIDE; + // Provide opportunity for subclasses to recalculate colours + virtual void UpdateColoursFromSystem() wxOVERRIDE; + protected: wxFont m_normalFont; diff --git a/include/wx/combo.h b/include/wx/combo.h index 9e26ddd318..2ba9780a2d 100644 --- a/include/wx/combo.h +++ b/include/wx/combo.h @@ -455,7 +455,7 @@ public: enum { Hidden = 0, - //Closing = 1, + Closing = 1, Animating = 2, Visible = 3 }; diff --git a/include/wx/display.h b/include/wx/display.h index af299a74e0..1c3a67298a 100644 --- a/include/wx/display.h +++ b/include/wx/display.h @@ -49,6 +49,10 @@ public: // primary display and the only one which is always supported wxDisplay(unsigned n = 0); + // create display object corresponding to the display of the given window + // or the default one if the window display couldn't be found + explicit wxDisplay(const wxWindow* window); + // dtor is not virtual as this is a concrete class not meant to be derived // from diff --git a/include/wx/dynarray.h b/include/wx/dynarray.h index 84a65cbce6..a8684e7999 100644 --- a/include/wx/dynarray.h +++ b/include/wx/dynarray.h @@ -215,9 +215,11 @@ public: // cannot handle types with size greater than pointer because of sorting // ---------------------------------------------------------------------------- -#define _WX_DEFINE_SORTED_TYPEARRAY_2(T, name, base, defcomp, classexp) \ +// Note that "classdecl" here is intentionally not used because this class has +// only inline methods and so never needs to be exported from a DLL. +#define _WX_DEFINE_SORTED_TYPEARRAY_2(T, name, base, defcomp, classdecl) \ typedef wxBaseSortedArray wxBaseSortedArrayFor##name; \ - classexp name : public wxBaseSortedArrayFor##name \ + class name : public wxBaseSortedArrayFor##name \ { \ public: \ name(wxBaseSortedArrayFor##name::SCMPFUNC fn defcomp) \ diff --git a/include/wx/event.h b/include/wx/event.h index d2b7a5d932..20f08b1ae2 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -15,6 +15,7 @@ #include "wx/cpp.h" #include "wx/object.h" #include "wx/clntdata.h" +#include "wx/math.h" #if wxUSE_GUI #include "wx/gdicmn.h" @@ -2760,6 +2761,7 @@ public: int GetZPosition() const { return m_zPosition; } int GetButtonState() const { return m_buttonState; } int GetButtonChange() const { return m_buttonChange; } + int GetButtonOrdinal() const { return wxCTZ(m_buttonChange); } int GetJoystick() const { return m_joyStick; } void SetJoystick(int stick) { m_joyStick = stick; } diff --git a/include/wx/generic/dataview.h b/include/wx/generic/dataview.h index aff77abd29..815dfcb75b 100644 --- a/include/wx/generic/dataview.h +++ b/include/wx/generic/dataview.h @@ -409,7 +409,7 @@ class WXDLLIMPEXP_CORE wxDataViewCtrlAccessible: public wxWindowAccessible { public: wxDataViewCtrlAccessible(wxDataViewCtrl* win); - virtual ~wxDataViewCtrlAccessible() {}; + virtual ~wxDataViewCtrlAccessible() {} virtual wxAccStatus HitTest(const wxPoint& pt, int* childId, wxAccessible** childObject) wxOVERRIDE; diff --git a/include/wx/generic/headerctrlg.h b/include/wx/generic/headerctrlg.h index 8a2a84ca1c..b145f1cbe2 100644 --- a/include/wx/generic/headerctrlg.h +++ b/include/wx/generic/headerctrlg.h @@ -98,6 +98,10 @@ private: // column 1 but close enough to the divider separating it from column 0) unsigned int FindColumnAtPoint(int x, bool *onSeparator = NULL) const; + // return the result of FindColumnAtPoint() if it is a valid column, + // otherwise the index of the last (rightmost) displayed column + unsigned int FindColumnClosestToPoint(int xPhysical) const; + // return true if a drag resizing operation is currently in progress bool IsResizing() const; diff --git a/include/wx/generic/spinctlg.h b/include/wx/generic/spinctlg.h index 7f5b5de50a..c3d2e9eef5 100644 --- a/include/wx/generic/spinctlg.h +++ b/include/wx/generic/spinctlg.h @@ -403,7 +403,7 @@ public: // We don't implement bases support for floating point numbers, this is not // very useful in practice. virtual int GetBase() const wxOVERRIDE { return 10; } - virtual bool SetBase(int WXUNUSED(base)) wxOVERRIDE { return 0; } + virtual bool SetBase(int WXUNUSED(base)) wxOVERRIDE { return false; } protected: virtual void DoSendEvent() wxOVERRIDE; diff --git a/include/wx/graphics.h b/include/wx/graphics.h index 9141d39450..a35667491f 100644 --- a/include/wx/graphics.h +++ b/include/wx/graphics.h @@ -452,7 +452,7 @@ private: class WXDLLIMPEXP_CORE wxGraphicsContext : public wxGraphicsObject { public: - wxGraphicsContext(wxGraphicsRenderer* renderer); + wxGraphicsContext(wxGraphicsRenderer* renderer, wxWindow* window = NULL); virtual ~wxGraphicsContext(); @@ -490,6 +490,9 @@ public: // create a context that can be used for measuring texts only, no drawing allowed static wxGraphicsContext * Create(); + // Return the window this context is associated with, if any. + wxWindow* GetWindow() const { return m_window; } + // begin a new document (relevant only for printing / pdf etc) if there is a progress dialog, message will be shown virtual bool StartDoc( const wxString& message ); @@ -788,6 +791,12 @@ protected: wxDouble angle, const wxGraphicsBrush& backgroundBrush); +private: + // The associated window, if any, i.e. if one was passed directly to + // Create() or the associated window of the wxDC this context was created + // from. + wxWindow* const m_window; + wxDECLARE_NO_COPY_CLASS(wxGraphicsContext); wxDECLARE_ABSTRACT_CLASS(wxGraphicsContext); }; diff --git a/include/wx/html/htmlcell.h b/include/wx/html/htmlcell.h index 083ebd8e63..5276a7b601 100644 --- a/include/wx/html/htmlcell.h +++ b/include/wx/html/htmlcell.h @@ -17,6 +17,7 @@ #include "wx/html/htmltag.h" #include "wx/html/htmldefs.h" #include "wx/window.h" +#include "wx/brush.h" class WXDLLIMPEXP_FWD_HTML wxHtmlWindowInterface; @@ -81,7 +82,7 @@ enum wxHtmlSelectionState class WXDLLIMPEXP_HTML wxHtmlRenderingState { public: - wxHtmlRenderingState() : m_selState(wxHTML_SEL_OUT) { m_bgMode = wxSOLID; } + wxHtmlRenderingState() : m_selState(wxHTML_SEL_OUT) { m_bgMode = wxBRUSHSTYLE_SOLID; } void SetSelectionState(wxHtmlSelectionState s) { m_selState = s; } wxHtmlSelectionState GetSelectionState() const { return m_selState; } diff --git a/include/wx/math.h b/include/wx/math.h index 544b5c7d6e..261969d364 100644 --- a/include/wx/math.h +++ b/include/wx/math.h @@ -150,6 +150,9 @@ inline int wxRound(double x) inline double wxDegToRad(double deg) { return (deg * M_PI) / 180.0; } inline double wxRadToDeg(double rad) { return (rad * 180.0) / M_PI; } +// Count trailing zeros. +WXDLLIMPEXP_BASE unsigned int wxCTZ(wxUint32 x); + #endif /* __cplusplus */ diff --git a/include/wx/msw/textctrl.h b/include/wx/msw/textctrl.h index 4fe3a470e6..5ef3128a7c 100644 --- a/include/wx/msw/textctrl.h +++ b/include/wx/msw/textctrl.h @@ -290,9 +290,6 @@ private: // false if we hit the limit set by SetMaxLength() and so didn't change it. bool AdjustSpaceLimit(); - wxDECLARE_EVENT_TABLE(); - wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxTextCtrl); - wxMenu* m_privateContextMenu; bool m_isNativeCaretShown; @@ -301,6 +298,8 @@ private: int m_isInkEdit; #endif + wxDECLARE_EVENT_TABLE(); + wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxTextCtrl); }; #endif // _WX_TEXTCTRL_H_ diff --git a/include/wx/msw/webview_ie.h b/include/wx/msw/webview_ie.h index f1e7773f89..3a4f042c16 100644 --- a/include/wx/msw/webview_ie.h +++ b/include/wx/msw/webview_ie.h @@ -157,7 +157,6 @@ private: wxIEContainer* m_container; wxAutomationObject m_ie; IWebBrowser2* m_webBrowser; - DWORD m_dwCookie; wxCOMPtr m_uiHandler; //We store the current zoom type; diff --git a/include/wx/odcombo.h b/include/wx/odcombo.h index 622e51a748..7fe4cddd8a 100644 --- a/include/wx/odcombo.h +++ b/include/wx/odcombo.h @@ -192,7 +192,7 @@ protected: private: // Cached item widths (in pixels). - wxArrayInt m_widths; + wxVector m_widths; // Width of currently widest item. int m_widestWidth; diff --git a/include/wx/osx/bitmap.h b/include/wx/osx/bitmap.h index 4252da9f9c..65255198e9 100644 --- a/include/wx/osx/bitmap.h +++ b/include/wx/osx/bitmap.h @@ -47,13 +47,8 @@ public: // Construct a mask from a mono bitmap (black meaning show pixels, white meaning transparent) wxMask(const wxBitmap& bitmap); - // implementation helper only : construct a mask from a 32 bit memory buffer - wxMask(const wxMemoryBuffer& buf, int width , int height , int bytesPerRow ) ; - virtual ~wxMask(); - bool Create(const wxMemoryBuffer& buf, int width , int height , int bytesPerRow ) ; - wxBitmap GetBitmap() const; // Implementation below @@ -71,6 +66,9 @@ public: WXHBITMAP GetHBITMAP() const ; + // implementation helper only : construct a mask from a 32 bit memory buffer + bool OSXCreate(const wxMemoryBuffer& buf, int width , int height , int bytesPerRow ) ; + protected: // this function is called from Create() to free the existing mask data virtual void FreeData() wxOVERRIDE; diff --git a/include/wx/private/display.h b/include/wx/private/display.h index 1cd7bae8d0..9a97a75f9c 100644 --- a/include/wx/private/display.h +++ b/include/wx/private/display.h @@ -81,8 +81,11 @@ public: // return the depth or 0 if unknown virtual int GetDepth() const = 0; - // return the resolution of the display, uses GetSizeMM() by default but - // can be also overridden directly + // return the scale factor used to convert logical pixels to physical ones + virtual double GetScaleFactor() const { return 1.0; } + + // return the resolution of the display, uses GetSize(), GetScaleFactor() + // and GetSizeMM() by default but can be also overridden directly virtual wxSize GetPPI() const; // return the physical size of the display or (0, 0) if unknown: this is @@ -115,6 +118,11 @@ protected: // create the object providing access to the display with the given index wxDisplayImpl(unsigned n) : m_index(n) { } + // Compute PPI from the sizes in pixels and mm. + // + // Return (0, 0) if physical size (in mm) is not known, i.e. 0. + static wxSize ComputePPI(int pxX, int pxY, int mmX, int mmY); + // the index of this display (0 is always the primary one) const unsigned m_index; diff --git a/include/wx/propgrid/property.h b/include/wx/propgrid/property.h index d93595cf0e..77d8c4b09a 100644 --- a/include/wx/propgrid/property.h +++ b/include/wx/propgrid/property.h @@ -2019,7 +2019,7 @@ protected: wxVariant m_value; wxPGAttributeStorage m_attributes; - wxArrayPGProperty m_children; + wxVector m_children; // Extended cell information wxVector m_cells; diff --git a/include/wx/propgrid/propgriddefs.h b/include/wx/propgrid/propgriddefs.h index 5dcc6cd973..6eebf00177 100644 --- a/include/wx/propgrid/propgriddefs.h +++ b/include/wx/propgrid/propgriddefs.h @@ -547,7 +547,7 @@ expdecl classname& classname##RefFromVariant( wxVariant& variant ) \ wxString::Format(wxS("Variant type should have been '%s'") \ wxS("instead of '%s'"), \ wxS(#classname), \ - variant.GetType().c_str())); \ + variant.GetType())); \ classname##VariantData *data = \ (classname##VariantData*) variant.GetData(); \ return data->GetValue();\ @@ -558,7 +558,7 @@ expdecl const classname& classname##RefFromVariant( const wxVariant& variant ) \ wxString::Format(wxS("Variant type should have been '%s'") \ wxS("instead of '%s'"), \ wxS(#classname), \ - variant.GetType().c_str())); \ + variant.GetType())); \ classname##VariantData *data = \ (classname##VariantData*) variant.GetData(); \ return data->GetValue();\ @@ -699,6 +699,67 @@ protected: #define WX_PG_TOKENIZER2_END() \ } +// ----------------------------------------------------------------------- +// wxVector utilities + +// Utility to check if specific item is in a vector. +template +inline bool wxPGItemExistsInVector(const wxVector& vector, const T& item) +{ +#if wxUSE_STL + return std::find(vector.begin(), vector.end(), item) != vector.end(); +#else + for (typename wxVector::const_iterator it = vector.begin(); it != vector.end(); ++it) + { + if ( *it == item ) + return true; + } + return false; +#endif // wxUSE_STL/!wxUSE_STL +} + +// Utility to determine the index of the item in the vector. +template +inline int wxPGItemIndexInVector(const wxVector& vector, const T& item) +{ +#if wxUSE_STL + typename wxVector::const_iterator it = std::find(vector.begin(), vector.end(), item); + if ( it != vector.end() ) + return (int)(it - vector.begin()); + + return wxNOT_FOUND; +#else + for (typename wxVector::const_iterator it = vector.begin(); it != vector.end(); ++it) + { + if ( *it == item ) + return (int)(it - vector.begin()); + } + return wxNOT_FOUND; +#endif // wxUSE_STL/!wxUSE_STL +} + +// Utility to remove given item from the vector. +template +inline void wxPGRemoveItemFromVector(wxVector& vector, const T& item) +{ +#if wxUSE_STL + typename wxVector::iterator it = std::find(vector.begin(), vector.end(), item); + if ( it != vector.end() ) + { + vector.erase(it); + } +#else + for (typename wxVector::iterator it = vector.begin(); it != vector.end(); ++it) + { + if ( *it == item ) + { + vector.erase(it); + return; + } + } +#endif // wxUSE_STL/!wxUSE_STL +} + // ----------------------------------------------------------------------- #endif // wxUSE_PROPGRID diff --git a/include/wx/qt/anybutton.h b/include/wx/qt/anybutton.h index 1d07bc5b3b..f8cc359f97 100644 --- a/include/wx/qt/anybutton.h +++ b/include/wx/qt/anybutton.h @@ -26,11 +26,12 @@ public: // -------------- virtual void SetLabel( const wxString &label ); - virtual void DoSetBitmap(const wxBitmap& bitmap, State which); virtual QWidget *GetHandle() const; protected: + virtual wxBitmap DoGetBitmap(State state) const wxOVERRIDE; + virtual void DoSetBitmap(const wxBitmap& bitmap, State which) wxOVERRIDE; QPushButton *m_qtPushButton; @@ -39,6 +40,7 @@ protected: private: typedef wxAnyButtonBase base_type; + wxBitmap m_bitmap; wxDECLARE_NO_COPY_CLASS(wxAnyButton); }; diff --git a/include/wx/qt/checkbox.h b/include/wx/qt/checkbox.h index 6bb328de70..82a28ec14f 100644 --- a/include/wx/qt/checkbox.h +++ b/include/wx/qt/checkbox.h @@ -32,6 +32,9 @@ public: virtual void SetValue(bool value); virtual bool GetValue() const; + virtual void SetLabel(const wxString& label) wxOVERRIDE; + virtual wxString GetLabel() const wxOVERRIDE; + virtual QWidget *GetHandle() const; protected: diff --git a/include/wx/qt/menu.h b/include/wx/qt/menu.h index b8d5abca52..f6d52bb3e2 100644 --- a/include/wx/qt/menu.h +++ b/include/wx/qt/menu.h @@ -44,6 +44,7 @@ public: virtual wxMenu *Remove(size_t pos); virtual void EnableTop(size_t pos, bool enable); + virtual bool IsEnabledTop(size_t pos) const wxOVERRIDE; virtual void SetMenuLabel(size_t pos, const wxString& label); virtual wxString GetMenuLabel(size_t pos) const; diff --git a/include/wx/qt/stattext.h b/include/wx/qt/stattext.h index 36f8628aae..513bae3479 100644 --- a/include/wx/qt/stattext.h +++ b/include/wx/qt/stattext.h @@ -30,7 +30,8 @@ public: long style = 0, const wxString &name = wxStaticTextNameStr ); - void SetLabel(const wxString& label); + virtual void SetLabel(const wxString& label) wxOVERRIDE; + virtual wxString GetLabel() const wxOVERRIDE; virtual QWidget *GetHandle() const; diff --git a/include/wx/toolbook.h b/include/wx/toolbook.h index ecd703cfc2..fd868226cb 100644 --- a/include/wx/toolbook.h +++ b/include/wx/toolbook.h @@ -92,6 +92,10 @@ public: // get the underlying toolbar wxToolBarBase* GetToolBar() const { return (wxToolBarBase*)m_bookctrl; } + // enable/disable a page + bool EnablePage(wxWindow *page, bool enable); + bool EnablePage(size_t page, bool enable); + // must be called in OnIdle or by application to realize the toolbar and // select the initial page. void Realize(); @@ -119,6 +123,14 @@ private: // common part of all constructors void Init(); + // returns the tool identifier for the specified page + int PageToToolId(size_t page) const; + + // returns the page index for the specified tool ID or + // wxNOT_FOUND if there is no page with that tool ID + int ToolIdToPage(int toolId) const; + + wxDECLARE_EVENT_TABLE(); wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxToolbook); }; diff --git a/include/wx/translation.h b/include/wx/translation.h index 3d5d5b0b83..9b931a088a 100644 --- a/include/wx/translation.h +++ b/include/wx/translation.h @@ -145,6 +145,12 @@ public: wxString GetBestTranslation(const wxString& domain, const wxString& msgIdLanguage = "en"); + // find best and all other suitable translation languages for given domain + wxArrayString GetAcceptableTranslations(const wxString& domain, + wxLanguage msgIdLanguage); + wxArrayString GetAcceptableTranslations(const wxString& domain, + const wxString& msgIdLanguage = "en"); + // add standard wxWidgets catalog ("wxstd") bool AddStdCatalog(); diff --git a/include/wx/valnum.h b/include/wx/valnum.h index 3f9be1d99c..2e05bc6b15 100644 --- a/include/wx/valnum.h +++ b/include/wx/valnum.h @@ -228,10 +228,16 @@ private: // wxNUM_VAL_ZERO_AS_BLANK flag. wxString NormalizeValue(LongestValueType value) const { + // We really want to compare with the exact 0 here, so disable gcc + // warning about doing this. + wxGCC_WARNING_SUPPRESS(float-equal) + wxString s; if ( value != 0 || !BaseValidator::HasFlag(wxNUM_VAL_ZERO_AS_BLANK) ) s = this->ToString(value); + wxGCC_WARNING_RESTORE(float-equal) + return s; } diff --git a/interface/wx/bitmap.h b/interface/wx/bitmap.h index 9f0405e5b5..c20aa7725e 100644 --- a/interface/wx/bitmap.h +++ b/interface/wx/bitmap.h @@ -712,9 +712,6 @@ public: Sets the depth member (does not affect the bitmap data). - @todo since these functions do not affect the bitmap data, - why they exist?? - @param depth Bitmap depth. diff --git a/interface/wx/dataview.h b/interface/wx/dataview.h index 84c7479df8..00a8069f06 100644 --- a/interface/wx/dataview.h +++ b/interface/wx/dataview.h @@ -1446,8 +1446,14 @@ public: int GetIndent() const; /** - Returns item rectangle. Coordinates of the rectangle are specified in - wxDataViewCtrl client area coordinates. + Returns item rectangle. + + If item is not currently visible, either because its parent is + collapsed or it is outside of the visible part of the control due to + the current vertical scrollbar position, return an empty rectangle. + + Coordinates of the rectangle are specified in wxDataViewCtrl client + area coordinates. @param item A valid item. @@ -1455,10 +1461,6 @@ public: If non-@NULL, the rectangle returned corresponds to the intersection of the item with the specified column. If @NULL, the rectangle spans all the columns. - - @note This method is currently not implemented at all in wxGTK and only - implemented for non-@NULL @a col argument in wxOSX. It is fully - implemented in the generic version of the control. */ virtual wxRect GetItemRect(const wxDataViewItem& item, const wxDataViewColumn* col = NULL) const; @@ -1556,6 +1558,9 @@ public: /** Return @true if the item is expanded. + + @note When using the native macOS version this method has a bug which + may result in returning @true even for items without children. */ virtual bool IsExpanded(const wxDataViewItem& item) const; diff --git a/interface/wx/display.h b/interface/wx/display.h index 1a3ca71450..3c4e28f4bb 100644 --- a/interface/wx/display.h +++ b/interface/wx/display.h @@ -26,6 +26,23 @@ public: */ wxDisplay(unsigned int index = 0); + /** + Constructor creating the display object associated with the given + window. + + This is the most convenient way of finding the display on which the + given window is shown while falling back to the default display if it + is not shown at all or positioned outside of any display. + + @param window + A valid, i.e. non-null, window. + + @see GetFromWindow() + + @since 3.1.2 + */ + explicit wxDisplay(const wxWindow* window); + /** Destructor. */ diff --git a/interface/wx/event.h b/interface/wx/event.h index b58fdc4a3c..061ba76201 100644 --- a/interface/wx/event.h +++ b/interface/wx/event.h @@ -1741,10 +1741,24 @@ public: /** Returns the identifier of the button changing state. - This is a @c wxJOY_BUTTONn identifier, where @c n is one of 1, 2, 3, 4. + The return value is @code 1 << n @endcode where @c n is the index of the + button changing state, which can also be retrieved using GetButtonOrdinal(). + + Note that for @c n equal to 1, 2, 3 or 4 there are predefined @c wxJOY_BUTTONn + constants which can be used for more clarity, however these constants are not + defined for the buttons beyond the first four. */ int GetButtonChange() const; + /** + Returns the 0-indexed ordinal of the button changing state. + + @see GetButtonChange() + + @since 3.1.2. + */ + int GetButtonOrdinal() const; + /** Returns the down state of the buttons. diff --git a/interface/wx/graphics.h b/interface/wx/graphics.h index 2e1bd40477..5154ec19ba 100644 --- a/interface/wx/graphics.h +++ b/interface/wx/graphics.h @@ -1095,6 +1095,19 @@ public: */ virtual void GetDPI( wxDouble* dpiX, wxDouble* dpiY); + /** + Returns the associated window if any. + + If this context was created using Create() overload taking wxWindow or + wxWindowDC, this method returns the corresponding window. Otherwise + returns @NULL. + + @return A possibly @NULL window pointer. + + @since 3.1.2 + */ + wxWindow* GetWindow() const; + /** @} */ diff --git a/interface/wx/grid.h b/interface/wx/grid.h index 1546607b5d..0c3eef3d24 100644 --- a/interface/wx/grid.h +++ b/interface/wx/grid.h @@ -987,7 +987,7 @@ public: */ void SetTextColour(const wxColour& colText); - + void MergeWith(wxGridCellAttr *mergefrom); void SetSize(int num_rows, int num_cols); @@ -2319,7 +2319,7 @@ public: wxPen MidiGrid::GetRowGridLinePen(int row) { if ( row % 12 == 7 ) - return wxPen(*wxBLACK, 1, wxSOLID); + return wxPen(*wxBLACK, 1, wxPENSTYLE_SOLID); else return GetDefaultGridLinePen(); } @@ -4551,7 +4551,7 @@ public: */ void SetRowAttr(int row, wxGridCellAttr* attr); - + wxArrayInt CalcRowLabelsExposed( const wxRegion& reg ); wxArrayInt CalcColLabelsExposed( const wxRegion& reg ); wxGridCellCoordsArray CalcCellsExposed( const wxRegion& reg ); @@ -4697,7 +4697,7 @@ public: virtual void DrawCellHighlight( wxDC& dc, const wxGridCellAttr *attr ); - + virtual void DrawRowLabels( wxDC& dc, const wxArrayInt& rows ); virtual void DrawRowLabel( wxDC& dc, int row ); @@ -4722,9 +4722,9 @@ public: void SetCellHighlightColour( const wxColour& ); void SetCellHighlightPenWidth(int width); - void SetCellHighlightROPenWidth(int width); + void SetCellHighlightROPenWidth(int width); + - protected: /** Returns @true if this grid has support for cell attributes. diff --git a/interface/wx/math.h b/interface/wx/math.h index ca11a9fff2..b1486c270c 100644 --- a/interface/wx/math.h +++ b/interface/wx/math.h @@ -75,6 +75,19 @@ double wxDegToRad(double deg); */ double wxRadToDeg(double rad); +/** + Count the number of trailing zeros. + + This function returns the number of trailing zeros in the binary notation + of its argument @a x. E.g. for @a x equal to 4, or 0b100, the return value + is 2. + + @param x Strictly positive, i.e. non-zero, 32 bit number. + + @since 3.1.2 + */ +unsigned int wxCTZ(wxUint32 x); + /** Small wrapper around round(). */ diff --git a/interface/wx/toolbook.h b/interface/wx/toolbook.h index 08d1f45991..ad8447d386 100644 --- a/interface/wx/toolbook.h +++ b/interface/wx/toolbook.h @@ -23,6 +23,9 @@ wxEventType wxEVT_TOOLBOOK_PAGE_CHANGING; refer to that class documentation for now. You can also use the @ref page_samples_notebook to see wxToolbook in action. + One feature of this class not supported by wxBookCtrlBase is the support + for disabling some of the pages, see EnablePage(). + @beginStyleTable @style{wxTBK_BUTTONBAR} Use wxButtonToolBar-based implementation under OS X (ignored under @@ -82,5 +85,44 @@ public: Returns the wxToolBarBase associated with the control. */ wxToolBarBase* GetToolBar() const; + + /** + Enables or disables the specified page. + + Using this function, a page can be disabled when it can't be used, while + still remaining present to let the users know that more functionality is + available, even if currently inaccessible. + + Icons for disabled pages are created by wxBitmap::ConvertToDisabled(). + + @param page + The index of the page. + @param enable + @true to enable the page and @false to disable it. + + @return @true if successful, @false otherwise (currently only if the + index is invalid). + + @since 3.1.2 + */ + bool EnablePage(size_t page, bool enable); + + /** + Enables or disables the specified page. + + This is similar to the overload above, but finds the index of the + specified page. + + @param page + Pointer of a page windows inside the book control. + @param enable + @true to enable the page and @false to disable it. + + @return @true if successful, @false otherwise, e.g. if @a page is not + one of the pages of this control. + + @since 3.1.2 + */ + bool EnablePage(wxWindow *page, bool enable); }; diff --git a/interface/wx/translation.h b/interface/wx/translation.h index eed6355d0b..23ca5128c7 100644 --- a/interface/wx/translation.h +++ b/interface/wx/translation.h @@ -137,6 +137,34 @@ public: const wxString& msgIdLanguage = "en"); /** + Returns the languages of all translations that can be used for the @a + domain. + + This is a more general version of GetBestTranslation(), which returns + the whole list of preferred UI languages for which a translation for + the @a domain was found instead of just the first, i.e. the most + preferred, element of this list. + + @param domain + The catalog domain to look for. + + @param msgIdLanguage + Specifies the language of "msgid" strings in source code (i.e. + arguments to GetString(), wxGetTranslation() and the _() macro). + + @return An array of language codes if any suitable matches were found, + empty array otherwise. + + @since 3.1.2 + */ + wxArrayString GetAcceptableTranslations(const wxString& domain, + wxLanguage msgIdLanguage); + + /// @overload + wxArrayString GetAcceptableTranslations(const wxString& domain, + const wxString& msgIdLanguage = "en"); + + /** Add standard wxWidgets catalogs ("wxstd" and possible port-specific catalogs). @@ -147,9 +175,10 @@ public: bool AddStdCatalog(); /** - Add a catalog for use with the current locale. + Add a catalog for the preferred UI language. In case of multiple + preferences, add catalog for each language, if available. - By default, it is searched for in standard places (see + By default, the catalog is searched for in standard places (see wxFileTranslationsLoader), but you may also prepend additional directories to the search path with wxFileTranslationsLoader::AddCatalogLookupPathPrefix(). @@ -173,8 +202,9 @@ public: code are used instead. @return - @true if catalog was successfully loaded, @false otherwise (which might - mean that the catalog is not found or that it isn't in the correct format). + @true if catalog in the most preferred language was successfully loaded, + @false otherwise (which might mean that the catalog is not found or that + it isn't in the correct format). */ bool AddCatalog(const wxString& domain, wxLanguage msgIdLanguage = wxLANGUAGE_ENGLISH_US); @@ -200,8 +230,9 @@ public: in case they use 8-bit characters (e.g. German or French strings). @return - @true if catalog was successfully loaded, @false otherwise (which might - mean that the catalog is not found or that it isn't in the correct format). + @true if catalog in the most preferred language was successfully loaded, + @false otherwise (which might mean that the catalog is not found or that + it isn't in the correct format). */ bool AddCatalog(const wxString& domain, wxLanguage msgIdLanguage, diff --git a/misc/gdb/print.py b/misc/gdb/print.py index 28d47d6276..8408087ad7 100755 --- a/misc/gdb/print.py +++ b/misc/gdb/print.py @@ -14,6 +14,20 @@ # in wxLookupFunction at the bottom of this file. import datetime +import gdb +import itertools +import sys + +if sys.version_info[0] > 2: + # Python 3 + Iterator = object + + long = int +else: + # Python 2, we need to make an adaptor, so we can use Python 3 iterator implementations. + class Iterator: + def next(self): + return self.__next__() # shamelessly stolen from std::string example class wxStringPrinter: @@ -26,6 +40,41 @@ class wxStringPrinter: def display_hint(self): return 'string' +class wxArrayStringPrinter: + + class _iterator(Iterator): + def __init__ (self, firstItem, count): + self.item = firstItem + self.count = count + self.current = 0 + + def __iter__(self): + return self + + def __next__(self): + current = self.current + self.current = self.current + 1 + + if current == self.count: + raise StopIteration + elt = self.item.dereference() + self.item = self.item + 1 + return ('[%d]' % current, elt) + + def __init__(self, val): + self.val = val + + def children(self): + return self._iterator(self.val['m_pItems'], self.val['m_nCount']) + + def to_string(self): + count = self.val['m_nCount'] + capacity = self.val['m_nSize'] + return ('length %d, capacity %d' % (int (count), int (capacity))) + + def display_hint(self): + return 'array' + class wxDateTimePrinter: def __init__(self, val): self.val = val @@ -81,6 +130,7 @@ def wxLookupFunction(val): # Using a list is probably ok for so few items but consider switching to a # set (or a dict and cache class types as the keys in it?) if needed later. types = ['wxString', + 'wxArrayString', 'wxDateTime', 'wxFileName', 'wxPoint', diff --git a/samples/artprov/artbrows.cpp b/samples/artprov/artbrows.cpp index 93e0f9f638..ea0b9944da 100644 --- a/samples/artprov/artbrows.cpp +++ b/samples/artprov/artbrows.cpp @@ -126,8 +126,14 @@ static void FillBitmaps(wxImageList *images, wxListCtrl *list, #include "null.xpm" +const int SIZE_CHOICE_ID = ::wxNewId(); + +// Bitmap sizes that can be chosen in the size selection wxChoice. +static const int bitmapSizes[] = { -1, 16, 32, 64, 128, 256, 0 }; + wxBEGIN_EVENT_TABLE(wxArtBrowserDialog, wxDialog) EVT_LIST_ITEM_SELECTED(wxID_ANY, wxArtBrowserDialog::OnSelectItem) + EVT_CHOICE(SIZE_CHOICE_ID, wxArtBrowserDialog::OnChangeSize) EVT_CHOICE(wxID_ANY, wxArtBrowserDialog::OnChooseClient) wxEND_EVENT_TABLE() @@ -136,6 +142,8 @@ wxArtBrowserDialog::wxArtBrowserDialog(wxWindow *parent) wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER) { + m_currentArtId = wxART_ERROR; + wxSizer *sizer = new wxBoxSizer(wxVERTICAL); wxSizer *subsizer; @@ -152,16 +160,28 @@ wxArtBrowserDialog::wxArtBrowserDialog(wxWindow *parent) m_list = new wxListCtrl(this, wxID_ANY, wxDefaultPosition, wxSize(250, 300), wxLC_REPORT | wxSUNKEN_BORDER); m_list->AppendColumn("wxArtID"); - subsizer->Add(m_list, 1, wxEXPAND | wxRIGHT, 10); + subsizer->Add(m_list, 0, wxEXPAND | wxRIGHT, 10); wxSizer *subsub = new wxBoxSizer(wxVERTICAL); + + m_sizes = new wxChoice( this, SIZE_CHOICE_ID ); + for ( const int* p = bitmapSizes; *p; ++p ) + { + if ( *p == -1 ) + m_sizes->Append( "Default" ); + else + m_sizes->Append( wxString::Format("%d x %d", *p, *p ) ); + } + m_sizes->SetSelection(0); + subsub->Add(m_sizes, 0, wxALL, 4); + m_text = new wxStaticText(this, wxID_ANY, "Size: 333x333"); - subsub->Add(m_text); + subsub->Add(m_text, 0, wxALL, 4); m_canvas = new wxStaticBitmap(this, wxID_ANY, wxBitmap(null_xpm)); subsub->Add(m_canvas); - subsub->Add(100, 100); - subsizer->Add(subsub); + subsub->Add(256, 256); + subsizer->Add(subsub, 1, wxLEFT, 4 ); sizer->Add(subsizer, 1, wxEXPAND | wxLEFT|wxRIGHT, 10); @@ -176,6 +196,13 @@ wxArtBrowserDialog::wxArtBrowserDialog(wxWindow *parent) } +wxSize wxArtBrowserDialog::GetSelectedBitmapSize() const +{ + const int size = bitmapSizes[m_sizes->GetSelection()]; + return wxSize(size, size); +} + + void wxArtBrowserDialog::SetArtClient(const wxArtClient& client) { wxBusyCursor bcur; @@ -201,7 +228,13 @@ void wxArtBrowserDialog::SetArtClient(const wxArtClient& client) void wxArtBrowserDialog::OnSelectItem(wxListEvent &event) { const char *data = (const char*)event.GetData(); - SetArtBitmap(data, m_client, wxDefaultSize); + m_currentArtId = wxString( data ); + SetArtBitmap(data, m_client, GetSelectedBitmapSize()); +} + +void wxArtBrowserDialog::OnChangeSize(wxCommandEvent& WXUNUSED(event)) +{ + SetArtBitmap(m_currentArtId, m_client, GetSelectedBitmapSize() ); } void wxArtBrowserDialog::OnChooseClient(wxCommandEvent &event) diff --git a/samples/artprov/artbrows.h b/samples/artprov/artbrows.h index 977dce30f3..e1dbb093b5 100644 --- a/samples/artprov/artbrows.h +++ b/samples/artprov/artbrows.h @@ -28,12 +28,17 @@ public: private: void OnSelectItem(wxListEvent &event); + void OnChangeSize(wxCommandEvent &event); void OnChooseClient(wxCommandEvent &event); + wxSize GetSelectedBitmapSize() const; + wxListCtrl *m_list; wxStaticBitmap *m_canvas; wxStaticText *m_text; wxString m_client; + wxChoice *m_sizes; + wxString m_currentArtId; wxDECLARE_EVENT_TABLE(); }; diff --git a/samples/calendar/calendar.cpp b/samples/calendar/calendar.cpp index 14e1f616bd..54f02275d2 100644 --- a/samples/calendar/calendar.cpp +++ b/samples/calendar/calendar.cpp @@ -625,7 +625,7 @@ void MyFrame::OnCalRClick(wxMouseEvent& event) { default: wxFAIL_MSG( "unexpected" ); - // fall through + wxFALLTHROUGH; case wxCAL_HITTEST_NOWHERE: msg += "nowhere"; diff --git a/samples/caret/caret.cpp b/samples/caret/caret.cpp index 7de956c71c..70f7e69591 100644 --- a/samples/caret/caret.cpp +++ b/samples/caret/caret.cpp @@ -479,7 +479,7 @@ void MyCanvas::OnChar( wxKeyEvent &event ) wxCaretSuspend cs(this); wxClientDC dc(this); dc.SetFont(m_font); - dc.SetBackgroundMode(wxSOLID); // overwrite old value + dc.SetBackgroundMode(wxBRUSHSTYLE_SOLID); // overwrite old value dc.DrawText(ch, m_xMargin + m_xCaret * m_widthChar, m_yMargin + m_yCaret * m_heightChar ); diff --git a/samples/combo/combo.cpp b/samples/combo/combo.cpp index c489504194..fded5d1a18 100644 --- a/samples/combo/combo.cpp +++ b/samples/combo/combo.cpp @@ -1017,14 +1017,14 @@ void MyFrame::OnShowComparison( wxCommandEvent& WXUNUSED(event) ) groupSizer->AddStretchSpacer(); // - // Disabled ODComboBox - groupSizer->Add( new wxStaticText(dlg,wxID_ANY,"Disabled:"), + // Disabled read-only ODComboBox + groupSizer->Add( new wxStaticText(dlg,wxID_ANY,"Read-only disabled:"), wxSizerFlags().Border(wxRIGHT, border) ); odc = new wxOwnerDrawnComboBox(dlg,wxID_ANY,wxEmptyString, wxDefaultPosition, wxDefaultSize, m_arrItems, - wxCB_SORT|wxCB_READONLY // wxNO_BORDER|wxCB_READONLY + wxCB_READONLY // wxNO_BORDER|wxCB_READONLY ); odc->SetValue("Dot Dash"); @@ -1032,6 +1032,18 @@ void MyFrame::OnShowComparison( wxCommandEvent& WXUNUSED(event) ) groupSizer->Add( odc, wxSizerFlags(3).Expand().Border(wxALL, border) ); + // Disabled ODComboBox + groupSizer->Add(new wxStaticText(dlg, wxID_ANY, "Disabled:"), + wxSizerFlags().Border(wxRIGHT, border)); + + odc = new wxOwnerDrawnComboBox(dlg, wxID_ANY, wxEmptyString, + wxDefaultPosition, wxDefaultSize, m_arrItems); + + odc->SetValue("Dot Dash"); + odc->Enable(false); + + groupSizer->Add(odc, wxSizerFlags(3).Expand().Border(wxALL, border)); + rowSizer->Add( groupSizer, 1, wxEXPAND|wxALL, border ); @@ -1077,14 +1089,14 @@ void MyFrame::OnShowComparison( wxCommandEvent& WXUNUSED(event) ) groupSizer->AddStretchSpacer(); // - // Disabled wxComboBox - groupSizer->Add( new wxStaticText(dlg,wxID_ANY,"Disabled:"), + // Disabled read-only wxComboBox + groupSizer->Add( new wxStaticText(dlg,wxID_ANY,"Read-only disabled:"), wxSizerFlags().Border(wxRIGHT, border) ); cb = new wxComboBox(dlg,wxID_ANY,wxEmptyString, wxDefaultPosition, wxDefaultSize, m_arrItems, - wxCB_SORT|wxCB_READONLY // wxNO_BORDER|wxCB_READONLY + wxCB_READONLY // wxNO_BORDER|wxCB_READONLY ); cb->SetValue("Dot Dash"); @@ -1092,6 +1104,19 @@ void MyFrame::OnShowComparison( wxCommandEvent& WXUNUSED(event) ) groupSizer->Add( cb, wxSizerFlags(3).Expand().Border(wxALL, border) ); + // + // Disabled wxComboBox + groupSizer->Add(new wxStaticText(dlg, wxID_ANY, "Disabled:"), + wxSizerFlags().Border(wxRIGHT, border)); + + cb = new wxComboBox(dlg, wxID_ANY, wxEmptyString, + wxDefaultPosition, wxDefaultSize, m_arrItems); + + cb->SetValue("Dot Dash"); + cb->Enable(false); + + groupSizer->Add(cb, wxSizerFlags(3).Expand().Border(wxALL, border)); + rowSizer->Add( groupSizer, 1, wxEXPAND|wxALL, border ); colSizer->Add( rowSizer, 1, wxEXPAND|wxALL, border ); diff --git a/samples/dataview/mymodels.cpp b/samples/dataview/mymodels.cpp index ae40acb021..fcffc59d69 100644 --- a/samples/dataview/mymodels.cpp +++ b/samples/dataview/mymodels.cpp @@ -525,6 +525,7 @@ bool MyListModel::GetAttrByRow( unsigned int row, unsigned int col, return true; } } + wxFALLTHROUGH; case Col_Custom: // do what the labels defined in GetValueByRow() hint at diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index 011ca273c9..578bb940ce 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -3080,7 +3080,7 @@ void MyFrame::OnFindDialog(wxFindDialogEvent& event) void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event) ) { wxPaintDC dc(this); - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); dc.DrawText( "wxWidgets common dialogs" " test application" @@ -3707,6 +3707,7 @@ long TestMessageBoxDialog::GetStyle() { case MsgDlgIcon_Max: wxFAIL_MSG( "unexpected selection" ); + wxFALLTHROUGH; case MsgDlgIcon_No: break; diff --git a/samples/display/display.cpp b/samples/display/display.cpp index 7996eac945..ed5420d147 100644 --- a/samples/display/display.cpp +++ b/samples/display/display.cpp @@ -232,9 +232,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, #endif // wxUSE_STATUSBAR // create child controls - wxPanel *panel = new wxPanel(this, wxID_ANY); - - m_book = new wxBookCtrl(panel, wxID_ANY); + m_book = new wxBookCtrl(this, wxID_ANY); const size_t countDpy = wxDisplay::GetCount(); for ( size_t nDpy = 0; nDpy < countDpy; nDpy++ ) { @@ -291,6 +289,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, sizer->Add(new wxStaticText(page, wxID_ANY, display.IsPrimary() ? "yes" : "no")); + // add it to another sizer to have borders around it and button below wxSizer *sizerTop = new wxBoxSizer(wxVERTICAL); sizerTop->Add(sizer, 1, wxALL | wxEXPAND, 10); @@ -313,22 +312,19 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, sizer->Add(new wxStaticText(page, Display_CurrentMode, VideoModeToText(display.GetCurrentMode()))); - // add it to another sizer to have borders around it and button below sizerTop->Add(new wxButton(page, Display_ResetMode, "&Reset mode"), 0, wxALL | wxCENTRE, 5); #endif // wxUSE_DISPLAY page->SetSizer(sizerTop); + page->Layout(); m_book->AddPage(page, wxString::Format("Display %lu", (unsigned long)nDpy)); } - wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL); - sizer->Add(m_book, 1, wxEXPAND); - panel->SetSizer(sizer); - sizer->SetSizeHints(this); + SetClientSize(m_book->GetBestSize()); } #if wxUSE_DISPLAY diff --git a/samples/dll/sdk_exe.cpp b/samples/dll/sdk_exe.cpp index b090eb6afc..7e5c127029 100644 --- a/samples/dll/sdk_exe.cpp +++ b/samples/dll/sdk_exe.cpp @@ -82,8 +82,6 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) default: return DefWindowProc(hwnd, msg, wParam, lParam); } - - return 0; } // ---------------------------------------------------------------------------- diff --git a/samples/dragimag/dragimag.h b/samples/dragimag/dragimag.h index c30bd3edba..ca4034a996 100644 --- a/samples/dragimag/dragimag.h +++ b/samples/dragimag/dragimag.h @@ -122,7 +122,7 @@ class DragShape: public wxObject { public: DragShape(const wxBitmap& bitmap); - ~DragShape(){}; + ~DragShape(){} //// Operations diff --git a/samples/drawing/drawing.cpp b/samples/drawing/drawing.cpp index b9da4ce65a..2b266b9231 100644 --- a/samples/drawing/drawing.cpp +++ b/samples/drawing/drawing.cpp @@ -461,6 +461,10 @@ bool MyApp::OnInit() if ( !wxApp::OnInit() ) return false; +#if wxUSE_LIBPNG + wxImage::AddHandler( new wxPNGHandler ); +#endif + // Create the main application window MyFrame *frame = new MyFrame("Drawing sample", wxDefaultPosition, wxSize(550, 840)); @@ -477,9 +481,6 @@ bool MyApp::OnInit() // still continue, the sample can be used without images too if they're // missing for whatever reason } -#if wxUSE_LIBPNG - wxImage::AddHandler( new wxPNGHandler ); -#endif return true; } @@ -895,7 +896,7 @@ void MyCanvas::DrawText(wxDC& dc) dc.SetFont( *wxSWISS_FONT ); wxString text; - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); for ( int n = -180; n < 180; n += 30 ) { @@ -2196,7 +2197,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) m_yLogicalOrigin = 0; m_xAxisReversed = m_yAxisReversed = false; - m_backgroundMode = wxSOLID; + m_backgroundMode = wxBRUSHSTYLE_SOLID; m_colourForeground = *wxBLACK; m_colourBackground = *wxLIGHT_GREY; m_textureBackground = false; @@ -2462,8 +2463,9 @@ void MyFrame::OnOption(wxCommandEvent& event) #endif // wxUSE_COLOURDLG case Colour_BackgroundMode: - m_backgroundMode = m_backgroundMode == wxSOLID ? wxTRANSPARENT - : wxSOLID; + m_backgroundMode = m_backgroundMode == wxBRUSHSTYLE_SOLID + ? wxBRUSHSTYLE_TRANSPARENT + : wxBRUSHSTYLE_SOLID; break; case Colour_TextureBackgound: diff --git a/samples/erase/erase.cpp b/samples/erase/erase.cpp index 5336bfe155..c48026dc9d 100644 --- a/samples/erase/erase.cpp +++ b/samples/erase/erase.cpp @@ -178,7 +178,7 @@ private: dc.DrawRectangle(GetClientSize()); dc.SetTextForeground(*wxBLUE); - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); dc.DrawText(m_message, 0, 2); // Draw some bitmap/icon to ensure transparent bitmaps are indeed @@ -436,7 +436,7 @@ void MyCanvas::OnEraseBackground( wxEraseEvent& event ) } dc.SetTextForeground(*wxRED); - dc.SetBackgroundMode(wxSOLID); + dc.SetBackgroundMode(wxBRUSHSTYLE_SOLID); dc.DrawText("This text is drawn from OnEraseBackground", 60, 160); } diff --git a/samples/exec/exec.cpp b/samples/exec/exec.cpp index ae5ed8f8ed..130bdcc780 100644 --- a/samples/exec/exec.cpp +++ b/samples/exec/exec.cpp @@ -627,7 +627,7 @@ void MyFrame::OnKill(wxCommandEvent& WXUNUSED(event)) { default: wxFAIL_MSG( "unexpected return value" ); - // fall through + wxFALLTHROUGH; case -1: // cancelled diff --git a/samples/image/image.cpp b/samples/image/image.cpp index 949619960e..819da2578f 100644 --- a/samples/image/image.cpp +++ b/samples/image/image.cpp @@ -802,7 +802,7 @@ void MyFrame::OnImageInfo( wxCommandEvent &WXUNUSED(event) ) { default: wxFAIL_MSG( "unknown image resolution units" ); - // fall through + wxFALLTHROUGH; case wxIMAGE_RESOLUTION_NONE: info += " in default units"; diff --git a/samples/ipc/baseclient.cpp b/samples/ipc/baseclient.cpp index a3f139987e..c958ed91cb 100644 --- a/samples/ipc/baseclient.cpp +++ b/samples/ipc/baseclient.cpp @@ -78,7 +78,7 @@ public: bool Connect(const wxString& sHost, const wxString& sService, const wxString& sTopic); void Disconnect(); wxConnectionBase *OnMakeConnection() wxOVERRIDE; - bool IsConnected() { return m_connection != NULL; }; + bool IsConnected() { return m_connection != NULL; } virtual void Notify() wxOVERRIDE; diff --git a/samples/ipc/baseserver.cpp b/samples/ipc/baseserver.cpp index 47a29085ce..8c58305f9f 100644 --- a/samples/ipc/baseserver.cpp +++ b/samples/ipc/baseserver.cpp @@ -113,7 +113,7 @@ public: MyServer(); virtual ~MyServer(); void Disconnect(); - bool IsConnected() { return m_connection != NULL; }; + bool IsConnected() { return m_connection != NULL; } virtual wxConnectionBase *OnAcceptConnection(const wxString& topic) wxOVERRIDE; diff --git a/samples/ipc/client.h b/samples/ipc/client.h index 8e44ffe546..7c1d58b207 100644 --- a/samples/ipc/client.h +++ b/samples/ipc/client.h @@ -31,7 +31,7 @@ class MyApp: public wxApp public: virtual bool OnInit() wxOVERRIDE; virtual int OnExit() wxOVERRIDE; - MyFrame *GetFrame() { return m_frame; }; + MyFrame *GetFrame() { return m_frame; } protected: MyFrame *m_frame; @@ -96,8 +96,8 @@ public: bool Connect(const wxString& sHost, const wxString& sService, const wxString& sTopic); void Disconnect(); wxConnectionBase *OnMakeConnection() wxOVERRIDE; - bool IsConnected() { return m_connection != NULL; }; - MyConnection *GetConnection() { return m_connection; }; + bool IsConnected() { return m_connection != NULL; } + MyConnection *GetConnection() { return m_connection; } protected: MyConnection *m_connection; diff --git a/samples/joytest/joytest.cpp b/samples/joytest/joytest.cpp index dd62713eec..c355d05fe6 100644 --- a/samples/joytest/joytest.cpp +++ b/samples/joytest/joytest.cpp @@ -159,7 +159,7 @@ void MyCanvas::OnJoystickEvent(wxJoystickEvent& event) #if wxUSE_STATUSBAR wxString buf; if (event.ButtonDown()) - buf.Printf("Joystick (%ld, %ld) #%i Fire!", xpos, ypos, event.GetButtonChange()); + buf.Printf("Joystick (%ld, %ld) #%i Fire!", xpos, ypos, event.GetButtonOrdinal()); else buf.Printf("Joystick (%ld, %ld) ", xpos, ypos); diff --git a/samples/joytest/joytest.h b/samples/joytest/joytest.h index 59d4afb5e2..76876e2e4d 100644 --- a/samples/joytest/joytest.h +++ b/samples/joytest/joytest.h @@ -44,7 +44,7 @@ public: MyCanvas *canvas; MyFrame(wxFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size, const long style); - ~MyFrame(){}; + ~MyFrame(){} void OnActivate(wxActivateEvent& event); void OnQuit(wxCommandEvent& event); diff --git a/samples/layout/layout.h b/samples/layout/layout.h index 40627037d1..fdfd4a0c5f 100644 --- a/samples/layout/layout.h +++ b/samples/layout/layout.h @@ -12,7 +12,7 @@ class MyApp: public wxApp { public: - MyApp(){}; + MyApp(){} bool OnInit() wxOVERRIDE; }; diff --git a/samples/nativdlg/nativdlg.h b/samples/nativdlg/nativdlg.h index 468b0ed2c9..732f881704 100644 --- a/samples/nativdlg/nativdlg.h +++ b/samples/nativdlg/nativdlg.h @@ -12,7 +12,7 @@ class MyApp: public wxApp { public: - MyApp(void){}; + MyApp(void){} bool OnInit(void) wxOVERRIDE; }; diff --git a/samples/opengl/pyramid/pyramid.h b/samples/opengl/pyramid/pyramid.h index aacce137a9..fdffd31455 100644 --- a/samples/opengl/pyramid/pyramid.h +++ b/samples/opengl/pyramid/pyramid.h @@ -14,7 +14,7 @@ class MyApp: public wxApp { public: - MyApp(){}; + MyApp(){} bool OnInit() wxOVERRIDE; }; diff --git a/samples/ownerdrw/ownerdrw.cpp b/samples/ownerdrw/ownerdrw.cpp index d82a3f0032..c1ae01437c 100644 --- a/samples/ownerdrw/ownerdrw.cpp +++ b/samples/ownerdrw/ownerdrw.cpp @@ -40,7 +40,7 @@ class OwnerDrawnFrame : public wxFrame public: // ctor & dtor OwnerDrawnFrame(wxFrame *frame, const wxString& title, int x, int y, int w, int h); - ~OwnerDrawnFrame(){}; + ~OwnerDrawnFrame(){} // notifications void OnQuit (wxCommandEvent& event); diff --git a/samples/power/power.cpp b/samples/power/power.cpp index 6c0f6454f0..59fdfc96ba 100644 --- a/samples/power/power.cpp +++ b/samples/power/power.cpp @@ -142,7 +142,7 @@ private: default: wxFAIL_MSG("unknown wxPowerType value"); - // fall through + wxFALLTHROUGH; case wxPOWER_UNKNOWN: powerStr = "psychic"; @@ -170,7 +170,7 @@ private: default: wxFAIL_MSG("unknown wxBatteryState value"); - // fall through + wxFALLTHROUGH; case wxBATTERY_UNKNOWN_STATE: batteryStr = "unknown"; diff --git a/samples/printing/printing.cpp b/samples/printing/printing.cpp index bfac9abd3a..682dac26c3 100644 --- a/samples/printing/printing.cpp +++ b/samples/printing/printing.cpp @@ -139,7 +139,7 @@ void MyApp::Draw(wxDC&dc) // dc.Clear(); dc.SetFont(m_testFont); - // dc.SetBackgroundMode(wxTRANSPARENT); + // dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); dc.SetPen(*wxBLACK_PEN); dc.SetBrush(*wxLIGHT_GREY_BRUSH); @@ -679,7 +679,7 @@ void MyPrintout::DrawPageTwo() dc->DrawLine(50, 250, (long)(50.0 + logUnits), 250); dc->DrawLine(50, 250, 50, (long)(250.0 + logUnits)); - dc->SetBackgroundMode(wxTRANSPARENT); + dc->SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); dc->SetBrush(*wxTRANSPARENT_BRUSH); { // GetTextExtent demo: diff --git a/samples/regtest/regtest.cpp b/samples/regtest/regtest.cpp index b97f627625..2004e34ce9 100644 --- a/samples/regtest/regtest.cpp +++ b/samples/regtest/regtest.cpp @@ -1074,8 +1074,7 @@ bool RegTreeCtrl::TreeNode::OnExpand() m_pKey->QueryValue(str, &l); strItem << l; } - - // fall through + wxFALLTHROUGH; default: icon = RegImageList::BinaryValue; diff --git a/samples/splitter/splitter.cpp b/samples/splitter/splitter.cpp index 08fd17f7c0..a91357af61 100644 --- a/samples/splitter/splitter.cpp +++ b/samples/splitter/splitter.cpp @@ -151,7 +151,7 @@ class MyCanvas: public wxScrolledWindow { public: MyCanvas(wxWindow* parent, bool mirror); - virtual ~MyCanvas(){}; + virtual ~MyCanvas(){} virtual void OnDraw(wxDC& dc) wxOVERRIDE; diff --git a/samples/stc/edit.h b/samples/stc/edit.h index 908990e757..703ebae395 100644 --- a/samples/stc/edit.h +++ b/samples/stc/edit.h @@ -112,7 +112,7 @@ public: wxString DeterminePrefs (const wxString &filename); bool InitializePrefs (const wxString &filename); bool UserSettings (const wxString &filename); - LanguageInfo const* GetLanguageInfo () {return m_language;}; + LanguageInfo const* GetLanguageInfo () {return m_language;} //! load/save file bool LoadFile (); @@ -120,8 +120,8 @@ public: bool SaveFile (); bool SaveFile (const wxString &filename); bool Modified (); - wxString GetFilename () {return m_filename;}; - void SetFilename (const wxString &filename) {m_filename = filename;}; + wxString GetFilename () {return m_filename;} + void SetFilename (const wxString &filename) {m_filename = filename;} private: // file diff --git a/samples/svg/svgtest.cpp b/samples/svg/svgtest.cpp index 26c5f9b323..b6bf13d681 100644 --- a/samples/svg/svgtest.cpp +++ b/samples/svg/svgtest.cpp @@ -342,7 +342,7 @@ void MyPage::OnDraw(wxDC& dc) wP = *wxCYAN_PEN; wP.SetWidth(3); dc.SetPen(wP); - //wxTRANSPARENT)); + //wxBRUSHSTYLE_TRANSPARENT)); dc.SetBrush (wxBrush ("SALMON")); dc.DrawEllipticArc(300, 0,200,100, 0.0,145.0); //same end point diff --git a/samples/thread/thread.cpp b/samples/thread/thread.cpp index 60c0f18005..7b3a706938 100644 --- a/samples/thread/thread.cpp +++ b/samples/thread/thread.cpp @@ -66,7 +66,7 @@ class MyApp : public wxApp { public: MyApp(); - virtual ~MyApp(){}; + virtual ~MyApp(){} virtual bool OnInit() wxOVERRIDE; diff --git a/samples/treectrl/treetest.h b/samples/treectrl/treetest.h index c615a483bc..99182002d0 100644 --- a/samples/treectrl/treetest.h +++ b/samples/treectrl/treetest.h @@ -67,7 +67,7 @@ public: MyTreeCtrl(wxWindow *parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style); - virtual ~MyTreeCtrl(){}; + virtual ~MyTreeCtrl(){} void OnBeginDrag(wxTreeEvent& event); void OnBeginRDrag(wxTreeEvent& event); diff --git a/samples/treelist/treelist.cpp b/samples/treelist/treelist.cpp index 0614f0ef84..b8a43a4039 100644 --- a/samples/treelist/treelist.cpp +++ b/samples/treelist/treelist.cpp @@ -695,7 +695,7 @@ void MyFrame::OnItemContextMenu(wxTreeListEvent& event) default: wxFAIL_MSG( "Unexpected menu selection" ); - // Fall through. + wxFALLTHROUGH; case wxID_NONE: return; diff --git a/samples/widgets/bmpcombobox.cpp b/samples/widgets/bmpcombobox.cpp index 56dd331fd8..bf7e7070a2 100644 --- a/samples/widgets/bmpcombobox.cpp +++ b/samples/widgets/bmpcombobox.cpp @@ -433,7 +433,7 @@ void BitmapComboBoxWidgetsPage::CreateCombo() { default: wxFAIL_MSG( "unknown combo kind" ); - // fall through + wxFALLTHROUGH; case ComboKind_Default: break; diff --git a/samples/widgets/button.cpp b/samples/widgets/button.cpp index 1275372a6d..98d9473a39 100644 --- a/samples/widgets/button.cpp +++ b/samples/widgets/button.cpp @@ -416,7 +416,7 @@ void ButtonWidgetsPage::CreateButton() default: wxFAIL_MSG("unexpected radiobox selection"); - // fall through + wxFALLTHROUGH; case ButtonHAlign_Centre: break; @@ -434,7 +434,7 @@ void ButtonWidgetsPage::CreateButton() default: wxFAIL_MSG("unexpected radiobox selection"); - // fall through + wxFALLTHROUGH; case ButtonVAlign_Centre: // centre vertical alignment is the default (no style) diff --git a/samples/widgets/checkbox.cpp b/samples/widgets/checkbox.cpp index 09893f3029..7e5c6720fd 100644 --- a/samples/widgets/checkbox.cpp +++ b/samples/widgets/checkbox.cpp @@ -259,7 +259,7 @@ void CheckBoxWidgetsPage::CreateCheckbox() { default: wxFAIL_MSG("unexpected radiobox selection"); - // fall through + wxFALLTHROUGH; case CheckboxKind_2State: flags |= wxCHK_2STATE; @@ -267,7 +267,7 @@ void CheckBoxWidgetsPage::CreateCheckbox() case CheckboxKind_3StateUser: flags |= wxCHK_ALLOW_3RD_STATE_FOR_USER; - // fall through + wxFALLTHROUGH; case CheckboxKind_3State: flags |= wxCHK_3STATE; diff --git a/samples/widgets/combobox.cpp b/samples/widgets/combobox.cpp index 57c031802b..6618ceff1a 100644 --- a/samples/widgets/combobox.cpp +++ b/samples/widgets/combobox.cpp @@ -431,7 +431,7 @@ void ComboboxWidgetsPage::CreateCombo() { default: wxFAIL_MSG( "unknown combo kind" ); - // fall through + wxFALLTHROUGH; case ComboKind_Default: break; diff --git a/samples/widgets/hyperlnk.cpp b/samples/widgets/hyperlnk.cpp index fb110f5a71..f71ad23a17 100644 --- a/samples/widgets/hyperlnk.cpp +++ b/samples/widgets/hyperlnk.cpp @@ -366,7 +366,7 @@ void HyperlinkWidgetsPage::OnAlignment(wxCommandEvent& WXUNUSED(event)) default: case Align_Max: wxFAIL_MSG( "unknown alignment" ); - // fall through + wxFALLTHROUGH; case Align_Left: addstyle = wxHL_ALIGN_LEFT; diff --git a/samples/widgets/notebook.cpp b/samples/widgets/notebook.cpp index 08c51f1f3c..598c19f848 100644 --- a/samples/widgets/notebook.cpp +++ b/samples/widgets/notebook.cpp @@ -343,7 +343,7 @@ void BookWidgetsPage::RecreateBook() { default: wxFAIL_MSG( "unknown orientation" ); - // fall through + wxFALLTHROUGH; case Orient_Top: flags |= wxBK_TOP; diff --git a/samples/widgets/radiobox.cpp b/samples/widgets/radiobox.cpp index 2745422475..2d109a51fe 100644 --- a/samples/widgets/radiobox.cpp +++ b/samples/widgets/radiobox.cpp @@ -376,7 +376,7 @@ void RadioWidgetsPage::CreateRadio() { default: wxFAIL_MSG( "unexpected wxRadioBox layout direction" ); - // fall through + wxFALLTHROUGH; case RadioDir_Default: break; diff --git a/samples/widgets/spinbtn.cpp b/samples/widgets/spinbtn.cpp index 4bda25ffef..067a3af999 100644 --- a/samples/widgets/spinbtn.cpp +++ b/samples/widgets/spinbtn.cpp @@ -368,7 +368,7 @@ void SpinBtnWidgetsPage::CreateSpin() { default: wxFAIL_MSG("unexpected radiobox selection"); - // fall through + wxFALLTHROUGH; case Align_Left: textFlags |= wxALIGN_LEFT; // no-op diff --git a/samples/widgets/static.cpp b/samples/widgets/static.cpp index 5ae946b9f8..163d500cda 100644 --- a/samples/widgets/static.cpp +++ b/samples/widgets/static.cpp @@ -417,7 +417,7 @@ void StaticWidgetsPage::CreateStatic() { default: wxFAIL_MSG("unexpected radiobox selection"); - // fall through + wxFALLTHROUGH; case StaticHAlign_Left: align |= wxALIGN_LEFT; @@ -436,7 +436,7 @@ void StaticWidgetsPage::CreateStatic() { default: wxFAIL_MSG("unexpected radiobox selection"); - // fall through + wxFALLTHROUGH; case StaticVAlign_Top: align |= wxALIGN_TOP; @@ -457,7 +457,7 @@ void StaticWidgetsPage::CreateStatic() { default: wxFAIL_MSG("unexpected radiobox selection"); - // fall through + wxFALLTHROUGH; case StaticEllipsize_Start: flagsDummyText |= wxST_ELLIPSIZE_START; diff --git a/samples/widgets/textctrl.cpp b/samples/widgets/textctrl.cpp index 8bd91ce042..8618261215 100644 --- a/samples/widgets/textctrl.cpp +++ b/samples/widgets/textctrl.cpp @@ -293,7 +293,7 @@ private: { default: wxFAIL_MSG( "unexpected HitTest() result" ); - // fall through + wxFALLTHROUGH; case wxTE_HT_UNKNOWN: x = y = -1; @@ -690,6 +690,7 @@ void TextWidgetsPage::CreateText() { default: wxFAIL_MSG( "unexpected lines radio box selection" ); + wxFALLTHROUGH; case TextLines_Single: break; @@ -755,6 +756,7 @@ void TextWidgetsPage::CreateText() { default: wxFAIL_MSG( "unexpected kind radio box selection" ); + wxFALLTHROUGH; case TextKind_Plain: break; diff --git a/samples/widgets/toggle.cpp b/samples/widgets/toggle.cpp index 83289037bc..d435642951 100644 --- a/samples/widgets/toggle.cpp +++ b/samples/widgets/toggle.cpp @@ -379,7 +379,7 @@ void ToggleWidgetsPage::CreateToggle() default: wxFAIL_MSG("unexpected radiobox selection"); - // fall through + wxFALLTHROUGH; case ToggleHAlign_Centre: break; @@ -397,7 +397,7 @@ void ToggleWidgetsPage::CreateToggle() default: wxFAIL_MSG("unexpected radiobox selection"); - // fall through + wxFALLTHROUGH; case ToggleVAlign_Centre: // centre vertical alignment is the default (no style) diff --git a/samples/widgets/widgets.cpp b/samples/widgets/widgets.cpp index 63eee2c2f8..381011490d 100644 --- a/samples/widgets/widgets.cpp +++ b/samples/widgets/widgets.cpp @@ -902,7 +902,7 @@ void WidgetsFrame::OnSetBorder(wxCommandEvent& event) default: wxFAIL_MSG( "unknown border style" ); - // fall through + wxFALLTHROUGH; case Widgets_BorderDefault: border = wxBORDER_DEFAULT; break; } diff --git a/samples/xrc/custclas.h b/samples/xrc/custclas.h index 0a72b87394..85f1913d21 100644 --- a/samples/xrc/custclas.h +++ b/samples/xrc/custclas.h @@ -60,7 +60,7 @@ public: ); // Destructor. - ~MyResizableListCtrl(){}; + ~MyResizableListCtrl(){} protected: diff --git a/samples/xrc/derivdlg.h b/samples/xrc/derivdlg.h index 0707a1740b..4c7ef36b6b 100644 --- a/samples/xrc/derivdlg.h +++ b/samples/xrc/derivdlg.h @@ -36,7 +36,7 @@ public: PreferencesDialog( wxWindow* parent ); // Destructor. - ~PreferencesDialog(){}; + ~PreferencesDialog(){} private: diff --git a/src/aui/auibar.cpp b/src/aui/auibar.cpp index b2dc732a66..f31bb456a9 100644 --- a/src/aui/auibar.cpp +++ b/src/aui/auibar.cpp @@ -124,28 +124,16 @@ const wxColour DISABLED_TEXT_COLOR(DISABLED_TEXT_GREY_HUE, wxAuiGenericToolBarArt::wxAuiGenericToolBarArt() { - m_baseColour = GetBaseColor(); + UpdateColoursFromSystem(); m_flags = 0; m_textOrientation = wxAUI_TBTOOL_TEXT_BOTTOM; - m_highlightColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); m_separatorSize = wxWindow::FromDIP( 7, NULL); m_gripperSize = wxWindow::FromDIP( 7, NULL); m_overflowSize = wxWindow::FromDIP(16, NULL); m_dropdownSize = wxWindow::FromDIP(10, NULL); - wxColor darker1Colour = m_baseColour.ChangeLightness(85); - wxColor darker2Colour = m_baseColour.ChangeLightness(75); - wxColor darker3Colour = m_baseColour.ChangeLightness(60); - wxColor darker4Colour = m_baseColour.ChangeLightness(50); - wxColor darker5Colour = m_baseColour.ChangeLightness(40); - - int pen_width = wxWindow::FromDIP(1, NULL); - m_gripperPen1 = wxPen(darker5Colour, pen_width); - m_gripperPen2 = wxPen(darker3Colour, pen_width); - m_gripperPen3 = wxPen(*wxWHITE, pen_width); - // TODO: Provide x1.5 and x2.0 versions or migrate to SVG. static const unsigned char buttonDropdownBits[] = { 0xe0, 0xf1, 0xfb }; static const unsigned char overflowBits[] = { 0x80, 0xff, 0x80, 0xc1, 0xe3, 0xf7 }; @@ -165,13 +153,27 @@ wxAuiGenericToolBarArt::~wxAuiGenericToolBarArt() { m_font = *wxNORMAL_FONT; } - - wxAuiToolBarArt* wxAuiGenericToolBarArt::Clone() { return static_cast(new wxAuiGenericToolBarArt); } +void wxAuiGenericToolBarArt::UpdateColoursFromSystem() +{ + m_baseColour = GetBaseColor(); + m_highlightColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); + wxColor darker1Colour = m_baseColour.ChangeLightness(85); + wxColor darker2Colour = m_baseColour.ChangeLightness(75); + wxColor darker3Colour = m_baseColour.ChangeLightness(60); + wxColor darker4Colour = m_baseColour.ChangeLightness(50); + wxColor darker5Colour = m_baseColour.ChangeLightness(40); + + int pen_width = wxWindow::FromDIP(1, NULL); + m_gripperPen1 = wxPen(darker5Colour, pen_width); + m_gripperPen2 = wxPen(darker3Colour, pen_width); + m_gripperPen3 = wxPen(*wxStockGDI::GetColour(wxStockGDI::COLOUR_WHITE), pen_width); +} + void wxAuiGenericToolBarArt::SetFlags(unsigned int flags) { m_flags = flags; @@ -858,6 +860,7 @@ wxBEGIN_EVENT_TABLE(wxAuiToolBar, wxControl) EVT_LEAVE_WINDOW(wxAuiToolBar::OnLeaveWindow) EVT_MOUSE_CAPTURE_LOST(wxAuiToolBar::OnCaptureLost) EVT_SET_CURSOR(wxAuiToolBar::OnSetCursor) + EVT_SYS_COLOUR_CHANGED(wxAuiToolBar::OnSysColourChanged) wxEND_EVENT_TABLE() void wxAuiToolBar::Init() @@ -912,7 +915,7 @@ bool wxAuiToolBar::Create(wxWindow* parent, SetExtraStyle(wxWS_EX_PROCESS_IDLE); if (style & wxAUI_TB_HORZ_LAYOUT) SetToolTextOrientation(wxAUI_TBTOOL_TEXT_RIGHT); - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); return true; } @@ -2428,6 +2431,14 @@ void wxAuiToolBar::UpdateWindowUI(long flags) wxControl::UpdateWindowUI(flags); } +void wxAuiToolBar::OnSysColourChanged(wxSysColourChangedEvent& event) +{ + event.Skip(); + + m_art->UpdateColoursFromSystem(); + Refresh(); +} + void wxAuiToolBar::OnPaint(wxPaintEvent& WXUNUSED(evt)) { wxAutoBufferedPaintDC dc(this); diff --git a/src/aui/auibook.cpp b/src/aui/auibook.cpp index f1298c9997..9bfe2a7589 100644 --- a/src/aui/auibook.cpp +++ b/src/aui/auibook.cpp @@ -998,6 +998,7 @@ wxBEGIN_EVENT_TABLE(wxAuiTabCtrl, wxControl) EVT_KILL_FOCUS(wxAuiTabCtrl::OnKillFocus) EVT_CHAR(wxAuiTabCtrl::OnChar) EVT_MOUSE_CAPTURE_LOST(wxAuiTabCtrl::OnCaptureLost) + EVT_SYS_COLOUR_CHANGED(wxAuiTabCtrl::OnSysColourChanged) wxEND_EVENT_TABLE() @@ -1028,6 +1029,16 @@ void wxAuiTabCtrl::OnPaint(wxPaintEvent&) Render(&dc, this); } +void wxAuiTabCtrl::OnSysColourChanged(wxSysColourChangedEvent &event) +{ + event.Skip(); + + if (m_art) + { + m_art->UpdateColoursFromSystem(); + } +} + void wxAuiTabCtrl::OnEraseBackground(wxEraseEvent& WXUNUSED(evt)) { } @@ -1669,8 +1680,30 @@ wxBEGIN_EVENT_TABLE(wxAuiNotebook, wxControl) wxEVT_AUINOTEBOOK_BG_DCLICK, wxAuiNotebook::OnTabBgDClick) EVT_NAVIGATION_KEY(wxAuiNotebook::OnNavigationKeyNotebook) + EVT_SYS_COLOUR_CHANGED(wxAuiNotebook::OnSysColourChanged) wxEND_EVENT_TABLE() +void wxAuiNotebook::OnSysColourChanged(wxSysColourChangedEvent &event) +{ + event.Skip(true); + wxAuiTabArt* art = m_tabs.GetArtProvider(); + art->UpdateColoursFromSystem(); + + wxAuiPaneInfoArray& all_panes = m_mgr.GetAllPanes(); + size_t i, pane_count = all_panes.GetCount(); + for (i = 0; i < pane_count; ++i) + { + wxAuiPaneInfo& pane = all_panes.Item(i); + if (pane.name == wxT("dummy")) + continue; + wxTabFrame* tab_frame = (wxTabFrame*)pane.window; + wxAuiTabCtrl* tabctrl = tab_frame->m_tabs; + tabctrl->GetArtProvider()->UpdateColoursFromSystem(); + tabctrl->Refresh(); + } + Refresh(); +} + void wxAuiNotebook::Init() { m_curPage = -1; diff --git a/src/aui/dockart.cpp b/src/aui/dockart.cpp index 6aa5a469b9..47f6fd0d63 100644 --- a/src/aui/dockart.cpp +++ b/src/aui/dockart.cpp @@ -156,48 +156,7 @@ wxString wxAuiChopText(wxDC& dc, const wxString& text, int max_size) wxAuiDefaultDockArt::wxAuiDefaultDockArt() { -#if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON - wxColor baseColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); -#else - wxColor baseColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); -#endif - - // the baseColour is too pale to use as our base colour, - // so darken it a bit -- - if ((255-baseColour.Red()) + - (255-baseColour.Green()) + - (255-baseColour.Blue()) < 60) - { - baseColour = baseColour.ChangeLightness(92); - } - - m_baseColour = baseColour; - wxColor darker1Colour = baseColour.ChangeLightness(85); - wxColor darker2Colour = baseColour.ChangeLightness(75); - wxColor darker3Colour = baseColour.ChangeLightness(60); - //wxColor darker4Colour = baseColour.ChangeLightness(50); - wxColor darker5Colour = baseColour.ChangeLightness(40); - - m_activeCaptionColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); - m_activeCaptionGradientColour = wxAuiLightContrastColour(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); - m_activeCaptionTextColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT); - m_inactiveCaptionColour = darker1Colour; - m_inactiveCaptionGradientColour = baseColour.ChangeLightness(97); -#ifdef __WXMAC__ - m_inactiveCaptionTextColour = wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTIONTEXT); -#else - m_inactiveCaptionTextColour = *wxBLACK; -#endif - - m_sashBrush = wxBrush(baseColour); - m_backgroundBrush = wxBrush(baseColour); - m_gripperBrush = wxBrush(baseColour); - - m_borderPen = wxPen(darker2Colour); - int pen_width = wxWindow::FromDIP(1, NULL); - m_gripperPen1 = wxPen(darker5Colour, pen_width); - m_gripperPen2 = wxPen(darker3Colour, pen_width); - m_gripperPen3 = wxPen(*wxWHITE, pen_width); + UpdateColoursFromSystem(); #ifdef __WXMAC__ m_captionFont = *wxSMALL_FONT; @@ -296,6 +255,53 @@ wxAuiDefaultDockArt::InitBitmaps () m_activePinBitmap = wxAuiBitmapFromBits(pin_bits, 16, 16, m_activeCaptionTextColour); } +void wxAuiDefaultDockArt::UpdateColoursFromSystem() +{ +#if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON + wxColor baseColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); +#else + wxColor baseColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); +#endif + + // the baseColour is too pale to use as our base colour, + // so darken it a bit -- + if ((255-baseColour.Red()) + + (255-baseColour.Green()) + + (255-baseColour.Blue()) < 60) + { + baseColour = baseColour.ChangeLightness(92); + } + + m_baseColour = baseColour; + wxColor darker1Colour = baseColour.ChangeLightness(85); + wxColor darker2Colour = baseColour.ChangeLightness(75); + wxColor darker3Colour = baseColour.ChangeLightness(60); + //wxColor darker4Colour = baseColour.ChangeLightness(50); + wxColor darker5Colour = baseColour.ChangeLightness(40); + + m_activeCaptionColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); + m_activeCaptionGradientColour = wxAuiLightContrastColour(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); + m_activeCaptionTextColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT); + m_inactiveCaptionColour = darker1Colour; + m_inactiveCaptionGradientColour = baseColour.ChangeLightness(97); +#ifdef __WXMAC__ + m_inactiveCaptionTextColour = wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTIONTEXT); +#else + m_inactiveCaptionTextColour = *wxBLACK; +#endif + + m_sashBrush = wxBrush(baseColour); + m_backgroundBrush = wxBrush(baseColour); + m_gripperBrush = wxBrush(baseColour); + + m_borderPen = wxPen(darker2Colour); + int pen_width = wxWindow::FromDIP(1, NULL); + m_gripperPen1 = wxPen(darker5Colour, pen_width); + m_gripperPen2 = wxPen(darker3Colour, pen_width); + m_gripperPen3 = wxPen(*wxStockGDI::GetColour(wxStockGDI::COLOUR_WHITE), pen_width); + InitBitmaps(); +} + int wxAuiDefaultDockArt::GetMetric(int id) { switch (id) diff --git a/src/aui/framemanager.cpp b/src/aui/framemanager.cpp index 21ddcbd60f..206a114dd8 100644 --- a/src/aui/framemanager.cpp +++ b/src/aui/framemanager.cpp @@ -97,7 +97,7 @@ public: const wxString &name = wxT("frame")) : wxFrame(parent, id, title, pos, size, style | wxFRAME_SHAPED, name) { - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); m_amount=0; m_maxWidth=0; m_maxHeight=0; @@ -604,6 +604,7 @@ wxBEGIN_EVENT_TABLE(wxAuiManager, wxEvtHandler) EVT_MOUSE_CAPTURE_LOST(wxAuiManager::OnCaptureLost) EVT_CHILD_FOCUS(wxAuiManager::OnChildFocus) EVT_AUI_FIND_MANAGER(wxAuiManager::OnFindManager) + EVT_SYS_COLOUR_CHANGED(wxAuiManager::OnSysColourChanged) wxEND_EVENT_TABLE() @@ -648,6 +649,13 @@ wxAuiManager::~wxAuiManager() delete m_art; } +void wxAuiManager::OnSysColourChanged(wxSysColourChangedEvent& event) +{ + m_art->UpdateColoursFromSystem(); + m_frame->Refresh(); + event.Skip(true); +} + // creates a floating frame for the windows wxAuiFloatingFrame* wxAuiManager::CreateFloatingFrame(wxWindow* parent, const wxAuiPaneInfo& paneInfo) @@ -3934,7 +3942,7 @@ void wxAuiManager::Render(wxDC* dc) void wxAuiManager::Repaint(wxDC* dc) { -#ifdef __WXMAC__ +#ifdef __WXMAC__ if ( dc == NULL ) { m_frame->Refresh() ; diff --git a/src/aui/tabart.cpp b/src/aui/tabart.cpp index e2ef6c7caa..25acae3f78 100644 --- a/src/aui/tabart.cpp +++ b/src/aui/tabart.cpp @@ -164,6 +164,29 @@ wxAuiGenericTabArt::wxAuiGenericTabArt() m_fixedTabWidth = wxWindow::FromDIP(100, NULL); m_tabCtrlHeight = 0; + UpdateColoursFromSystem(); + + m_activeCloseBmp = wxAuiBitmapFromBits(close_bits, 16, 16, *wxBLACK); + m_disabledCloseBmp = wxAuiBitmapFromBits(close_bits, 16, 16, wxColour(128,128,128)); + + m_activeLeftBmp = wxAuiBitmapFromBits(left_bits, 16, 16, *wxBLACK); + m_disabledLeftBmp = wxAuiBitmapFromBits(left_bits, 16, 16, wxColour(128,128,128)); + + m_activeRightBmp = wxAuiBitmapFromBits(right_bits, 16, 16, *wxBLACK); + m_disabledRightBmp = wxAuiBitmapFromBits(right_bits, 16, 16, wxColour(128,128,128)); + + m_activeWindowListBmp = wxAuiBitmapFromBits(list_bits, 16, 16, *wxBLACK); + m_disabledWindowListBmp = wxAuiBitmapFromBits(list_bits, 16, 16, wxColour(128,128,128)); + + m_flags = 0; +} + +wxAuiGenericTabArt::~wxAuiGenericTabArt() +{ +} + +void wxAuiGenericTabArt::UpdateColoursFromSystem() +{ #if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON wxColor baseColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); #else @@ -186,24 +209,6 @@ wxAuiGenericTabArt::wxAuiGenericTabArt() m_borderPen = wxPen(borderColour); m_baseColourPen = wxPen(m_baseColour); m_baseColourBrush = wxBrush(m_baseColour); - - m_activeCloseBmp = wxAuiBitmapFromBits(close_bits, 16, 16, *wxBLACK); - m_disabledCloseBmp = wxAuiBitmapFromBits(close_bits, 16, 16, wxColour(128,128,128)); - - m_activeLeftBmp = wxAuiBitmapFromBits(left_bits, 16, 16, *wxBLACK); - m_disabledLeftBmp = wxAuiBitmapFromBits(left_bits, 16, 16, wxColour(128,128,128)); - - m_activeRightBmp = wxAuiBitmapFromBits(right_bits, 16, 16, *wxBLACK); - m_disabledRightBmp = wxAuiBitmapFromBits(right_bits, 16, 16, wxColour(128,128,128)); - - m_activeWindowListBmp = wxAuiBitmapFromBits(list_bits, 16, 16, *wxBLACK); - m_disabledWindowListBmp = wxAuiBitmapFromBits(list_bits, 16, 16, wxColour(128,128,128)); - - m_flags = 0; -} - -wxAuiGenericTabArt::~wxAuiGenericTabArt() -{ } wxAuiTabArt* wxAuiGenericTabArt::Clone() @@ -919,7 +924,6 @@ wxAuiSimpleTabArt::wxAuiSimpleTabArt() m_activeWindowListBmp = wxAuiBitmapFromBits(list_bits, 16, 16, *wxBLACK); m_disabledWindowListBmp = wxAuiBitmapFromBits(list_bits, 16, 16, wxColour(128,128,128)); - } wxAuiSimpleTabArt::~wxAuiSimpleTabArt() diff --git a/src/common/combocmn.cpp b/src/common/combocmn.cpp index b1e0645abd..4663dd5c0f 100644 --- a/src/common/combocmn.cpp +++ b/src/common/combocmn.cpp @@ -2277,7 +2277,7 @@ void wxComboCtrlBase::ShowPopup() wxSize ctrlSz = GetSize(); screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y ); - scrPos = GetParent()->ClientToScreen(GetPosition()); + scrPos = GetScreenPosition(); spaceAbove = scrPos.y; spaceBelow = screenHeight - spaceAbove - ctrlSz.y; @@ -2571,8 +2571,9 @@ void wxComboCtrlBase::OnPopupDismiss(bool generateEvent) void wxComboCtrlBase::HidePopup(bool generateEvent) { // Should be able to call this without popup interface - if ( IsPopupWindowState(Hidden) ) + if ( IsPopupWindowState(Hidden) || IsPopupWindowState(Closing) ) return; + m_popupWinState = Closing; // To prevent from reentering // transfer value and show it in textctrl, if any if ( !IsPopupWindowState(Animating) ) diff --git a/src/common/dcgraph.cpp b/src/common/dcgraph.cpp index d70113dfcc..5812e393f3 100644 --- a/src/common/dcgraph.cpp +++ b/src/common/dcgraph.cpp @@ -418,6 +418,15 @@ void wxGCDCImpl::SetTextBackground( const wxColour &col ) wxSize wxGCDCImpl::GetPPI() const { + if ( m_graphicContext ) + { + wxDouble x, y; + m_graphicContext->GetDPI(&x, &y); + return wxSize(wxRound(x), wxRound(y)); + } + + // This is the same value that wxGraphicsContext::GetDPI() returns by + // default. return wxSize(72, 72); } @@ -1098,40 +1107,40 @@ void wxGCDCImpl::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, if ( (angle == 0.0) && m_font.IsOk() ) { DoDrawText(text, x, y); - + // Bounding box already updated by DoDrawText(), no need to do it again. return; } - + // Get extent of whole text. wxCoord w, h, heightLine; GetOwner()->GetMultiLineTextExtent(text, &w, &h, &heightLine); - + // Compute the shift for the origin of the next line. const double rad = wxDegToRad(angle); const double dx = heightLine * sin(rad); const double dy = heightLine * cos(rad); - + // Draw all text line by line const wxArrayString lines = wxSplit(text, '\n', '\0'); for ( size_t lineNum = 0; lineNum < lines.size(); lineNum++ ) { // Calculate origin for each line to avoid accumulation of // rounding errors. - if ( m_backgroundMode == wxTRANSPARENT ) + if ( m_backgroundMode == wxBRUSHSTYLE_TRANSPARENT ) m_graphicContext->DrawText( lines[lineNum], x + wxRound(lineNum*dx), y + wxRound(lineNum*dy), wxDegToRad(angle )); else m_graphicContext->DrawText( lines[lineNum], x + wxRound(lineNum*dx), y + wxRound(lineNum*dy), wxDegToRad(angle ), m_graphicContext->CreateBrush(m_textBackgroundColour) ); } - + // call the bounding box by adding all four vertices of the rectangle // containing the text to it (simpler and probably not slower than // determining which of them is really topmost/leftmost/...) - + // "upper left" and "upper right" CalcBoundingBox(x, y); CalcBoundingBox(x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad))); - + // "bottom left" and "bottom right" x += (wxCoord)(h*sin(rad)); y += (wxCoord)(h*cos(rad)); @@ -1161,7 +1170,7 @@ void wxGCDCImpl::DoDrawText(const wxString& str, wxCoord x, wxCoord y) if ( !m_logicalFunctionSupported ) return; - if ( m_backgroundMode == wxTRANSPARENT ) + if ( m_backgroundMode == wxBRUSHSTYLE_TRANSPARENT ) m_graphicContext->DrawText( str, x ,y); else m_graphicContext->DrawText( str, x ,y , m_graphicContext->CreateBrush(m_textBackgroundColour) ); @@ -1245,7 +1254,7 @@ wxCoord wxGCDCImpl::GetCharHeight(void) const void wxGCDCImpl::Clear(void) { wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::Clear - invalid DC") ); - + if ( m_backgroundBrush.IsOk() ) { m_graphicContext->SetBrush( m_backgroundBrush ); diff --git a/src/common/dlgcmn.cpp b/src/common/dlgcmn.cpp index 55e37cc2e6..a7a6803bb3 100644 --- a/src/common/dlgcmn.cpp +++ b/src/common/dlgcmn.cpp @@ -871,7 +871,7 @@ int wxStandardDialogLayoutAdapter::DoMustScroll(wxDialog* dialog, wxSize& window wxSize minWindowSize = dialog->GetSizer()->GetMinSize(); windowSize = dialog->GetSize(); windowSize = wxSize(wxMax(windowSize.x, minWindowSize.x), wxMax(windowSize.y, minWindowSize.y)); - displaySize = wxDisplay(wxDisplay::GetFromWindow(dialog)).GetClientArea().GetSize(); + displaySize = wxDisplay(dialog).GetClientArea().GetSize(); int flags = 0; diff --git a/src/common/dpycmn.cpp b/src/common/dpycmn.cpp index d0073ee32c..6171335b1a 100644 --- a/src/common/dpycmn.cpp +++ b/src/common/dpycmn.cpp @@ -85,6 +85,13 @@ wxDisplay::wxDisplay(unsigned n) m_impl = Factory().GetDisplay(n); } +wxDisplay::wxDisplay(const wxWindow* window) +{ + const int n = GetFromWindow(window); + + m_impl = Factory().GetDisplay(n != wxNOT_FOUND ? n : 0); +} + // ---------------------------------------------------------------------------- // static functions forwarded to wxDisplayFactory // ---------------------------------------------------------------------------- @@ -193,20 +200,29 @@ bool wxDisplay::ChangeMode(const wxVideoMode& mode) // wxDisplayImpl implementation // ============================================================================ -wxSize wxDisplayImpl::GetPPI() const +/* static */ +wxSize wxDisplayImpl::ComputePPI(int pxX, int pxY, int mmX, int mmY) { - const wxSize pixels = GetGeometry().GetSize(); - const wxSize mm = GetSizeMM(); - - if ( !mm.x || !mm.y ) + if ( !mmX || !mmY ) { // Physical size is unknown, return a special value indicating that we // can't compute the resolution -- what else can we do? return wxSize(0, 0); } - return wxSize(wxRound((pixels.x * inches2mm) / mm.x), - wxRound((pixels.y * inches2mm) / mm.y)); + return wxSize(wxRound((pxX * inches2mm) / mmX), + wxRound((pxY * inches2mm) / mmY)); +} + +wxSize wxDisplayImpl::GetPPI() const +{ + const wxSize mm = GetSizeMM(); + + // We need physical pixels here, not logical ones returned by + // GetGeometry(), to compute the real DPI. + const wxSize pixels = GetGeometry().GetSize()*GetScaleFactor(); + + return ComputePPI(pixels.x, pixels.y, mm.x, mm.y); } // ============================================================================ @@ -224,6 +240,8 @@ wxDisplayFactory::~wxDisplayFactory() int wxDisplayFactory::GetFromWindow(const wxWindow *window) { + wxCHECK_MSG( window, wxNOT_FOUND, "window can't be NULL" ); + // consider that the window belongs to the display containing its centre const wxRect r(window->GetScreenRect()); return GetFromPoint(wxPoint(r.x + r.width/2, r.y + r.height/2)); diff --git a/src/common/fontcmn.cpp b/src/common/fontcmn.cpp index 74f105e2a2..54c0698ef4 100644 --- a/src/common/fontcmn.cpp +++ b/src/common/fontcmn.cpp @@ -104,9 +104,9 @@ wxPROPERTY( Size,int, SetPointSize, GetPointSize, 12, 0 /*flags*/, \ wxT("Helpstring"), wxT("group")) wxPROPERTY( Family, wxFontFamily , SetFamily, GetFamily, (wxFontFamily)wxDEFAULT, \ 0 /*flags*/, wxT("Helpstring"), wxT("group")) // wxFontFamily -wxPROPERTY( Style, wxFontStyle, SetStyle, GetStyle, (wxFontStyle)wxNORMAL, 0 /*flags*/, \ +wxPROPERTY( Style, wxFontStyle, SetStyle, GetStyle, wxFONTSTYLE_NORMAL, 0 /*flags*/, \ wxT("Helpstring"), wxT("group")) // wxFontStyle -wxPROPERTY( Weight, wxFontWeight, SetWeight, GetWeight, (wxFontWeight)wxNORMAL, 0 /*flags*/, \ +wxPROPERTY( Weight, wxFontWeight, SetWeight, GetWeight, wxFONTWEIGHT_NORMAL, 0 /*flags*/, \ wxT("Helpstring"), wxT("group")) // wxFontWeight wxPROPERTY( Underlined, bool, SetUnderlined, GetUnderlined, false, 0 /*flags*/, \ wxT("Helpstring"), wxT("group")) diff --git a/src/common/glcmn.cpp b/src/common/glcmn.cpp index 21f7d54129..03dd583ca1 100644 --- a/src/common/glcmn.cpp +++ b/src/common/glcmn.cpp @@ -76,7 +76,7 @@ wxGLCanvasBase::wxGLCanvasBase() // we always paint background entirely ourselves so prevent wx from erasing // it to avoid flicker - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); } bool wxGLCanvasBase::SetCurrent(const wxGLContext& context) const diff --git a/src/common/graphcmn.cpp b/src/common/graphcmn.cpp index fc0e6ab894..1f4f74cc7c 100644 --- a/src/common/graphcmn.cpp +++ b/src/common/graphcmn.cpp @@ -31,6 +31,8 @@ #include "wx/log.h" #endif +#include "wx/display.h" + #ifdef __WXMSW__ #include "wx/msw/enhmeta.h" #endif @@ -565,12 +567,14 @@ void * wxGraphicsBitmap::GetNativeBitmap() const wxIMPLEMENT_ABSTRACT_CLASS(wxGraphicsContext, wxObject); -wxGraphicsContext::wxGraphicsContext(wxGraphicsRenderer* renderer) : - wxGraphicsObject(renderer), +wxGraphicsContext::wxGraphicsContext(wxGraphicsRenderer* renderer, + wxWindow* window) + : wxGraphicsObject(renderer), m_antialias(wxANTIALIAS_DEFAULT), m_composition(wxCOMPOSITION_OVER), m_interpolation(wxINTERPOLATION_DEFAULT), - m_enableOffset(false) + m_enableOffset(false), + m_window(window) { } @@ -618,8 +622,19 @@ wxDouble wxGraphicsContext::GetAlpha() const void wxGraphicsContext::GetDPI( wxDouble* dpiX, wxDouble* dpiY) { - *dpiX = 72.0; - *dpiY = 72.0; + if ( m_window ) + { + const wxSize ppi = wxDisplay(m_window).GetPPI(); + *dpiX = ppi.x; + *dpiY = ppi.y; + } + else + { + // Use some standard DPI value, it doesn't make much sense for the + // contexts not using any pixels anyhow. + *dpiX = 72.0; + *dpiY = 72.0; + } } // sets the pen diff --git a/src/common/imagjpeg.cpp b/src/common/imagjpeg.cpp index df9893c44d..7fbb97ce5e 100644 --- a/src/common/imagjpeg.cpp +++ b/src/common/imagjpeg.cpp @@ -505,7 +505,11 @@ bool wxJPEGHandler::DoCanRead( wxInputStream& stream ) /*static*/ wxVersionInfo wxJPEGHandler::GetLibraryVersionInfo() { - return wxVersionInfo("libjpeg", JPEG_LIB_VERSION/10, JPEG_LIB_VERSION%10); +#if defined(JPEG_LIB_VERSION_MAJOR) && defined(JPEG_LIB_VERSION_MINOR) + return wxVersionInfo("libjpeg", JPEG_LIB_VERSION_MAJOR, JPEG_LIB_VERSION_MINOR); +#else + return wxVersionInfo("libjpeg", JPEG_LIB_VERSION / 10, JPEG_LIB_VERSION % 10); +#endif } #endif // wxUSE_LIBJPEG diff --git a/src/common/sizer.cpp b/src/common/sizer.cpp index fa42c07497..9bc0d295fb 100644 --- a/src/common/sizer.cpp +++ b/src/common/sizer.cpp @@ -930,15 +930,9 @@ wxSize wxSizer::ComputeFittingClientSize(wxWindow *window) return tlw->GetClientSize(); } - // limit the window to the size of the display it is on - int disp = wxDisplay::GetFromWindow(window); - if ( disp == wxNOT_FOUND ) - { - // or, if we don't know which one it is, of the main one - disp = 0; - } - - sizeMax = wxDisplay(disp).GetClientArea().GetSize(); + // limit the window to the size of the display it is on (or the main + // one if the window display can't be determined) + sizeMax = wxDisplay(window).GetClientArea().GetSize(); // If determining the display size failed, skip the max size checks as // we really don't want to create windows of (0, 0) size. diff --git a/src/common/toplvcmn.cpp b/src/common/toplvcmn.cpp index a5660a3b23..7619328a18 100644 --- a/src/common/toplvcmn.cpp +++ b/src/common/toplvcmn.cpp @@ -249,8 +249,7 @@ void wxTopLevelWindowBase::DoCentre(int dir) // we need the display rect anyhow so store it first: notice that we should // be centered on the same display as our parent window, the display of // this window itself is not really defined yet - int nDisplay = wxDisplay::GetFromWindow(GetParent() ? GetParent() : this); - wxDisplay dpy(nDisplay == wxNOT_FOUND ? 0 : nDisplay); + wxDisplay dpy(GetParent() ? GetParent() : this); const wxRect rectDisplay(dpy.GetClientArea()); // what should we centre this window on? diff --git a/src/common/translation.cpp b/src/common/translation.cpp index bf92ed2942..7d9937cd18 100644 --- a/src/common/translation.cpp +++ b/src/common/translation.cpp @@ -127,7 +127,7 @@ wxString GetPreferredUILanguageFallback(const wxArrayString& WXUNUSED(available) #ifdef __WINDOWS__ -wxString GetPreferredUILanguage(const wxArrayString& available) +wxString GetPreferredUILanguage(const wxArrayString& available, wxArrayString& allPreferred) { typedef BOOL (WINAPI *GetUserPreferredUILanguages_t)(DWORD, PULONG, PWSTR, PULONG); static GetUserPreferredUILanguages_t s_pfnGetUserPreferredUILanguages = NULL; @@ -172,18 +172,20 @@ wxString GetPreferredUILanguage(const wxArrayString& available) wxString lang(*j); lang.Replace("-", "_"); if ( available.Index(lang, /*bCase=*/false) != wxNOT_FOUND ) - return lang; + allPreferred.Add(lang); size_t pos = lang.find('_'); if ( pos != wxString::npos ) { lang = lang.substr(0, pos); if ( available.Index(lang, /*bCase=*/false) != wxNOT_FOUND ) - return lang; + allPreferred.Add(lang); } } } } } + if ( !allPreferred.empty() ) + return allPreferred[0]; return GetPreferredUILanguageFallback(available); } @@ -207,7 +209,7 @@ void LogTraceArray(const char *prefix, CFArrayRef arr) #endif // wxUSE_LOG_TRACE -wxString GetPreferredUILanguage(const wxArrayString& available) +wxString GetPreferredUILanguage(const wxArrayString& available, wxArrayString &allPreferred) { wxStringToStringHashMap availableNormalized; wxCFRef availableArr( @@ -231,17 +233,19 @@ wxString GetPreferredUILanguage(const wxArrayString& available) LogTraceArray(" - system preferred languages", prefArr); unsigned prefArrLength = CFArrayGetCount(prefArr); - if ( prefArrLength > 0 ) + for ( size_t x = 0; x < prefArrLength; ++x ) { // Lookup the name in 'available' by index -- we need to get the // original value corresponding to the normalized one chosen. - wxString lang(wxCFStringRef::AsString((CFStringRef)CFArrayGetValueAtIndex(prefArr, 0))); + wxString lang(wxCFStringRef::AsString((CFStringRef)CFArrayGetValueAtIndex(prefArr, x))); wxStringToStringHashMap::const_iterator i = availableNormalized.find(lang); if ( i == availableNormalized.end() ) - return lang; + allPreferred.push_back(lang); else - return i->second; + allPreferred.push_back(i->second); } + if ( allPreferred.empty() == false ) + return allPreferred[0]; return GetPreferredUILanguageFallback(available); } @@ -255,7 +259,7 @@ wxString GetPreferredUILanguage(const wxArrayString& available) // The LANGUAGE variable may contain a colon separated list of language // codes in the order of preference. // http://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html -wxString GetPreferredUILanguage(const wxArrayString& available) +wxString GetPreferredUILanguage(const wxArrayString& available, wxArrayString &allPreferred) { wxString languageFromEnv; wxArrayString preferred; @@ -283,15 +287,17 @@ wxString GetPreferredUILanguage(const wxArrayString& available) { wxString lang(*j); if ( available.Index(lang) != wxNOT_FOUND ) - return lang; + allPreferred.Add(lang); size_t pos = lang.find('_'); if ( pos != wxString::npos ) { lang = lang.substr(0, pos); if ( available.Index(lang) != wxNOT_FOUND ) - return lang; + allPreferred.Add(lang); } } + if ( allPreferred.empty() == false ) + return allPreferred[0]; return GetPreferredUILanguageFallback(available); } @@ -1549,9 +1555,9 @@ bool wxTranslations::AddCatalog(const wxString& domain, wxLanguage msgIdLanguage) { const wxString msgIdLang = wxLocale::GetLanguageCanonicalName(msgIdLanguage); - const wxString domain_lang = GetBestTranslation(domain, msgIdLang); + const wxArrayString domain_langs = GetAcceptableTranslations(domain, msgIdLanguage); - if ( domain_lang.empty() ) + if ( domain_langs.empty() ) { wxLogTrace(TRACE_I18N, wxS("no suitable translation for domain '%s' found"), @@ -1559,11 +1565,30 @@ bool wxTranslations::AddCatalog(const wxString& domain, return false; } - wxLogTrace(TRACE_I18N, - wxS("adding '%s' translation for domain '%s' (msgid language '%s')"), - domain_lang, domain, msgIdLang); + bool success = false; + for ( wxArrayString::const_iterator lang = domain_langs.begin(); + lang != domain_langs.end(); + ++lang ) + { + wxLogTrace(TRACE_I18N, + wxS("adding '%s' translation for domain '%s' (msgid language '%s')"), + *lang, domain, msgIdLang); - return LoadCatalog(domain, domain_lang, msgIdLang); + // No use loading languages that are less preferred than the + // msgid language, as by definition it contains all the strings + // in the msgid language. + if ( msgIdLang == *lang ) + break; + + // We determine success by the success of loading/failing to load + // the most preferred (i.e. the first one) language's catalog: + if ( lang == domain_langs.begin() ) + success = LoadCatalog(domain, *lang, msgIdLang); + else + LoadCatalog(domain, *lang, msgIdLang); + } + + return success; } @@ -1650,20 +1675,37 @@ wxString wxTranslations::GetBestTranslation(const wxString& domain, wxString wxTranslations::GetBestTranslation(const wxString& domain, const wxString& msgIdLanguage) { - // explicitly set language should always be respected - if ( !m_lang.empty() ) - return m_lang; + const wxArrayString allGoodOnes = GetAcceptableTranslations(domain, msgIdLanguage); + wxLogTrace(TRACE_I18N, " => using language '%s'", allGoodOnes[0]); + return allGoodOnes[0]; +} + +wxArrayString wxTranslations::GetAcceptableTranslations(const wxString& domain, + wxLanguage msgIdLanguage) +{ + const wxString lang = wxLocale::GetLanguageCanonicalName(msgIdLanguage); + return GetAcceptableTranslations(domain, lang); +} + +wxArrayString wxTranslations::GetAcceptableTranslations(const wxString& domain, + const wxString& msgIdLanguage) +{ wxArrayString available(GetAvailableTranslations(domain)); // it's OK to have duplicates, so just add msgid language available.push_back(msgIdLanguage); available.push_back(msgIdLanguage.BeforeFirst('_')); - wxLogTrace(TRACE_I18N, "choosing best language for domain '%s'", domain); + wxLogTrace(TRACE_I18N, "choosing best languages for domain '%s'", domain); LogTraceArray(" - available translations", available); - const wxString lang = GetPreferredUILanguage(available); - wxLogTrace(TRACE_I18N, " => using language '%s'", lang); - return lang; + wxArrayString allPreferred; + GetPreferredUILanguage(available, allPreferred); + + // explicitly set language should always be preferred the most + if ( !m_lang.empty() ) + allPreferred.insert(allPreferred.begin(), m_lang); + + return allPreferred; } diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index f18f5f1fb2..456dc1b38a 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -19,6 +19,8 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" +#include "wx/debug.h" + #ifdef __BORLANDC__ #pragma hdrstop #endif @@ -1015,6 +1017,27 @@ unsigned int wxGCD(unsigned int u, unsigned int v) return u << shift; } +// ---------------------------------------------------------------------------- +// wxCTZ +// Count trailing zeros. Use optimised builtin where available. +// ---------------------------------------------------------------------------- +unsigned int wxCTZ(wxUint32 x) +{ + wxCHECK_MSG(x > 0, 0, "Undefined for x == 0."); +#ifdef __GNUC__ + return __builtin_ctz(x); +#else + int n; + n = 1; + if ((x & 0x0000FFFF) == 0) {n = n +16; x = x >>16;} + if ((x & 0x000000FF) == 0) {n = n + 8; x = x >> 8;} + if ((x & 0x0000000F) == 0) {n = n + 4; x = x >> 4;} + if ((x & 0x00000003) == 0) {n = n + 2; x = x >> 2;} + return n - (x & 1); +#endif +} + + #endif // wxUSE_BASE // ============================================================================ diff --git a/src/common/webviewarchivehandler.cpp b/src/common/webviewarchivehandler.cpp index 963c7fd210..509bacd3c2 100644 --- a/src/common/webviewarchivehandler.cpp +++ b/src/common/webviewarchivehandler.cpp @@ -85,7 +85,7 @@ wxFSFile* wxWebViewArchiveHandler::GetFile(const wxString &uri) return NULL; wxString fspath = "file:" + - EscapeFileNameCharsInURL(path.substr(doubleslash + 2).c_str()); + EscapeFileNameCharsInURL(path.substr(doubleslash + 2).utf8_str()); return m_fileSystem->OpenFile(fspath); } //Otherwise we need to extract the protocol @@ -108,7 +108,7 @@ wxFSFile* wxWebViewArchiveHandler::GetFile(const wxString &uri) return NULL; wxString fspath = "file:" + - EscapeFileNameCharsInURL(mainpath.substr(doubleslash + 2).c_str()) + EscapeFileNameCharsInURL(mainpath.substr(doubleslash + 2).utf8_str()) + "#" + protocol +":" + archivepath; return m_fileSystem->OpenFile(fspath); } diff --git a/src/dfb/brush.cpp b/src/dfb/brush.cpp index d8ffb6c5a3..ba9f38e3c6 100644 --- a/src/dfb/brush.cpp +++ b/src/dfb/brush.cpp @@ -44,9 +44,9 @@ public: void SetStyle(wxBrushStyle style) { - if ( style != wxSOLID && style != wxTRANSPARENT ) + if ( style != wxBRUSHSTYLE_SOLID && style != wxBRUSHSTYLE_TRANSPARENT ) { - wxFAIL_MSG( wxT("only wxSOLID and wxTRANSPARENT styles are supported") ); + wxFAIL_MSG( wxT("only wxBRUSHSTYLE_SOLID and wxBRUSHSTYLE_TRANSPARENT styles are supported") ); style = wxBRUSHSTYLE_SOLID; } diff --git a/src/dfb/dc.cpp b/src/dfb/dc.cpp index d6141a7602..a65f9bca0b 100644 --- a/src/dfb/dc.cpp +++ b/src/dfb/dc.cpp @@ -135,7 +135,7 @@ void wxDFBDCImpl::Clear() { wxCHECK_RET( IsOk(), wxT("invalid dc") ); - if ( m_backgroundBrush.GetStyle() == wxTRANSPARENT ) + if ( m_backgroundBrush.GetStyle() == wxBRUSHSTYLE_TRANSPARENT ) return; wxColour clr = m_backgroundBrush.GetColour(); @@ -181,7 +181,7 @@ void wxDFBDCImpl::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) { wxCHECK_RET( IsOk(), wxT("invalid dc") ); - if ( m_pen.GetStyle() == wxTRANSPARENT ) + if ( m_pen.GetStyle() == wxPENSTYLE_TRANSPARENT ) return; wxCoord xx1 = XLOG2DEV(x1); @@ -278,7 +278,7 @@ void wxDFBDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord h yy = yy - hh; } - if ( m_brush.GetStyle() != wxTRANSPARENT ) + if ( m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT ) { SelectColour(m_brush.GetColour()); m_surface->FillRectangle(xx, yy, ww, hh); @@ -287,7 +287,7 @@ void wxDFBDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord h SelectColour(m_pen.GetColour()); } - if ( m_pen.GetStyle() != wxTRANSPARENT ) + if ( m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT ) { m_surface->DrawRectangle(xx, yy, ww, hh); } @@ -343,7 +343,7 @@ void wxDFBDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y) CalcBoundingBox(x + w, y + h); // if background mode is solid, DrawText must paint text's background: - if ( m_backgroundMode == wxSOLID ) + if ( m_backgroundMode == wxBRUSHSTYLE_SOLID ) { wxCHECK_RET( m_textBackgroundColour.IsOk(), wxT("invalid background color") ); diff --git a/src/dfb/pen.cpp b/src/dfb/pen.cpp index 02f290da02..cac8a98561 100644 --- a/src/dfb/pen.cpp +++ b/src/dfb/pen.cpp @@ -43,7 +43,7 @@ public: { if ( style != wxPENSTYLE_SOLID && style != wxPENSTYLE_TRANSPARENT ) { - wxFAIL_MSG( "only wxSOLID and wxTRANSPARENT styles are supported" ); + wxFAIL_MSG( "only wxPENSTYLE_SOLID and wxPENSTYLE_TRANSPARENT styles are supported" ); style = wxPENSTYLE_SOLID; } diff --git a/src/expat b/src/expat index 6b2e0e6802..b99766ce61 160000 --- a/src/expat +++ b/src/expat @@ -1 +1 @@ -Subproject commit 6b2e0e680289cdf92839b2a3f8b0735c84dc9326 +Subproject commit b99766ce61f2cefa0ada22204765c1bf08802216 diff --git a/src/generic/buttonbar.cpp b/src/generic/buttonbar.cpp index 38848cd30b..2e4c1c9772 100644 --- a/src/generic/buttonbar.cpp +++ b/src/generic/buttonbar.cpp @@ -500,7 +500,7 @@ void wxButtonToolBar::OnPaint(wxPaintEvent& WXUNUSED(event)) wxPaintDC dc(this); dc.SetFont(GetFont()); - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); for ( wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst(); node; diff --git a/src/generic/calctrlg.cpp b/src/generic/calctrlg.cpp index 3c5b8ce4e9..b8169ec11c 100644 --- a/src/generic/calctrlg.cpp +++ b/src/generic/calctrlg.cpp @@ -913,7 +913,7 @@ void wxGenericCalendarCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) // draw column with calendar week nr if ( HasFlag( wxCAL_SHOW_WEEK_NUMBERS ) && IsExposed( 0, y, m_calendarWeekWidth, m_heightRow * 6 )) { - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); dc.SetBrush(wxBrush(m_colHeaderBg, wxBRUSHSTYLE_SOLID)); dc.SetPen(wxPen(m_colHeaderBg, 1, wxPENSTYLE_SOLID)); dc.DrawRectangle( 0, y, m_calendarWeekWidth, m_heightRow * 6 ); diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 2e1d1887e1..448a58bf5b 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -1965,7 +1965,7 @@ wxDataViewMainWindow::wxDataViewMainWindow( wxDataViewCtrl *parent, wxWindowID i SetBackgroundColour( *wxWHITE ); - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); m_penRule = wxPen(GetRuleColour()); @@ -3468,55 +3468,53 @@ int wxDataViewMainWindow::GetLineHeight( unsigned int row ) const class RowToTreeNodeJob: public DoJob { public: - RowToTreeNodeJob( unsigned int row_ , int current_, wxDataViewTreeNode * node ) + // Note that we initialize m_current to -1 because the first node passed to + // our operator() will be the root node, which doesn't appear in the window + // and so doesn't count as a real row. + explicit RowToTreeNodeJob(int row) + : m_row(row), m_current(-1), m_ret(NULL) { - this->row = row_; - this->current = current_; - ret = NULL; - parent = node; } virtual int operator() ( wxDataViewTreeNode * node ) wxOVERRIDE { - current ++; - if( current == static_cast(row)) + if( m_current == m_row) { - ret = node; + m_ret = node; return DoJob::DONE; } - if( node->GetSubTreeCount() + current < static_cast(row) ) + if( node->GetSubTreeCount() + m_current < m_row ) { - current += node->GetSubTreeCount(); + m_current += node->GetSubTreeCount() + 1; return DoJob::SKIP_SUBTREE; } else { - parent = node; - // If the current node has only leaf children, we can find the // desired node directly. This can speed up finding the node // in some cases, and will have a very good effect for list views. if ( node->HasChildren() && (int)node->GetChildNodes().size() == node->GetSubTreeCount() ) { - const int index = static_cast(row) - current - 1; - ret = node->GetChildNodes()[index]; + const int index = m_row - m_current - 1; + m_ret = node->GetChildNodes()[index]; return DoJob::DONE; } + m_current++; + return DoJob::CONTINUE; } } wxDataViewTreeNode * GetResult() const - { return ret; } + { return m_ret; } private: - unsigned int row; - int current; - wxDataViewTreeNode * ret; - wxDataViewTreeNode * parent; + const int m_row; + int m_current; + wxDataViewTreeNode* m_ret; }; wxDataViewTreeNode * wxDataViewMainWindow::GetTreeNodeByRow(unsigned int row) const @@ -3526,7 +3524,7 @@ wxDataViewTreeNode * wxDataViewMainWindow::GetTreeNodeByRow(unsigned int row) co if ( row == (unsigned)-1 ) return NULL; - RowToTreeNodeJob job( row , -2, m_root ); + RowToTreeNodeJob job(static_cast(row)); Walker( m_root , job ); return job.GetResult(); } @@ -3815,10 +3813,16 @@ wxRect wxDataViewMainWindow::GetItemRect( const wxDataViewItem & item, xpos = 0; } + const int row = GetRowByItem(item); + if ( row == -1 ) + { + // This means the row is currently not visible at all. + return wxRect(); + } + // we have to take an expander column into account and compute its indentation // to get the correct x position where the actual text is int indent = 0; - int row = GetRowByItem(item); if (!IsList() && (column == 0 || GetExpanderColumnOrFirstOne(GetOwner()) == column) ) { @@ -3835,6 +3839,14 @@ wxRect wxDataViewMainWindow::GetItemRect( const wxDataViewItem & item, GetOwner()->CalcScrolledPosition( itemRect.x, itemRect.y, &itemRect.x, &itemRect.y ); + // Check if the rectangle is completely outside of the currently visible + // area and, if so, return an empty rectangle to indicate that the item is + // not visible. + if ( itemRect.GetBottom() < 0 || itemRect.GetTop() > GetClientSize().y ) + { + return wxRect(); + } + return itemRect; } @@ -3856,43 +3868,49 @@ int wxDataViewMainWindow::RecalculateCount() const class ItemToRowJob : public DoJob { public: - ItemToRowJob(const wxDataViewItem& item_, wxVector::reverse_iterator iter) - : m_iter(iter), - item(item_) + // As with RowToTreeNodeJob above, we initialize m_current to -1 because + // the first node passed to our operator() is the root node which is not + // visible on screen and so we should return 0 for its first child node and + // not for the root itself. + ItemToRowJob(const wxDataViewItem& item, wxVector::reverse_iterator iter) + : m_item(item), m_iter(iter), m_current(-1) { - ret = -1; } // Maybe binary search will help to speed up this process virtual int operator() ( wxDataViewTreeNode * node) wxOVERRIDE { - ret ++; - if( node->GetItem() == item ) + if( node->GetItem() == m_item ) { return DoJob::DONE; } + // Is this node the next (grand)parent of the item we're looking for? if( node->GetItem() == *m_iter ) { + // Search for the next (grand)parent now and skip this item itself. ++m_iter; + ++m_current; return DoJob::CONTINUE; } else { - ret += node->GetSubTreeCount(); + // Skip this node and all its currently visible children. + m_current += node->GetSubTreeCount() + 1; return DoJob::SKIP_SUBTREE; } } - // the row number is begin from zero int GetResult() const - { return ret -1; } + { return m_current; } private: + const wxDataViewItem m_item; wxVector::reverse_iterator m_iter; - wxDataViewItem item; - int ret; + + // The row corresponding to the last node seen in our operator(). + int m_current; }; @@ -3926,7 +3944,9 @@ int wxDataViewMainWindow::GetRowByItem(const wxDataViewItem & item) const // the parent chain was created by adding the deepest parent first. // so if we want to start at the root node, we have to iterate backwards through the vector ItemToRowJob job( item, parentChain.rbegin() ); - Walker( m_root, job ); + if ( !Walker( m_root, job ) ) + return -1; + return job.GetResult(); } } @@ -5841,8 +5861,11 @@ wxRect wxDataViewCtrl::GetItemRect( const wxDataViewItem & item, // Convert position from the main window coordinates to the control coordinates. // (They can be different due to the presence of the header.). wxRect r = m_clientArea->GetItemRect(item, column); - const wxPoint ctrlPos = ScreenToClient(m_clientArea->ClientToScreen(r.GetPosition())); - r.SetPosition(ctrlPos); + if ( r.width || r.height ) + { + const wxPoint ctrlPos = ScreenToClient(m_clientArea->ClientToScreen(r.GetPosition())); + r.SetPosition(ctrlPos); + } return r; } diff --git a/src/generic/datectlg.cpp b/src/generic/datectlg.cpp index 5ddadc3933..7a405e2c9b 100644 --- a/src/generic/datectlg.cpp +++ b/src/generic/datectlg.cpp @@ -252,7 +252,7 @@ private: return fmt; #else // !wxUSE_INTL - return wxT("x"); + return wxS("%x"); #endif // wxUSE_INTL/!wxUSE_INTL } diff --git a/src/generic/dcpsg.cpp b/src/generic/dcpsg.cpp index 295c7c7650..9787ed6fc6 100644 --- a/src/generic/dcpsg.cpp +++ b/src/generic/dcpsg.cpp @@ -1546,7 +1546,7 @@ void wxPostScriptDCImpl::DoDrawSpline( const wxPointList *points ) wxCoord wxPostScriptDCImpl::GetCharWidth() const { - // Chris Breeze: reasonable approximation using wxMODERN/Courier + // Chris Breeze: reasonable approximation using wxFONTFAMILY_MODERN/Courier return (wxCoord) (GetCharHeight() * 72.0 / 120.0); } @@ -1983,7 +1983,7 @@ void wxPostScriptDCImpl::DoGetTextExtent(const wxString& string, #if !wxUSE_AFM_FOR_POSTSCRIPT /* Provide a VERY rough estimate (avoid using it). * Produces accurate results for mono-spaced font - * such as Courier (aka wxMODERN) */ + * such as Courier (aka wxFONTFAMILY_MODERN) */ if ( x ) *x = strlen (strbuf) * fontSize * 72.0 / 120.0; @@ -2061,8 +2061,8 @@ void wxPostScriptDCImpl::DoGetTextExtent(const wxString& string, switch (Family) { - case wxMODERN: - case wxTELETYPE: + case wxFONTFAMILY_MODERN: + case wxFONTFAMILY_TELETYPE: { if ((Style == wxFONTSTYLE_ITALIC) && (Weight == wxFONTWEIGHT_BOLD)) name = wxT("CourBoO.afm"); else if ((Style != wxFONTSTYLE_ITALIC) && (Weight == wxFONTWEIGHT_BOLD)) name = wxT("CourBo.afm"); @@ -2070,7 +2070,7 @@ void wxPostScriptDCImpl::DoGetTextExtent(const wxString& string, else name = wxT("Cour.afm"); break; } - case wxROMAN: + case wxFONTFAMILY_ROMAN: { if ((Style == wxFONTSTYLE_ITALIC) && (Weight == wxFONTWEIGHT_BOLD)) name = wxT("TimesBoO.afm"); else if ((Style != wxFONTSTYLE_ITALIC) && (Weight == wxFONTWEIGHT_BOLD)) name = wxT("TimesBo.afm"); @@ -2078,12 +2078,12 @@ void wxPostScriptDCImpl::DoGetTextExtent(const wxString& string, else name = wxT("TimesRo.afm"); break; } - case wxSCRIPT: + case wxFONTFAMILY_SCRIPT: { name = wxT("Zapf.afm"); break; } - case wxSWISS: + case wxFONTFAMILY_SWISS: default: { if ((Style == wxFONTSTYLE_ITALIC) && (Weight == wxFONTWEIGHT_BOLD)) name = wxT("HelvBoO.afm"); diff --git a/src/generic/graphicc.cpp b/src/generic/graphicc.cpp index 7ed04b4bd4..ebebea96df 100644 --- a/src/generic/graphicc.cpp +++ b/src/generic/graphicc.cpp @@ -1830,7 +1830,7 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxPrinterDC& #endif wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxWindowDC& dc ) -: wxGraphicsContext(renderer) +: wxGraphicsContext(renderer, dc.GetWindow()) { int width, height; dc.GetSize( &width, &height ); @@ -2244,7 +2244,7 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, cairo_t *context ) } wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, wxWindow *window) - : wxGraphicsContext(renderer) + : wxGraphicsContext(renderer, window) #ifdef __WXMSW__ , m_mswWindowHDC(GetHwndOf(window)) #endif diff --git a/src/generic/headerctrlg.cpp b/src/generic/headerctrlg.cpp index 6d86d56209..d3fa849ad4 100644 --- a/src/generic/headerctrlg.cpp +++ b/src/generic/headerctrlg.cpp @@ -73,7 +73,7 @@ bool wxHeaderCtrl::Create(wxWindow *parent, // tell the system to not paint the background at all to avoid flicker as // we paint the entire window area in our OnPaint() - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); return true; } @@ -183,11 +183,12 @@ unsigned int wxHeaderCtrl::FindColumnAtPoint(int xPhysical, bool *onSeparator) c pos += col.GetWidth(); + // TODO: don't hardcode sensitivity + const int separatorClickMargin = FromDIP(8); + // if the column is resizable, check if we're approximatively over the // line separating it from the next column - // - // TODO: don't hardcode sensitivity - if ( col.IsResizeable() && abs(xLogical - pos) < 8 ) + if ( col.IsResizeable() && abs(xLogical - pos) < separatorClickMargin ) { if ( onSeparator ) *onSeparator = true; @@ -208,6 +209,23 @@ unsigned int wxHeaderCtrl::FindColumnAtPoint(int xPhysical, bool *onSeparator) c return COL_NONE; } +unsigned int wxHeaderCtrl::FindColumnClosestToPoint(int xPhysical) const +{ + const unsigned int colIndexAtPoint = FindColumnAtPoint(xPhysical); + + // valid column found? + if ( colIndexAtPoint != COL_NONE ) + return colIndexAtPoint; + + // if not, xPhysical must be beyond the rightmost column, so return its + // index instead -- if we have it + const unsigned int count = GetColumnCount(); + if ( !count ) + return COL_NONE; + + return m_colIndices[count - 1]; +} + // ---------------------------------------------------------------------------- // wxHeaderCtrl repainting // ---------------------------------------------------------------------------- @@ -372,7 +390,7 @@ void wxHeaderCtrl::UpdateReorderingMarker(int xPhysical) // and also a hint indicating where it is going to be inserted if it's // dropped now - unsigned int col = FindColumnAtPoint(xPhysical); + unsigned int col = FindColumnClosestToPoint(xPhysical); if ( col != COL_NONE ) { static const int DROP_MARKER_WIDTH = 4; @@ -414,15 +432,24 @@ bool wxHeaderCtrl::EndReordering(int xPhysical) ReleaseMouse(); - const int colOld = m_colBeingReordered, - colNew = FindColumnAtPoint(xPhysical); + const int colOld = m_colBeingReordered; + const unsigned colNew = FindColumnClosestToPoint(xPhysical); m_colBeingReordered = COL_NONE; + // mouse drag must be longer than min distance m_dragOffset if ( xPhysical - GetColStart(colOld) == m_dragOffset ) + { return false; + } - if ( colNew != colOld ) + // cannot proceed without a valid column index + if ( colNew == COL_NONE ) + { + return false; + } + + if ( static_cast(colNew) != colOld ) { wxHeaderCtrlEvent event(wxEVT_HEADER_END_REORDER, GetId()); event.SetEventObject(this); diff --git a/src/generic/markuptext.cpp b/src/generic/markuptext.cpp index c883632b9d..e49938ccab 100644 --- a/src/generic/markuptext.cpp +++ b/src/generic/markuptext.cpp @@ -147,7 +147,7 @@ public: { // Setting the background colour is not enough, we must also change // the mode to ensure that it is actually used. - m_dc.SetBackgroundMode(wxSOLID); + m_dc.SetBackgroundMode(wxBRUSHSTYLE_SOLID); m_dc.SetTextBackground(attr.background); } } @@ -170,7 +170,7 @@ public: // should actually be made transparent and in this case the // actual value of background colour doesn't matter but we also // restore it just in case, see comment in the ctor. - m_dc.SetBackgroundMode(wxTRANSPARENT); + m_dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); background = m_origTextBackground; } @@ -260,7 +260,7 @@ public: const wxSize extent = m_dc.GetTextExtent(text); // DrawItemText() ignores background color, so render it ourselves - if ( m_dc.GetBackgroundMode() == wxSOLID ) + if ( m_dc.GetBackgroundMode() == wxBRUSHSTYLE_SOLID) { #if wxUSE_GRAPHICS_CONTEXT // Prefer to use wxGraphicsContext because it supports alpha channel; fall back to wxDC diff --git a/src/generic/odcombo.cpp b/src/generic/odcombo.cpp index 4f144bb751..12fb482dec 100644 --- a/src/generic/odcombo.cpp +++ b/src/generic/odcombo.cpp @@ -219,18 +219,15 @@ void wxVListBoxComboPopup::DismissWithEvent() int selection = wxVListBox::GetSelection(); - Dismiss(); - if ( selection != wxNOT_FOUND ) m_stringValue = m_strings[selection]; else m_stringValue.clear(); - if ( m_stringValue != m_combo->GetValue() ) - m_combo->SetValueByUser(m_stringValue); - m_value = selection; + Dismiss(); + SendComboBoxEvent(selection); } @@ -515,18 +512,20 @@ void wxVListBoxComboPopup::OnChar(wxKeyEvent& event) void wxVListBoxComboPopup::Insert( const wxString& item, int pos ) { // Need to change selection? - wxString strValue; - if ( !(m_combo->GetWindowStyle() & wxCB_READONLY) && - m_combo->GetValue() == item ) + if ( m_combo->GetValue() == item ) { - m_value = pos; + m_value = wxMin(m_value, pos); + } + else if ( pos <= m_value ) + { + m_value++; } m_strings.Insert(item,pos); if ( (int)m_clientDatas.size() >= pos ) m_clientDatas.Insert(NULL, pos); - m_widths.Insert(-1,pos); + m_widths.insert(m_widths.begin()+pos, -1); m_widthsDirty = true; if ( IsCreated() ) @@ -541,10 +540,8 @@ int wxVListBoxComboPopup::Append(const wxString& item) { // Find position // TODO: Could be optimized with binary search - wxArrayString strings = m_strings; - unsigned int i; - - for ( i=0; i& widths = m_widths; // I think using wxDC::GetTextExtent is faster than // wxWindow::GetTextExtent (assuming same dc is used @@ -729,7 +724,7 @@ void wxVListBoxComboPopup::CalcWidths() m_useFont = m_combo->GetFont(); dc.SetFont(m_useFont); - for ( i=0; i bestWidth ) @@ -847,17 +841,15 @@ wxSize wxVListBoxComboPopup::GetAdjustedSize( int minWidth, int prefHeight, int //void wxVListBoxComboPopup::Populate( int n, const wxString choices[] ) void wxVListBoxComboPopup::Populate( const wxArrayString& choices ) { - int i; - int n = choices.GetCount(); - for ( i=0; i rectDpy.height/2 ? wxTipKind_Bottom : wxTipKind_Top; diff --git a/src/generic/splitter.cpp b/src/generic/splitter.cpp index 26442e4577..e0d5c1900c 100644 --- a/src/generic/splitter.cpp +++ b/src/generic/splitter.cpp @@ -101,7 +101,7 @@ bool wxSplitterWindow::Create(wxWindow *parent, wxWindowID id, #if !defined(__WXGTK__) || defined(__WXGTK20__) // don't erase the splitter background, it's pointless as we overwrite it // anyhow - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); #endif return true; diff --git a/src/generic/tabg.cpp b/src/generic/tabg.cpp index 2580a9aece..a2e00b21d4 100644 --- a/src/generic/tabg.cpp +++ b/src/generic/tabg.cpp @@ -203,7 +203,7 @@ void wxTabControl::OnDraw(wxDC& dc, bool lastInRow) wxColour col(m_view->GetTextColour()); dc.SetTextForeground(col); - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); wxCoord textWidth, textHeight; dc.GetTextExtent(GetLabel(), &textWidth, &textHeight); @@ -474,7 +474,7 @@ void wxTabControl::OnDraw(wxDC& dc, bool lastInRow) wxColour col(m_view->GetTextColour()); dc.SetTextForeground(col); - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); long textWidth, textHeight; dc.GetTextExtent(GetLabel(), &textWidth, &textHeight); diff --git a/src/generic/timectrlg.cpp b/src/generic/timectrlg.cpp index 4037d6f56d..efa0af028d 100644 --- a/src/generic/timectrlg.cpp +++ b/src/generic/timectrlg.cpp @@ -86,7 +86,7 @@ public: // nice to add support to "%k" and "%l" (hours with leading blanks // instead of zeros) too as this is the most common unsupported case in // practice. -#if wxUSE_XLOCALE +#if wxUSE_INTL m_useAMPM = wxLocale::GetInfo(wxLOCALE_TIME_FMT).Contains("%p"); #else m_useAMPM = false; diff --git a/src/generic/toolbkg.cpp b/src/generic/toolbkg.cpp index 07cd9fa962..38be3659a5 100644 --- a/src/generic/toolbkg.cpp +++ b/src/generic/toolbkg.cpp @@ -42,7 +42,7 @@ wxDEFINE_EVENT( wxEVT_TOOLBOOK_PAGE_CHANGED, wxBookCtrlEvent ); wxBEGIN_EVENT_TABLE(wxToolbook, wxBookCtrlBase) EVT_SIZE(wxToolbook::OnSize) - EVT_TOOL_RANGE(1, 50, wxToolbook::OnToolSelected) + EVT_TOOL(wxID_ANY, wxToolbook::OnToolSelected) EVT_IDLE(wxToolbook::OnIdle) wxEND_EVENT_TABLE() @@ -134,8 +134,8 @@ void wxToolbook::OnSize(wxSizeEvent& event) bool wxToolbook::SetPageText(size_t n, const wxString& strText) { - // Assume tool ids start from 1 - wxToolBarToolBase* tool = GetToolBar()->FindById(n + 1); + int toolId = PageToToolId(n); + wxToolBarToolBase* tool = GetToolBar()->FindById(toolId); if (tool) { tool->SetLabel(strText); @@ -147,7 +147,8 @@ bool wxToolbook::SetPageText(size_t n, const wxString& strText) wxString wxToolbook::GetPageText(size_t n) const { - wxToolBarToolBase* tool = GetToolBar()->FindById(n + 1); + int toolId = PageToToolId(n); + wxToolBarToolBase* tool = GetToolBar()->FindById(toolId); if (tool) return tool->GetLabel(); else @@ -167,7 +168,10 @@ bool wxToolbook::SetPageImage(size_t n, int imageId) if (!GetImageList()) return false; - GetToolBar()->SetToolNormalBitmap(n + 1, GetImageList()->GetBitmap(imageId)); + int toolId = PageToToolId(n); + wxBitmap bmp = GetImageList()->GetBitmap(imageId); + GetToolBar()->SetToolNormalBitmap(toolId, bmp); + GetToolBar()->SetToolDisabledBitmap(toolId, bmp.ConvertToDisabled()); return true; } @@ -197,7 +201,8 @@ void wxToolbook::MakeChangedEvent(wxBookCtrlEvent &event) void wxToolbook::UpdateSelectedPage(size_t newsel) { - GetToolBar()->ToggleTool(newsel + 1, true); + int toolId = PageToToolId(newsel); + GetToolBar()->ToggleTool(toolId, true); } // Not part of the wxBookctrl API, but must be called in OnIdle or @@ -300,16 +305,30 @@ bool wxToolbook::InsertPage(size_t n, m_maxBitmapSize.x = wxMax(bitmap.GetWidth(), m_maxBitmapSize.x); m_maxBitmapSize.y = wxMax(bitmap.GetHeight(), m_maxBitmapSize.y); + int toolId = page->GetId(); GetToolBar()->SetToolBitmapSize(m_maxBitmapSize); - GetToolBar()->AddRadioTool(n + 1, text, bitmap, wxNullBitmap, text); + GetToolBar()->InsertTool(n, toolId, text, bitmap, bitmap.ConvertToDisabled(), wxITEM_RADIO); - if (bSelect) + // fix current selection + if (m_selection == wxNOT_FOUND) { - GetToolBar()->ToggleTool(n, true); + DoShowPage(page, true); m_selection = n; } + else if ((size_t) m_selection >= n) + { + DoShowPage(page, false); + m_selection++; + } else - page->Hide(); + { + DoShowPage(page, false); + } + + if ( bSelect ) + { + SetSelection(n); + } InvalidateBestSize(); return true; @@ -317,11 +336,12 @@ bool wxToolbook::InsertPage(size_t n, wxWindow *wxToolbook::DoRemovePage(size_t page) { + int toolId = PageToToolId(page); wxWindow *win = wxBookCtrlBase::DoRemovePage(page); if ( win ) { - GetToolBar()->DeleteTool(page + 1); + GetToolBar()->DeleteTool(toolId); DoSetSelectionAfterRemoval(page); } @@ -336,15 +356,60 @@ bool wxToolbook::DeleteAllPages() return wxBookCtrlBase::DeleteAllPages(); } +bool wxToolbook::EnablePage(size_t page, bool enable) +{ + int toolId = PageToToolId(page); + GetToolBar()->EnableTool(toolId, enable); + if (!enable && GetSelection() == (int)page) + { + AdvanceSelection(); + } + return true; +} + +bool wxToolbook::EnablePage(wxWindow *page, bool enable) +{ + const int pageIndex = FindPage(page); + if (pageIndex == wxNOT_FOUND) + { + return false; + } + return EnablePage(pageIndex, enable); +} + +int wxToolbook::PageToToolId(size_t page) const +{ + wxCHECK_MSG(page < GetPageCount(), wxID_NONE, "Invalid page number"); + return GetPage(page)->GetId(); +} + +int wxToolbook::ToolIdToPage(int toolId) const +{ + for (size_t i = 0; i < m_pages.size(); i++) + { + if (m_pages[i]->GetId() == toolId) + { + return (int) i; + } + } + return wxNOT_FOUND; +} + // ---------------------------------------------------------------------------- // wxToolbook events // ---------------------------------------------------------------------------- void wxToolbook::OnToolSelected(wxCommandEvent& event) { - const int selNew = event.GetId() - 1; + // find page for the tool + int page = ToolIdToPage(event.GetId()); + if (page == wxNOT_FOUND) + { + // this happens only of page id has changed afterwards + return; + } - if ( selNew == m_selection ) + if (page == m_selection ) { // this event can only come from our own Select(m_selection) below // which we call when the page change is vetoed, so we should simply @@ -352,10 +417,10 @@ void wxToolbook::OnToolSelected(wxCommandEvent& event) return; } - SetSelection(selNew); + SetSelection(page); // change wasn't allowed, return to previous state - if (m_selection != selNew) + if (m_selection != page) { GetToolBar()->ToggleTool(m_selection, false); } diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index de0fe661fc..6d0f120f46 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -1019,7 +1019,7 @@ bool wxGenericTreeCtrl::Create(wxWindow *parent, if (!m_hasFont) SetOwnFont(attr.font); - // this is a misnomer: it's called "dotted pen" but uses (default) wxSOLID + // this is a misnomer: it's called "dotted pen" but uses (default) wxPENSTYLE_SOLID // style because we apparently get performance problems when using dotted // pen for drawing in some ports -- but under MSW it seems to work fine #ifdef __WXMSW__ @@ -2292,7 +2292,7 @@ void wxGenericTreeCtrl::ScrollTo(const wxTreeItemId &item) // update the control before scrolling it if (m_dirty) { -#if defined( __WXMSW__ ) +#if defined( __WXMSW__ ) Update(); #elif defined(__WXMAC__) Update(); @@ -2301,7 +2301,7 @@ void wxGenericTreeCtrl::ScrollTo(const wxTreeItemId &item) DoDirtyProcessing(); #endif } - + wxGenericTreeItem *gitem = (wxGenericTreeItem*) item.m_pItem; int itemY = gitem->GetY(); @@ -2320,7 +2320,7 @@ void wxGenericTreeCtrl::ScrollTo(const wxTreeItemId &item) itemY += itemHeight - clientHeight; // because itemY below will be divided by PIXELS_PER_UNIT it may - // be rounded down, with the result of the item still only being + // be rounded down, with the result of the item still only being // partially visible, so make sure we are rounding up itemY += PIXELS_PER_UNIT - 1; } diff --git a/src/generic/vlbox.cpp b/src/generic/vlbox.cpp index 4aabd378ad..79f03a9bc0 100644 --- a/src/generic/vlbox.cpp +++ b/src/generic/vlbox.cpp @@ -95,7 +95,7 @@ bool wxVListBox::Create(wxWindow *parent, m_colBgSel = wxNullColour; // flicker-free drawing requires this - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); return true; } diff --git a/src/gtk/button.cpp b/src/gtk/button.cpp index 247c5150b8..97c4bc93e9 100644 --- a/src/gtk/button.cpp +++ b/src/gtk/button.cpp @@ -179,12 +179,14 @@ wxSize wxButtonBase::GetDefaultSize() GtkWidget *wnd = gtk_window_new(GTK_WINDOW_TOPLEVEL); GtkWidget *box = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL); -#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,10,0) +#ifdef __WXGTK4__ wxString labelGTK = GTKConvertMnemonics(wxGetStockLabel(wxID_CANCEL)); GtkWidget *btn = gtk_button_new_with_mnemonic(labelGTK.utf8_str()); #else + wxGCC_WARNING_SUPPRESS(deprecated-declarations) GtkWidget *btn = gtk_button_new_from_stock(GTK_STOCK_CANCEL); -#endif // GTK >= 3.10 / < 3.10 + wxGCC_WARNING_RESTORE() +#endif gtk_container_add(GTK_CONTAINER(box), btn); gtk_container_add(GTK_CONTAINER(wnd), box); GtkRequisition req; @@ -219,7 +221,8 @@ void wxButton::SetLabel( const wxString &lbl ) if ( HasFlag(wxBU_NOTEXT) ) return; -#if !defined(__WXGTK3__) || !GTK_CHECK_VERSION(3,10,0) +#ifndef __WXGTK4__ + wxGCC_WARNING_SUPPRESS(deprecated-declarations) if (wxIsStockID(m_windowId) && wxIsStockLabel(m_windowId, label)) { const char *stock = wxGetStockGtkID(m_windowId); @@ -230,7 +233,8 @@ void wxButton::SetLabel( const wxString &lbl ) return; } } -#endif // GTK < 3.10 + wxGCC_WARNING_RESTORE() +#endif // this call is necessary if the button had been initially created without // a (text) label -- then we didn't use gtk_button_new_with_mnemonic() and @@ -238,9 +242,11 @@ void wxButton::SetLabel( const wxString &lbl ) gtk_button_set_use_underline(GTK_BUTTON(m_widget), TRUE); const wxString labelGTK = GTKConvertMnemonics(label); gtk_button_set_label(GTK_BUTTON(m_widget), wxGTK_CONV(labelGTK)); -#if !defined(__WXGTK3__) || !GTK_CHECK_VERSION(3,10,0) +#ifndef __WXGTK4__ + wxGCC_WARNING_SUPPRESS(deprecated-declarations) gtk_button_set_use_stock(GTK_BUTTON(m_widget), FALSE); -#endif // GTK < 3.10 + wxGCC_WARNING_RESTORE() +#endif GTKApplyWidgetStyle( false ); } diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index 8e1a6503a3..d2c1abf352 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -5289,10 +5289,71 @@ void wxDataViewCtrl::HitTest(const wxPoint& point, } wxRect -wxDataViewCtrl::GetItemRect(const wxDataViewItem& WXUNUSED(item), - const wxDataViewColumn *WXUNUSED(column)) const +wxDataViewCtrl::GetItemRect(const wxDataViewItem& item, + const wxDataViewColumn *column) const { - return wxRect(); + if ( !item ) + return wxRect(); + + GtkTreeViewColumn *gcolumn = NULL ; + if (column) + gcolumn = GTK_TREE_VIEW_COLUMN(column->GetGtkHandle()); + + GtkTreeIter iter; + iter.user_data = item.GetID(); + wxGtkTreePath path(m_internal->get_path( &iter )); + + GdkRectangle item_rect; + gtk_tree_view_get_cell_area(GTK_TREE_VIEW(m_treeview), path, gcolumn, &item_rect); + + // GTK returns rectangles with the position and height, but not width, for + // some reason, set to 0 if the item is not currently shown, so an explicit + // check is needed as this rectangle is not quite the empty rectangle we're + // supposed to return in this case. + if ( item_rect.height == 0 ) + return wxRect(); + + // If column is NULL we compute the combined width of all the columns + if ( !column ) + { + unsigned int cols = GetColumnCount(); + int width = 0; + for (unsigned int i = 0; i < cols; ++i) + { + wxDataViewColumn * col = GetColumn(i); + if ( !col->IsHidden() ) + width += col->GetWidth(); + } + item_rect.width = width; + } + + // We need to convert logical coordinates to physical ones, i.e. the + // rectangle of the topmost item should start at ~0, even if it's a 100th + // item shown on top only because the window is scrolled. +#if GTK_CHECK_VERSION(2, 12, 0) + if ( wx_is_at_least_gtk2(12) ) + { + gtk_tree_view_convert_bin_window_to_widget_coords + ( + GTK_TREE_VIEW(m_treeview), + item_rect.x, item_rect.y, + &item_rect.x, &item_rect.y + ); + + if ( item_rect.y > GetClientSize().y || + item_rect.y + item_rect.height < 0 ) + { + // If it turns out that the item is not visible at all, indicate it + // by returning an empty rectangle for it. + return wxRect(); + } + } + //else: There doesn't seem to be anything reasonable to do here, so we'll + // just return wrong values with the very old GTK+ versions if the + // window is scrolled. +#endif // GTK+ 2.12+ + + return wxRectFromGDKRect(&item_rect); } bool wxDataViewCtrl::SetRowHeight(int rowHeight) diff --git a/src/gtk/dc.cpp b/src/gtk/dc.cpp index 3e7868173c..a41910ac32 100644 --- a/src/gtk/dc.cpp +++ b/src/gtk/dc.cpp @@ -15,6 +15,7 @@ #include "wx/dcclient.h" #include "wx/dcmemory.h" #include "wx/dcscreen.h" +#include "wx/display.h" #include "wx/gdicmn.h" #include "wx/icon.h" #include "wx/gtk/dc.h" @@ -238,7 +239,7 @@ wxSize wxGTKCairoDCImpl::GetPPI() const { if ( m_window ) { - return wxGetDisplayPPI(); + return wxDisplay(m_window).GetPPI(); } // For a non-window-based DC the concept of PPI doesn't make much sense diff --git a/src/gtk/dirdlg.cpp b/src/gtk/dirdlg.cpp index 04e9401c68..3514cc406e 100644 --- a/src/gtk/dirdlg.cpp +++ b/src/gtk/dirdlg.cpp @@ -85,23 +85,29 @@ bool wxDirDialog::Create(wxWindow* parent, if (parent) gtk_parent = GTK_WINDOW( gtk_widget_get_toplevel(parent->m_widget) ); +#ifndef __WXGTK4__ + wxGCC_WARNING_SUPPRESS(deprecated-declarations) +#endif m_widget = gtk_file_chooser_dialog_new( wxGTK_CONV(m_message), gtk_parent, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, -#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,10,0) +#ifdef __WXGTK4__ static_cast(wxGTK_CONV(wxConvertMnemonicsToGTK(wxGetStockLabel(wxID_CANCEL)))), #else GTK_STOCK_CANCEL, -#endif // GTK >= 3.10 / < 3.10 +#endif GTK_RESPONSE_CANCEL, -#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,10,0) +#ifdef __WXGTK4__ static_cast(wxGTK_CONV(wxConvertMnemonicsToGTK(wxGetStockLabel(wxID_OPEN)))), #else GTK_STOCK_OPEN, -#endif // GTK >= 3.10 / < 3.10 +#endif GTK_RESPONSE_ACCEPT, NULL); +#ifndef __WXGTK4__ + wxGCC_WARNING_RESTORE() +#endif g_object_ref(m_widget); gtk_dialog_set_default_response(GTK_DIALOG(m_widget), GTK_RESPONSE_ACCEPT); diff --git a/src/gtk/display.cpp b/src/gtk/display.cpp index 07e1fc45f3..7ab2c8d36b 100644 --- a/src/gtk/display.cpp +++ b/src/gtk/display.cpp @@ -46,6 +46,7 @@ public: virtual wxRect GetGeometry() const wxOVERRIDE; virtual wxRect GetClientArea() const wxOVERRIDE; virtual int GetDepth() const wxOVERRIDE; + virtual double GetScaleFactor() const wxOVERRIDE; virtual wxSize GetSizeMM() const wxOVERRIDE; #if wxUSE_DISPLAY @@ -121,6 +122,11 @@ int wxDisplayImplGTK::GetDepth() const return 24; } +double wxDisplayImplGTK::GetScaleFactor() const +{ + return gdk_monitor_get_scale_factor(m_monitor); +} + wxSize wxDisplayImplGTK::GetSizeMM() const { return wxSize @@ -222,6 +228,10 @@ public: virtual wxRect GetGeometry() const wxOVERRIDE; virtual wxRect GetClientArea() const wxOVERRIDE; virtual int GetDepth() const wxOVERRIDE; +#if GTK_CHECK_VERSION(3,10,0) + virtual double GetScaleFactor() const wxOVERRIDE; +#endif // GTK+ 3.10 + virtual wxSize GetPPI() const wxOVERRIDE; virtual wxSize GetSizeMM() const wxOVERRIDE; #if wxUSE_DISPLAY @@ -293,16 +303,36 @@ int wxDisplayImplGTK::GetDepth() const return gdk_visual_get_depth(gdk_window_get_visual(wxGetTopLevelGDK())); } -wxSize wxDisplayImplGTK::GetSizeMM() const +#if GTK_CHECK_VERSION(3,10,0) +double wxDisplayImplGTK::GetScaleFactor() const { - // At least in some configurations, gdk_screen_xxx_mm() functions return - // valid values when gdk_screen_get_monitor_xxx_mm() only return -1, so - // handle this case specially. - if ( IsPrimary() ) + if ( gtk_check_version(3,10,0) == NULL ) + return gdk_screen_get_monitor_scale_factor(m_screen, m_index); + + return 1.0; +} +#endif // GTK+ 3.10 + +wxSize wxDisplayImplGTK::GetPPI() const +{ + // Try the base class version which uses our GetSizeMM() and returns + // per-display PPI value if it works. + wxSize ppi = wxDisplayImpl::GetPPI(); + + if ( !ppi.x || !ppi.y ) { - return wxSize(gdk_screen_width_mm(), gdk_screen_height_mm()); + // But if it didn't work, fall back to the global DPI value common to + // all displays -- this is still better than nothing and more + // compatible with the previous wxWidgets versions. + ppi = ComputePPI(gdk_screen_width(), gdk_screen_height(), + gdk_screen_width_mm(), gdk_screen_height_mm()); } + return ppi; +} + +wxSize wxDisplayImplGTK::GetSizeMM() const +{ wxSize sizeMM; #if GTK_CHECK_VERSION(2,14,0) if ( wx_is_at_least_gtk2(14) ) @@ -318,6 +348,19 @@ wxSize wxDisplayImplGTK::GetSizeMM() const sizeMM.y = rc; } #endif // GTK+ 2.14 + + // When we have only a single display, we can use global GTK+ functions. + // Note that at least in some configurations, these functions return valid + // values when gdk_screen_get_monitor_xxx_mm() only return -1, so it's + // always worth fallng back on them, but we can't do it when using + // multiple displays because they combine the sizes of all displays in this + // case, which would result in a completely wrong value for GetPPI(). + if ( !(sizeMM.x && sizeMM.y) && gdk_screen_get_n_monitors(m_screen) == 1 ) + { + sizeMM.x = gdk_screen_width_mm(); + sizeMM.y = gdk_screen_height_mm(); + } + return sizeMM; } diff --git a/src/gtk/filedlg.cpp b/src/gtk/filedlg.cpp index 7aa39cdfb3..05449efc65 100644 --- a/src/gtk/filedlg.cpp +++ b/src/gtk/filedlg.cpp @@ -213,38 +213,44 @@ bool wxFileDialog::Create(wxWindow *parent, const wxString& message, if (parent) gtk_parent = GTK_WINDOW( gtk_widget_get_toplevel(parent->m_widget) ); +#ifndef __WXGTK4__ + wxGCC_WARNING_SUPPRESS(deprecated-declarations) +#endif wxString ok_btn_stock; if ( style & wxFD_SAVE ) { gtk_action = GTK_FILE_CHOOSER_ACTION_SAVE; -#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,10,0) +#ifdef __WXGTK4__ ok_btn_stock = wxConvertMnemonicsToGTK(wxGetStockLabel(wxID_SAVE)); #else ok_btn_stock = GTK_STOCK_SAVE; -#endif // GTK >= 3.10 / < 3.10 +#endif } else { gtk_action = GTK_FILE_CHOOSER_ACTION_OPEN; -#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,10,0) +#ifdef __WXGTK4__ ok_btn_stock = wxConvertMnemonicsToGTK(wxGetStockLabel(wxID_OPEN)); #else ok_btn_stock = GTK_STOCK_OPEN; -#endif // GTK >= 3.10 / < 3.10 +#endif } m_widget = gtk_file_chooser_dialog_new( wxGTK_CONV(m_message), gtk_parent, gtk_action, -#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,10,0) +#ifdef __WXGTK4__ static_cast(wxGTK_CONV(wxConvertMnemonicsToGTK(wxGetStockLabel(wxID_CANCEL)))), #else GTK_STOCK_CANCEL, -#endif // GTK >= 3.10 / < 3.10 +#endif GTK_RESPONSE_CANCEL, static_cast(wxGTK_CONV(ok_btn_stock)), GTK_RESPONSE_ACCEPT, NULL); +#ifndef __WXGTK4__ + wxGCC_WARNING_RESTORE() +#endif g_object_ref(m_widget); GtkFileChooser* file_chooser = GTK_FILE_CHOOSER(m_widget); diff --git a/src/gtk/msgdlg.cpp b/src/gtk/msgdlg.cpp index 77d2d6a0ea..25d67009f8 100644 --- a/src/gtk/msgdlg.cpp +++ b/src/gtk/msgdlg.cpp @@ -49,47 +49,57 @@ wxMessageDialog::wxMessageDialog(wxWindow *parent, wxString wxMessageDialog::GetDefaultYesLabel() const { -#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,10,0) +#ifdef __WXGTK4__ return wxConvertMnemonicsToGTK(wxGetStockLabel(wxID_YES)); #else + wxGCC_WARNING_SUPPRESS(deprecated-declarations) return GTK_STOCK_YES; -#endif // GTK >= 3.10 / < 3.10 + wxGCC_WARNING_RESTORE() +#endif } wxString wxMessageDialog::GetDefaultNoLabel() const { -#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,10,0) +#ifdef __WXGTK4__ return wxConvertMnemonicsToGTK(wxGetStockLabel(wxID_NO)); #else + wxGCC_WARNING_SUPPRESS(deprecated-declarations) return GTK_STOCK_NO; -#endif // GTK >= 3.10 / < 3.10 + wxGCC_WARNING_RESTORE() +#endif } wxString wxMessageDialog::GetDefaultOKLabel() const { -#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,10,0) +#ifdef __WXGTK4__ return wxConvertMnemonicsToGTK(wxGetStockLabel(wxID_OK)); #else + wxGCC_WARNING_SUPPRESS(deprecated-declarations) return GTK_STOCK_OK; -#endif // GTK >= 3.10 / < 3.10 + wxGCC_WARNING_RESTORE() +#endif } wxString wxMessageDialog::GetDefaultCancelLabel() const { -#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,10,0) +#ifdef __WXGTK4__ return wxConvertMnemonicsToGTK(wxGetStockLabel(wxID_CANCEL)); #else + wxGCC_WARNING_SUPPRESS(deprecated-declarations) return GTK_STOCK_CANCEL; -#endif // GTK >= 3.10 / < 3.10 + wxGCC_WARNING_RESTORE() +#endif } wxString wxMessageDialog::GetDefaultHelpLabel() const { -#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,10,0) +#ifdef __WXGTK4__ return wxConvertMnemonicsToGTK(wxGetStockLabel(wxID_HELP)); #else + wxGCC_WARNING_SUPPRESS(deprecated-declarations) return GTK_STOCK_HELP; -#endif // GTK >= 3.10 / < 3.10 + wxGCC_WARNING_RESTORE() +#endif } void wxMessageDialog::DoSetCustomLabel(wxString& var, const ButtonLabel& label) @@ -102,11 +112,11 @@ void wxMessageDialog::DoSetCustomLabel(wxString& var, const ButtonLabel& label) } else // stock label { -#if defined(__WXGTK3__) && GTK_CHECK_VERSION(3,10,0) +#ifdef __WXGTK4__ var = wxConvertMnemonicsToGTK(wxGetStockLabel(stockId)); #else var = wxGetStockGtkID(stockId); -#endif // GTK >= 3.10 / < 3.10 +#endif } } diff --git a/src/gtk/notebook.cpp b/src/gtk/notebook.cpp index 31978cb2b0..71bd4d8ec2 100644 --- a/src/gtk/notebook.cpp +++ b/src/gtk/notebook.cpp @@ -454,6 +454,12 @@ bool wxNotebook::InsertPage( size_t position, /* set the label text */ pageData->m_label = gtk_label_new(wxGTK_CONV(wxStripMenuCodes(text))); + + if (m_windowStyle & wxBK_LEFT) + gtk_label_set_angle(GTK_LABEL(pageData->m_label), 90); + if (m_windowStyle & wxBK_RIGHT) + gtk_label_set_angle(GTK_LABEL(pageData->m_label), 270); + gtk_box_pack_end(GTK_BOX(pageData->m_box), pageData->m_label, false, false, m_padding); diff --git a/src/gtk/toolbar.cpp b/src/gtk/toolbar.cpp index d6d399b4a7..df9733c111 100644 --- a/src/gtk/toolbar.cpp +++ b/src/gtk/toolbar.cpp @@ -196,7 +196,7 @@ image_expose_event(GtkWidget* widget, GdkEventExpose*, wxToolBarTool* tool) int y = (alloc.height - bitmap.GetScaledHeight()) / 2; #ifdef __WXGTK3__ gtk_render_background(gtk_widget_get_style_context(widget), - cr, alloc.x, alloc.y, alloc.width, alloc.height); + cr, 0, 0, alloc.width, alloc.height); bitmap.Draw(cr, x, y); #else x += alloc.x; diff --git a/src/gtk/webview_webkit2.cpp b/src/gtk/webview_webkit2.cpp index 81f9a9a667..656a10f778 100644 --- a/src/gtk/webview_webkit2.cpp +++ b/src/gtk/webview_webkit2.cpp @@ -407,13 +407,14 @@ wxgtk_initialize_web_extensions(WebKitWebContext *context, GVariant *user_data = g_variant_new("(s)", address); // The first value is the location in which the extension is supposed to be - // normally installed, while the other two are used as fallbacks to allow + // normally installed, while the other three are used as fallbacks to allow // running the tests and sample using wxWebView before installing it. const char* const directories[] = { WX_WEB_EXTENSIONS_DIRECTORY, "..", "../..", + "lib", }; const char* dir = NULL; diff --git a/src/gtk/win_gtk.cpp b/src/gtk/win_gtk.cpp index 98b17fe117..9057f30ed4 100644 --- a/src/gtk/win_gtk.cpp +++ b/src/gtk/win_gtk.cpp @@ -218,8 +218,6 @@ static void pizza_adjust_size_request(GtkWidget* widget, GtkOrientation orientat // will use the size request, if set, as the minimum. // But don't override if in a GtkToolbar, it uses the minimum as actual size. GtkWidget* parent = gtk_widget_get_parent(widget); - if (parent) - parent = gtk_widget_get_parent(parent); if (!GTK_IS_TOOL_ITEM(parent)) *minimum = 0; } diff --git a/src/gtk1/control.cpp b/src/gtk1/control.cpp index d533d86efb..57c5b14dbf 100644 --- a/src/gtk1/control.cpp +++ b/src/gtk1/control.cpp @@ -205,7 +205,7 @@ wxControl::GetDefaultAttributesFromGTKWidget(GtkWidget* widget, // get the style's font // TODO: isn't there a way to get a standard gtk 1.2 font? - attr.font = wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL ); + attr.font = wxFont( 12, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL ); return attr; } diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp index 1dacb1b416..623f049e72 100644 --- a/src/gtk1/dcclient.cpp +++ b/src/gtk1/dcclient.cpp @@ -49,8 +49,8 @@ #include "cross.xbm" #define num_hatches 6 -#define IS_15_PIX_HATCH(s) ((s)==wxCROSSDIAG_HATCH || (s)==wxHORIZONTAL_HATCH || (s)==wxVERTICAL_HATCH) -#define IS_16_PIX_HATCH(s) ((s)!=wxCROSSDIAG_HATCH && (s)!=wxHORIZONTAL_HATCH && (s)!=wxVERTICAL_HATCH) +#define IS_15_PIX_HATCH(s) ((s)==wxHATCHSTYLE_CROSSDIAG || (s)==wxHATCHSTYLE_HORIZONTAL || (s)==wxHATCHSTYLE_VERTICAL) +#define IS_16_PIX_HATCH(s) ((s)!=wxHATCHSTYLE_CROSSDIAG && (s)!=wxHATCHSTYLE_HORIZONTAL && (s)!=wxHATCHSTYLE_VERTICAL) static GdkPixmap *hatches[num_hatches]; @@ -453,7 +453,7 @@ void wxWindowDCImpl::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); - if (m_pen.GetStyle() != wxTRANSPARENT) + if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT) { if (m_window) gdk_draw_line( m_window, m_penGC, XLOG2DEV(x1), YLOG2DEV(y1), XLOG2DEV(x2), YLOG2DEV(y2) ); @@ -467,7 +467,7 @@ void wxWindowDCImpl::DoCrossHair( wxCoord x, wxCoord y ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); - if (m_pen.GetStyle() != wxTRANSPARENT) + if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT) { int w = 0; int h = 0; @@ -525,9 +525,9 @@ void wxWindowDCImpl::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, if (m_window) { - if (m_brush.GetStyle() != wxTRANSPARENT) + if (m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT) { - if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) + if ((m_brush.GetStyle() == wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) { gdk_gc_set_ts_origin( m_textGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), @@ -547,7 +547,7 @@ void wxWindowDCImpl::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, gdk_draw_arc( m_window, m_brushGC, TRUE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else - if (m_brush.GetStyle() == wxSTIPPLE) + if (m_brush.GetStyle() == wxBRUSHSTYLE_STIPPLE) { gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), @@ -561,7 +561,7 @@ void wxWindowDCImpl::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, } } - if (m_pen.GetStyle() != wxTRANSPARENT) + if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT) { gdk_draw_arc( m_window, m_penGC, FALSE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); @@ -592,9 +592,9 @@ void wxWindowDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxC wxCoord start = wxCoord(sa * 64.0); wxCoord end = wxCoord((ea-sa) * 64.0); - if (m_brush.GetStyle() != wxTRANSPARENT) + if (m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT) { - if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) + if ((m_brush.GetStyle() == wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) { gdk_gc_set_ts_origin( m_textGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), @@ -614,7 +614,7 @@ void wxWindowDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxC gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, start, end ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else - if (m_brush.GetStyle() == wxSTIPPLE) + if (m_brush.GetStyle() == wxBRUSHSTYLE_STIPPLE) { gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), @@ -628,7 +628,7 @@ void wxWindowDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxC } } - if (m_pen.GetStyle() != wxTRANSPARENT) + if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT) gdk_draw_arc( m_window, m_penGC, FALSE, xx, yy, ww, hh, start, end ); } @@ -640,7 +640,7 @@ void wxWindowDCImpl::DoDrawPoint( wxCoord x, wxCoord y ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); - if ((m_pen.GetStyle() != wxTRANSPARENT) && m_window) + if ((m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT) && m_window) gdk_draw_point( m_window, m_penGC, XLOG2DEV(x), YLOG2DEV(y) ); CalcBoundingBox (x, y); @@ -650,7 +650,7 @@ void wxWindowDCImpl::DoDrawLines( int n, const wxPoint points[], wxCoord xoffset { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); - if (m_pen.GetStyle() == wxTRANSPARENT) return; + if (m_pen.GetStyle() == wxPENSTYLE_TRANSPARENT) return; if (n <= 0) return; @@ -696,13 +696,13 @@ void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], wxCoord xoffs gpts[i].y = YLOG2DEV(y); } - if (m_brush.GetStyle() == wxSOLID) + if (m_brush.GetStyle() == wxBRUSHSTYLE_SOLID) { gdk_draw_polygon( m_window, m_brushGC, TRUE, gpts, n ); } - else if (m_brush.GetStyle() != wxTRANSPARENT) + else if (m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT) { - if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) + if ((m_brush.GetStyle() == wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) { gdk_gc_set_ts_origin( m_textGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), @@ -722,7 +722,7 @@ void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], wxCoord xoffs gdk_draw_polygon( m_window, m_brushGC, TRUE, gpts, n ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else - if (m_brush.GetStyle() == wxSTIPPLE) + if (m_brush.GetStyle() == wxBRUSHSTYLE_STIPPLE) { gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), @@ -736,7 +736,7 @@ void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], wxCoord xoffs } } - if (m_pen.GetStyle() != wxTRANSPARENT) + if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT) { gdk_draw_polygon( m_window, m_penGC, FALSE, gpts, n ); @@ -763,9 +763,9 @@ void wxWindowDCImpl::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoo if (m_window) { - if (m_brush.GetStyle() != wxTRANSPARENT) + if (m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT) { - if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) + if ((m_brush.GetStyle() == wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) { gdk_gc_set_ts_origin( m_textGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), @@ -785,7 +785,7 @@ void wxWindowDCImpl::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoo gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy, ww, hh ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else - if (m_brush.GetStyle() == wxSTIPPLE) + if (m_brush.GetStyle() == wxBRUSHSTYLE_STIPPLE) { gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), @@ -799,7 +799,7 @@ void wxWindowDCImpl::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoo } } - if (m_pen.GetStyle() != wxTRANSPARENT) + if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT) gdk_draw_rectangle( m_window, m_penGC, FALSE, xx, yy, ww-1, hh-1 ); } @@ -836,7 +836,7 @@ void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width // CMB: adjust size if outline is drawn otherwise the result is // 1 pixel too wide and high - if (m_pen.GetStyle() != wxTRANSPARENT) + if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT) { ww--; hh--; @@ -851,9 +851,9 @@ void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width if (dd > hh) dd = hh; rr = dd / 2; - if (m_brush.GetStyle() != wxTRANSPARENT) + if (m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT) { - if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) + if ((m_brush.GetStyle() == wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) { gdk_gc_set_ts_origin( m_textGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), @@ -888,7 +888,7 @@ void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else - if (m_brush.GetStyle() == wxSTIPPLE) + if (m_brush.GetStyle() == wxBRUSHSTYLE_STIPPLE) { gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), @@ -912,7 +912,7 @@ void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width } } - if (m_pen.GetStyle() != wxTRANSPARENT) + if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT) { gdk_draw_line( m_window, m_penGC, xx+rr+1, yy, xx+ww-rr, yy ); gdk_draw_line( m_window, m_penGC, xx+rr+1, yy+hh, xx+ww-rr, yy+hh ); @@ -945,9 +945,9 @@ void wxWindowDCImpl::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord if (m_window) { - if (m_brush.GetStyle() != wxTRANSPARENT) + if (m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT) { - if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) + if ((m_brush.GetStyle() == wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) { gdk_gc_set_ts_origin( m_textGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), @@ -967,7 +967,7 @@ void wxWindowDCImpl::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, 0, 360*64 ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else - if (m_brush.GetStyle() == wxSTIPPLE) + if (m_brush.GetStyle() == wxBRUSHSTYLE_STIPPLE) { gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), @@ -981,7 +981,7 @@ void wxWindowDCImpl::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord } } - if (m_pen.GetStyle() != wxTRANSPARENT) + if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT) gdk_draw_arc( m_window, m_penGC, FALSE, xx, yy, ww, hh, 0, 360*64 ); } @@ -1410,7 +1410,7 @@ void wxWindowDCImpl::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) wxCoord width = gdk_string_width( font, text.mbc_str() ); wxCoord height = font->ascent + font->descent; - if ( m_backgroundMode == wxSOLID ) + if ( m_backgroundMode == wxBRUSHSTYLE_SOLID ) { gdk_gc_set_foreground( m_textGC, m_textBackgroundColour.GetColor() ); gdk_draw_rectangle( m_window, m_textGC, TRUE, x, y, width, height ); @@ -1686,35 +1686,35 @@ void wxWindowDCImpl::SetPen( const wxPen &pen ) GdkLineStyle lineStyle = GDK_LINE_SOLID; switch (m_pen.GetStyle()) { - case wxUSER_DASH: + case wxPENSTYLE_USER_DASH: { lineStyle = GDK_LINE_ON_OFF_DASH; req_nb_dash = m_pen.GetDashCount(); req_dash = (wxGTKDash*)m_pen.GetDash(); break; } - case wxDOT: + case wxPENSTYLE_DOT: { lineStyle = GDK_LINE_ON_OFF_DASH; req_nb_dash = 2; req_dash = dotted; break; } - case wxLONG_DASH: + case wxPENSTYLE_LONG_DASH: { lineStyle = GDK_LINE_ON_OFF_DASH; req_nb_dash = 2; req_dash = wxCoord_dashed; break; } - case wxSHORT_DASH: + case wxPENSTYLE_SHORT_DASH: { lineStyle = GDK_LINE_ON_OFF_DASH; req_nb_dash = 2; req_dash = short_dashed; break; } - case wxDOT_DASH: + case wxPENSTYLE_DOT_DASH: { // lineStyle = GDK_LINE_DOUBLE_DASH; lineStyle = GDK_LINE_ON_OFF_DASH; @@ -1723,10 +1723,10 @@ void wxWindowDCImpl::SetPen( const wxPen &pen ) break; } - case wxTRANSPARENT: - case wxSTIPPLE_MASK_OPAQUE: - case wxSTIPPLE: - case wxSOLID: + case wxPENSTYLE_TRANSPARENT: + case wxPENSTYLE_STIPPLE_MASK_OPAQUE: + case wxPENSTYLE_STIPPLE: + case wxPENSTYLE_SOLID: default: { lineStyle = GDK_LINE_SOLID; @@ -1806,7 +1806,7 @@ void wxWindowDCImpl::SetBrush( const wxBrush &brush ) gdk_gc_set_fill( m_brushGC, GDK_SOLID ); - if ((m_brush.GetStyle() == wxSTIPPLE) && (m_brush.GetStipple()->IsOk())) + if ((m_brush.GetStyle() == wxBRUSHSTYLE_STIPPLE) && (m_brush.GetStipple()->IsOk())) { if (m_brush.GetStipple()->GetPixmap()) { @@ -1820,7 +1820,7 @@ void wxWindowDCImpl::SetBrush( const wxBrush &brush ) } } - if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) + if ((m_brush.GetStyle() == wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) { gdk_gc_set_fill( m_textGC, GDK_OPAQUE_STIPPLED); gdk_gc_set_stipple( m_textGC, m_brush.GetStipple()->GetMask()->GetBitmap() ); @@ -1829,7 +1829,7 @@ void wxWindowDCImpl::SetBrush( const wxBrush &brush ) if (m_brush.IsHatch()) { gdk_gc_set_fill( m_brushGC, GDK_STIPPLED ); - int num = m_brush.GetStyle() - wxBDIAGONAL_HATCH; + int num = m_brush.GetStyle() - wxBRUSHSTYLE_BDIAGONAL_HATCH; gdk_gc_set_stipple( m_brushGC, hatches[num] ); } } @@ -1857,7 +1857,7 @@ void wxWindowDCImpl::SetBackground( const wxBrush &brush ) gdk_gc_set_fill( m_bgGC, GDK_SOLID ); - if ((m_backgroundBrush.GetStyle() == wxSTIPPLE) && (m_backgroundBrush.GetStipple()->IsOk())) + if ((m_backgroundBrush.GetStyle() == wxBRUSHSTYLE_STIPPLE) && (m_backgroundBrush.GetStipple()->IsOk())) { if (m_backgroundBrush.GetStipple()->GetPixmap()) { @@ -1874,7 +1874,7 @@ void wxWindowDCImpl::SetBackground( const wxBrush &brush ) if (m_backgroundBrush.IsHatch()) { gdk_gc_set_fill( m_bgGC, GDK_STIPPLED ); - int num = m_backgroundBrush.GetStyle() - wxBDIAGONAL_HATCH; + int num = m_backgroundBrush.GetStyle() - wxBRUSHSTYLE_BDIAGONAL_HATCH; gdk_gc_set_stipple( m_bgGC, hatches[num] ); } } @@ -1974,10 +1974,10 @@ void wxWindowDCImpl::SetBackgroundMode( int mode ) // CMB 21/7/98: fill style of cross-hatch brushes is affected by // transparent/solid background mode - if (m_brush.GetStyle() != wxSOLID && m_brush.GetStyle() != wxTRANSPARENT) + if (m_brush.GetStyle() != wxBRUSHSTYLE_SOLID && m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT) { gdk_gc_set_fill( m_brushGC, - (m_backgroundMode == wxTRANSPARENT) ? GDK_STIPPLED : GDK_OPAQUE_STIPPLED); + (m_backgroundMode == wxBRUSHSTYLE_TRANSPARENT) ? GDK_STIPPLED : GDK_OPAQUE_STIPPLED); } } diff --git a/src/gtk1/font.cpp b/src/gtk1/font.cpp index c2460ca128..f0e8993714 100644 --- a/src/gtk1/font.cpp +++ b/src/gtk1/font.cpp @@ -202,7 +202,7 @@ void wxFontRefData::InitFromNative() m_pointSize = wxDEFAULT_FONT_SIZE; } - // examine the spacing: if the font is monospaced, assume wxTELETYPE + // examine the spacing: if the font is monospaced, assume wxFONTFAMILY_TELETYPE // family for compatibility with the old code which used it instead of // IsFixedWidth() if ( m_nativeFontInfo.GetXFontComponent(wxXLFD_SPACING).Upper() == wxT('M') ) diff --git a/src/gtk1/settings.cpp b/src/gtk1/settings.cpp index f3e00e58f9..94fbb80bc2 100644 --- a/src/gtk1/settings.cpp +++ b/src/gtk1/settings.cpp @@ -347,7 +347,7 @@ wxFont wxSystemSettingsNative::GetFont( wxSystemFont index ) { if (!gs_objects.m_fontSystem.IsOk()) { - gs_objects.m_fontSystem = wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL ); + gs_objects.m_fontSystem = wxFont( 12, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL ); } return gs_objects.m_fontSystem; } diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index d36a768d0c..fdc2e37a2c 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -2918,7 +2918,7 @@ void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags void wxWindowGTK::OnInternalIdle() { // Update style if the window was not yet realized - // and SetBackgroundStyle(wxBG_STYLE_CUSTOM) was called + // and SetBackgroundStyle(wxBG_STYLE_PAINT) was called if (m_needsStyleChange) { SetBackgroundStyle(GetBackgroundStyle()); @@ -3583,7 +3583,7 @@ void wxWindowGTK::GtkSendPaintEvents() wxEraseEvent erase_event( GetId(), &dc ); erase_event.SetEventObject( this ); - if (!HandleWindowEvent(erase_event) && GetBackgroundStyle() != wxBG_STYLE_CUSTOM) + if (!HandleWindowEvent(erase_event) && GetBackgroundStyle() != wxBG_STYLE_PAINT) { if (!g_eraseGC) { @@ -3705,7 +3705,7 @@ bool wxWindowGTK::SetBackgroundColour( const wxColour &colour ) // apply style change (forceStyle=true so that new style is applied // even if the bg colour changed from valid to wxNullColour) - if (GetBackgroundStyle() != wxBG_STYLE_CUSTOM) + if (GetBackgroundStyle() != wxBG_STYLE_PAINT) ApplyWidgetStyle(true); return true; @@ -3818,7 +3818,7 @@ bool wxWindowGTK::SetBackgroundStyle(wxBackgroundStyle style) { wxWindowBase::SetBackgroundStyle(style); - if (style == wxBG_STYLE_CUSTOM) + if (style == wxBG_STYLE_PAINT) { GdkWindow *window = NULL; if (m_wxwindow) diff --git a/src/html/htmlcell.cpp b/src/html/htmlcell.cpp index 1768178b65..465bdc60d7 100644 --- a/src/html/htmlcell.cpp +++ b/src/html/htmlcell.cpp @@ -400,7 +400,7 @@ static void SwitchSelState(wxDC& dc, wxHtmlRenderingInfo& info, if ( toSelection ) { - dc.SetBackgroundMode(wxSOLID); + dc.SetBackgroundMode(wxBRUSHSTYLE_SOLID); dc.SetTextForeground(info.GetStyle().GetSelectedTextColour(fg)); dc.SetTextBackground(info.GetStyle().GetSelectedTextBgColour(bg)); dc.SetBackground(info.GetStyle().GetSelectedTextBgColour(bg)); @@ -411,7 +411,7 @@ static void SwitchSelState(wxDC& dc, wxHtmlRenderingInfo& info, dc.SetBackgroundMode(mode); dc.SetTextForeground(fg); dc.SetTextBackground(bg); - if ( mode != wxTRANSPARENT ) + if ( mode != wxBRUSHSTYLE_TRANSPARENT ) dc.SetBackground(bg); } } @@ -1469,23 +1469,23 @@ void wxHtmlColourCell::DrawInvisible(wxDC& dc, if (m_Flags & wxHTML_CLR_BACKGROUND) { state.SetBgColour(m_Colour); - state.SetBgMode(wxSOLID); + state.SetBgMode(wxBRUSHSTYLE_SOLID); const wxColour c = state.GetSelectionState() == wxHTML_SEL_IN ? info.GetStyle().GetSelectedTextBgColour(m_Colour) : m_Colour; dc.SetTextBackground(c); dc.SetBackground(c); - dc.SetBackgroundMode(wxSOLID); + dc.SetBackgroundMode(wxBRUSHSTYLE_SOLID); } if (m_Flags & wxHTML_CLR_TRANSPARENT_BACKGROUND) { state.SetBgColour(m_Colour); - state.SetBgMode(wxTRANSPARENT); + state.SetBgMode(wxBRUSHSTYLE_TRANSPARENT); const wxColour c = state.GetSelectionState() == wxHTML_SEL_IN ? info.GetStyle().GetSelectedTextBgColour(m_Colour) : m_Colour; dc.SetTextBackground(c); - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); } } diff --git a/src/html/htmlwin.cpp b/src/html/htmlwin.cpp index eca5d83869..5befc5879f 100644 --- a/src/html/htmlwin.cpp +++ b/src/html/htmlwin.cpp @@ -1134,7 +1134,7 @@ void wxHtmlWindow::OnPaint(wxPaintEvent& WXUNUSED(event)) // draw the HTML window contents dc->SetMapMode(wxMM_TEXT); - dc->SetBackgroundMode(wxTRANSPARENT); + dc->SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); dc->SetLayoutDirection(GetLayoutDirection()); wxHtmlRenderingInfo rinfo; diff --git a/src/html/htmprint.cpp b/src/html/htmprint.cpp index 2ed4e19256..08a052eb8f 100644 --- a/src/html/htmprint.cpp +++ b/src/html/htmprint.cpp @@ -533,7 +533,7 @@ void wxHtmlPrintout::RenderPage(wxDC *dc, int page) (double)ppiPrinterY / TYPICAL_SCREEN_DPI, (double)ppiPrinterY / (double)ppiScreenY); - dc->SetBackgroundMode(wxTRANSPARENT); + dc->SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); m_Renderer.Render((int) (ppmm_h * m_MarginLeft), (int) (ppmm_v * (m_MarginTop + (m_HeaderHeight == 0 ? 0 : m_MarginSpace)) + m_HeaderHeight), diff --git a/src/html/m_fonts.cpp b/src/html/m_fonts.cpp index 6d039f99ae..109db31967 100644 --- a/src/html/m_fonts.cpp +++ b/src/html/m_fonts.cpp @@ -15,6 +15,7 @@ #if wxUSE_HTML && wxUSE_STREAMS #ifndef WX_PRECOMP + #include "wx/brush.h" #endif #include "wx/html/forcelnk.h" @@ -140,7 +141,7 @@ TAG_HANDLER_BEGIN(FONT, "FONT" ) m_WParser->SetActualBackgroundMode(oldbackmode); m_WParser->SetActualBackgroundColor(oldbackclr); m_WParser->GetContainer()->InsertCell( - new wxHtmlColourCell(oldbackclr, oldbackmode == wxTRANSPARENT ? wxHTML_CLR_TRANSPARENT_BACKGROUND : wxHTML_CLR_BACKGROUND)); + new wxHtmlColourCell(oldbackclr, oldbackmode == wxBRUSHSTYLE_TRANSPARENT ? wxHTML_CLR_TRANSPARENT_BACKGROUND : wxHTML_CLR_BACKGROUND)); } return true; diff --git a/src/html/m_links.cpp b/src/html/m_links.cpp index b5a6553ce6..66dbb10a3b 100644 --- a/src/html/m_links.cpp +++ b/src/html/m_links.cpp @@ -110,7 +110,7 @@ TAG_HANDLER_BEGIN(A, "A") m_WParser->SetActualBackgroundMode(oldbackmode); m_WParser->SetActualBackgroundColor(oldbackclr); m_WParser->GetContainer()->InsertCell( - new wxHtmlColourCell(oldbackclr, oldbackmode == wxTRANSPARENT ? wxHTML_CLR_TRANSPARENT_BACKGROUND : wxHTML_CLR_BACKGROUND)); + new wxHtmlColourCell(oldbackclr, oldbackmode == wxBRUSHSTYLE_TRANSPARENT ? wxHTML_CLR_TRANSPARENT_BACKGROUND : wxHTML_CLR_BACKGROUND)); } return true; diff --git a/src/html/m_span.cpp b/src/html/m_span.cpp index bb9e9facc5..9ef9d196c9 100644 --- a/src/html/m_span.cpp +++ b/src/html/m_span.cpp @@ -69,7 +69,7 @@ TAG_HANDLER_BEGIN(SPAN, "SPAN" ) m_WParser->SetActualBackgroundMode(oldbackmode); m_WParser->SetActualBackgroundColor(oldbackclr); m_WParser->GetContainer()->InsertCell( - new wxHtmlColourCell(oldbackclr, oldbackmode == wxTRANSPARENT ? wxHTML_CLR_TRANSPARENT_BACKGROUND : wxHTML_CLR_BACKGROUND)); + new wxHtmlColourCell(oldbackclr, oldbackmode == wxBRUSHSTYLE_TRANSPARENT ? wxHTML_CLR_TRANSPARENT_BACKGROUND : wxHTML_CLR_BACKGROUND)); } return true; diff --git a/src/html/winpars.cpp b/src/html/winpars.cpp index 0ac09fb108..96650b2b37 100644 --- a/src/html/winpars.cpp +++ b/src/html/winpars.cpp @@ -217,7 +217,7 @@ void wxHtmlWinParser::InitParser(const wxString& source) m_ActualBackgroundColor = m_windowInterface ? m_windowInterface->GetHTMLBackgroundColour() : windowColour; - m_ActualBackgroundMode = wxTRANSPARENT; + m_ActualBackgroundMode = wxBRUSHSTYLE_TRANSPARENT; m_Align = wxHTML_ALIGN_LEFT; m_ScriptMode = wxHTML_SCRIPT_NORMAL; m_ScriptBaseline = 0; @@ -248,7 +248,7 @@ void wxHtmlWinParser::InitParser(const wxString& source) new wxHtmlColourCell ( m_ActualBackgroundColor, - m_ActualBackgroundMode == wxTRANSPARENT ? wxHTML_CLR_TRANSPARENT_BACKGROUND : wxHTML_CLR_BACKGROUND + m_ActualBackgroundMode == wxBRUSHSTYLE_TRANSPARENT ? wxHTML_CLR_TRANSPARENT_BACKGROUND : wxHTML_CLR_BACKGROUND ) ); @@ -766,7 +766,7 @@ void wxHtmlWinTagHandler::ApplyStyle(const wxHtmlStyleParams &styleParams) if ( wxHtmlTag::ParseAsColour(str, &clr) ) { m_WParser->SetActualBackgroundColor(clr); - m_WParser->SetActualBackgroundMode(wxSOLID); + m_WParser->SetActualBackgroundMode(wxBRUSHSTYLE_SOLID); m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(clr, wxHTML_CLR_BACKGROUND)); } } diff --git a/src/motif/dc.cpp b/src/motif/dc.cpp index c4ba143e54..908c8f76d1 100644 --- a/src/motif/dc.cpp +++ b/src/motif/dc.cpp @@ -29,7 +29,7 @@ wxMotifDCImpl::wxMotifDCImpl(wxDC *owner) { m_ok = false; - m_backgroundMode = wxTRANSPARENT; + m_backgroundMode = wxBRUSHSTYLE_TRANSPARENT; } void wxMotifDCImpl::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y) diff --git a/src/motif/dcclient.cpp b/src/motif/dcclient.cpp index a85f36bfc2..edc154f80a 100644 --- a/src/motif/dcclient.cpp +++ b/src/motif/dcclient.cpp @@ -83,7 +83,7 @@ wxIMPLEMENT_ABSTRACT_CLASS(wxClientDCImpl, wxWindowDCImpl); wxIMPLEMENT_ABSTRACT_CLASS(wxPaintDCImpl, wxWindowDCImpl); wxIMPLEMENT_ABSTRACT_CLASS(wxWindowDCImpl, wxMotifDCImpl); -#define IS_HATCH(s) ((s)>=wxFIRST_HATCH && (s)<=wxLAST_HATCH) +#define IS_HATCH(s) ((s)>=wxHATCHSTYLE_FIRST && (s)<=wxHATCHSTYLE_LAST) // FIXME: left over after removal of wxDC::GetOptimization() #define GET_OPTIMIZATION false @@ -197,7 +197,7 @@ wxWindowDCImpl::wxWindowDCImpl(wxDC *owner, wxWindow *window) m_backgroundPixel = gcvalues.background; - SetBackground(wxBrush(m_window->GetBackgroundColour(), wxSOLID)); + SetBackground(wxBrush(m_window->GetBackgroundColour(), wxBRUSHSTYLE_SOLID)); } wxWindowDCImpl::~wxWindowDCImpl() @@ -346,7 +346,7 @@ void wxWindowDCImpl::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, while (alpha2 > 360 * 64) alpha2 -= 360 * 64; - if (m_brush.IsOk() && m_brush.GetStyle () != wxTRANSPARENT) + if (m_brush.IsOk() && m_brush.GetStyle () != wxBRUSHSTYLE_TRANSPARENT) { SetBrush (m_brush); XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) (GC) m_gc, @@ -358,7 +358,7 @@ void wxWindowDCImpl::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, } - if (m_pen.IsOk() && m_pen.GetStyle () != wxTRANSPARENT) + if (m_pen.IsOk() && m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT) { if (m_autoSetting) SetPen (m_pen); @@ -393,7 +393,7 @@ void wxWindowDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxC if (end>start) end-=start; else end+=360*64-start; - if (m_brush.IsOk() && m_brush.GetStyle () != wxTRANSPARENT) + if (m_brush.IsOk() && m_brush.GetStyle () != wxBRUSHSTYLE_TRANSPARENT) { m_autoSetting = true; // must be reset @@ -405,7 +405,7 @@ void wxWindowDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxC XLOG2DEV_2 (x), YLOG2DEV_2 (y),wd,hd,start,end); } - if (m_pen.IsOk() && m_pen.GetStyle () != wxTRANSPARENT) + if (m_pen.IsOk() && m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT) { if (m_autoSetting) SetPen (m_pen); @@ -436,7 +436,7 @@ void wxWindowDCImpl::DoDrawLines( int n, const wxPoint points[], wxCoord xoffset { wxCHECK_RET( IsOk(), "invalid dc" ); - if (m_pen.IsOk() && m_pen.GetStyle () != wxTRANSPARENT) + if (m_pen.IsOk() && m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT) { if (m_autoSetting) SetPen (m_pen); @@ -487,7 +487,7 @@ void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], xpoints2[i].x = xpoints2[0].x; xpoints2[i].y = xpoints2[0].y; - if (m_brush.IsOk() && m_brush.GetStyle () != wxTRANSPARENT) + if (m_brush.IsOk() && m_brush.GetStyle () != wxBRUSHSTYLE_TRANSPARENT) { SetBrush (m_brush); XSetFillRule ((Display*) m_display, (GC) m_gc, fillStyle == wxODDEVEN_RULE ? EvenOddRule : WindingRule); @@ -502,7 +502,7 @@ void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], } } - if (m_pen.IsOk() && m_pen.GetStyle () != wxTRANSPARENT) + if (m_pen.IsOk() && m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT) { if (m_autoSetting) SetPen (m_pen); @@ -533,7 +533,7 @@ void wxWindowDCImpl::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoo if (wd < 0) { wd = - wd; xd = xd - wd; } if (hd < 0) { hd = - hd; yd = yd - hd; } - if (m_brush.IsOk() && m_brush.GetStyle () != wxTRANSPARENT) + if (m_brush.IsOk() && m_brush.GetStyle () != wxBRUSHSTYLE_TRANSPARENT) { SetBrush (m_brush); XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wfd, hfd); @@ -544,7 +544,7 @@ void wxWindowDCImpl::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoo wfd, hfd); } - if (m_pen.IsOk() && m_pen.GetStyle () != wxTRANSPARENT) + if (m_pen.IsOk() && m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT) { if (m_autoSetting) SetPen (m_pen); @@ -589,7 +589,7 @@ void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width // CMB: adjust size if outline is drawn otherwise the result is // 1 pixel too wide and high - if (m_pen.GetStyle() != wxTRANSPARENT) + if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT) { wd--; hd--; @@ -611,7 +611,7 @@ void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width int rw_d2 = rd2 * 2; int rh_d2 = rw_d2; - if (m_brush.IsOk() && m_brush.GetStyle () != wxTRANSPARENT) + if (m_brush.IsOk() && m_brush.GetStyle () != wxBRUSHSTYLE_TRANSPARENT) { SetBrush (m_brush); @@ -661,7 +661,7 @@ void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width } } - if (m_pen.IsOk() && m_pen.GetStyle () != wxTRANSPARENT) + if (m_pen.IsOk() && m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT) { SetPen (m_pen); XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + rd, yd, @@ -745,7 +745,7 @@ void wxWindowDCImpl::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord wd = XLOG2DEVREL(width) ; hd = YLOG2DEVREL(height) ; - if (m_brush.IsOk() && m_brush.GetStyle () != wxTRANSPARENT) + if (m_brush.IsOk() && m_brush.GetStyle () != wxBRUSHSTYLE_TRANSPARENT) { SetBrush (m_brush); XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wd, hd, 0, angle); @@ -756,7 +756,7 @@ void wxWindowDCImpl::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord YLOG2DEVREL (height) - WX_GC_CF, 0, angle); } - if (m_pen.IsOk() && m_pen.GetStyle () != wxTRANSPARENT) + if (m_pen.IsOk() && m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT) { if (m_autoSetting) SetPen (m_pen); @@ -1048,7 +1048,7 @@ void wxWindowDCImpl::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) // First draw a rectangle representing the text background, if a text // background is specified - if (m_textBackgroundColour.IsOk () && (m_backgroundMode != wxTRANSPARENT)) + if (m_textBackgroundColour.IsOk () && (m_backgroundMode != wxBRUSHSTYLE_TRANSPARENT)) { wxColour oldPenColour = m_currentColour; m_currentColour = m_textBackgroundColour; @@ -1243,7 +1243,7 @@ void wxWindowDCImpl::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord { bool textPixel = image.GetRed(sx, sy) == 0; - if (!textPixel && m_backgroundMode != wxSOLID) + if (!textPixel && m_backgroundMode != wxBRUSHSTYLE_SOLID) continue; wxCoord ox = (wxCoord) (x1 + rx), @@ -1510,7 +1510,7 @@ void wxWindowDCImpl::SetPen( const wxPen &pen ) m_currentPenDashCount = m_pen.GetDashCount(); m_currentPenDash = (wxX11Dash*)m_pen.GetDash(); - if (m_currentStyle == wxSTIPPLE) + if (m_currentStyle == wxPENSTYLE_STIPPLE) m_currentStipple = * m_pen.GetStipple (); bool sameStyle = (oldStyle == m_currentStyle && @@ -1548,34 +1548,34 @@ void wxWindowDCImpl::SetPen( const wxPen &pen ) switch (m_pen.GetStyle ()) { - case wxUSER_DASH: + case wxPENSTYLE_USER_DASH: req_nb_dash = m_currentPenDashCount; req_dash = m_currentPenDash; style = LineOnOffDash; break; - case wxDOT: + case wxPENSTYLE_DOT: req_nb_dash = 2; req_dash = dotted; style = LineOnOffDash; break; - case wxSHORT_DASH: + case wxPENSTYLE_SHORT_DASH: req_nb_dash = 2; req_dash = short_dashed; style = LineOnOffDash; break; - case wxLONG_DASH: + case wxPENSTYLE_LONG_DASH: req_nb_dash = 2; req_dash = long_dashed; style = LineOnOffDash; break; - case wxDOT_DASH: + case wxPENSTYLE_DOT_DASH: req_nb_dash = 4; req_dash = dotted_dashed; style = LineOnOffDash; break; - case wxSTIPPLE: - case wxSOLID: - case wxTRANSPARENT: + case wxPENSTYLE_STIPPLE: + case wxPENSTYLE_SOLID: + case wxPENSTYLE_TRANSPARENT: default: style = LineSolid; req_dash = NULL; @@ -1648,42 +1648,42 @@ void wxWindowDCImpl::SetPen( const wxPen &pen ) switch (m_currentFill) { - case wxBDIAGONAL_HATCH: + case wxHATCHSTYLE_BDIAGONAL: if (bdiag == (Pixmap) 0) bdiag = XCreateBitmapFromData ((Display*) m_display, RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), reinterpret_cast(bdiag_bits), bdiag_width, bdiag_height); myStipple = bdiag; break; - case wxFDIAGONAL_HATCH: + case wxHATCHSTYLE_FDIAGONAL: if (fdiag == (Pixmap) 0) fdiag = XCreateBitmapFromData ((Display*) m_display, RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), reinterpret_cast(fdiag_bits), fdiag_width, fdiag_height); myStipple = fdiag; break; - case wxCROSS_HATCH: + case wxHATCHSTYLE_CROSS: if (cross == (Pixmap) 0) cross = XCreateBitmapFromData ((Display*) m_display, RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), reinterpret_cast(cross_bits), cross_width, cross_height); myStipple = cross; break; - case wxHORIZONTAL_HATCH: + case wxHATCHSTYLE_HORIZONTAL: if (horiz == (Pixmap) 0) horiz = XCreateBitmapFromData ((Display*) m_display, RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), reinterpret_cast(horiz_bits), horiz_width, horiz_height); myStipple = horiz; break; - case wxVERTICAL_HATCH: + case wxHATCHSTYLE_VERTICAL: if (verti == (Pixmap) 0) verti = XCreateBitmapFromData ((Display*) m_display, RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), reinterpret_cast(verti_bits), verti_width, verti_height); myStipple = verti; break; - case wxCROSSDIAG_HATCH: + case wxHATCHSTYLE_CROSSDIAG: default: if (cdiag == (Pixmap) 0) cdiag = XCreateBitmapFromData ((Display*) m_display, @@ -1697,7 +1697,7 @@ void wxWindowDCImpl::SetPen( const wxPen &pen ) if (m_window && m_window->GetBackingPixmap()) XSetStipple ((Display*) m_display,(GC) m_gcBacking, myStipple); } - else if (m_currentStyle == wxSTIPPLE && m_currentStipple.IsOk() + else if (m_currentStyle == wxPENSTYLE_STIPPLE && m_currentStipple.IsOk() && ((!m_currentStipple.IsSameAs(oldStipple)) || !GET_OPTIMIZATION)) { XSetStipple ((Display*) m_display, (GC) m_gc, (Pixmap) m_currentStipple.GetDrawable()); @@ -1710,7 +1710,7 @@ void wxWindowDCImpl::SetPen( const wxPen &pen ) { int fill_style; - if (m_currentFill == wxSTIPPLE) + if (m_currentFill == wxBRUSHSTYLE_STIPPLE) fill_style = FillStippled; else if (IS_HATCH (m_currentFill)) fill_style = FillStippled; @@ -1726,7 +1726,7 @@ void wxWindowDCImpl::SetPen( const wxPen &pen ) || ((m_logicalFunction == wxXOR) || (m_autoSetting & 0x2))) { WXPixel pixel = -1; - if (m_pen.GetStyle () == wxTRANSPARENT) + if (m_pen.GetStyle () == wxPENSTYLE_TRANSPARENT) pixel = m_backgroundPixel; else { @@ -1751,7 +1751,7 @@ void wxWindowDCImpl::SetBrush( const wxBrush &brush ) m_brush = brush; - if (!m_brush.IsOk() || m_brush.GetStyle () == wxTRANSPARENT) + if (!m_brush.IsOk() || m_brush.GetStyle () == wxBRUSHSTYLE_TRANSPARENT) return; int oldFill = m_currentFill; @@ -1760,7 +1760,7 @@ void wxWindowDCImpl::SetBrush( const wxBrush &brush ) m_autoSetting |= 0x1; m_currentFill = m_brush.GetStyle (); - if (m_currentFill == wxSTIPPLE) + if (m_currentFill == wxBRUSHSTYLE_STIPPLE) m_currentStipple = * m_brush.GetStipple (); wxColour oldBrushColour(m_currentColour); @@ -1778,17 +1778,17 @@ void wxWindowDCImpl::SetBrush( const wxBrush &brush ) { switch (brush.GetStyle ()) { - case wxTRANSPARENT: + case wxBRUSHSTYLE_TRANSPARENT: break; - case wxSTIPPLE: + case wxBRUSHSTYLE_STIPPLE: stippleDepth = m_currentStipple.GetDepth(); // fall through! - case wxBDIAGONAL_HATCH: - case wxCROSSDIAG_HATCH: - case wxFDIAGONAL_HATCH: - case wxCROSS_HATCH: - case wxHORIZONTAL_HATCH: - case wxVERTICAL_HATCH: + case wxBRUSHSTYLE_BDIAGONAL_HATCH: + case wxBRUSHSTYLE_CROSSDIAG_HATCH: + case wxBRUSHSTYLE_FDIAGONAL_HATCH: + case wxBRUSHSTYLE_CROSS_HATCH: + case wxBRUSHSTYLE_HORIZONTAL_HATCH: + case wxBRUSHSTYLE_VERTICAL_HATCH: { if (stippleDepth == -1) stippleDepth = 1; @@ -1796,7 +1796,7 @@ void wxWindowDCImpl::SetBrush( const wxBrush &brush ) // determine whether fill style should be solid or // transparent int style = stippleDepth == 1 ? - (m_backgroundMode == wxSOLID ? + (m_backgroundMode == wxBRUSHSTYLE_SOLID ? FillOpaqueStippled : FillStippled) : FillTiled; XSetFillStyle ((Display*) m_display, (GC) m_gc, style); @@ -1804,7 +1804,7 @@ void wxWindowDCImpl::SetBrush( const wxBrush &brush ) XSetFillStyle ((Display*) m_display,(GC) m_gcBacking, style); } break; - case wxSOLID: + case wxBRUSHSTYLE_SOLID: default: XSetFillStyle ((Display*) m_display, (GC) m_gc, FillSolid); if (m_window && m_window->GetBackingPixmap()) @@ -1819,42 +1819,42 @@ void wxWindowDCImpl::SetBrush( const wxBrush &brush ) switch (m_currentFill) { - case wxBDIAGONAL_HATCH: + case wxHATCHSTYLE_BDIAGONAL: if (bdiag == (Pixmap) 0) bdiag = XCreateBitmapFromData ((Display*) m_display, RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), reinterpret_cast(bdiag_bits), bdiag_width, bdiag_height); myStipple = bdiag; break; - case wxFDIAGONAL_HATCH: + case wxHATCHSTYLE_FDIAGONAL: if (fdiag == (Pixmap) 0) fdiag = XCreateBitmapFromData ((Display*) m_display, RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), reinterpret_cast(fdiag_bits), fdiag_width, fdiag_height); myStipple = fdiag; break; - case wxCROSS_HATCH: + case wxHATCHSTYLE_CROSS: if (cross == (Pixmap) 0) cross = XCreateBitmapFromData ((Display*) m_display, RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), reinterpret_cast(cross_bits), cross_width, cross_height); myStipple = cross; break; - case wxHORIZONTAL_HATCH: + case wxHATCHSTYLE_HORIZONTAL: if (horiz == (Pixmap) 0) horiz = XCreateBitmapFromData ((Display*) m_display, RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), reinterpret_cast(horiz_bits), horiz_width, horiz_height); myStipple = horiz; break; - case wxVERTICAL_HATCH: + case wxHATCHSTYLE_VERTICAL: if (verti == (Pixmap) 0) verti = XCreateBitmapFromData ((Display*) m_display, RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)), reinterpret_cast(verti_bits), verti_width, verti_height); myStipple = verti; break; - case wxCROSSDIAG_HATCH: + case wxHATCHSTYLE_CROSSDIAG: default: if (cdiag == (Pixmap) 0) cdiag = XCreateBitmapFromData ((Display*) m_display, @@ -1870,7 +1870,7 @@ void wxWindowDCImpl::SetBrush( const wxBrush &brush ) } // X can forget the stipple value when resizing a window (apparently) // so always set the stipple. - else if (m_currentFill != wxSOLID && m_currentFill != wxTRANSPARENT && + else if (m_currentFill != wxBRUSHSTYLE_SOLID && m_currentFill != wxBRUSHSTYLE_TRANSPARENT && m_currentStipple.IsOk()) // && m_currentStipple != oldStipple) { if (m_currentStipple.GetDepth() == 1) diff --git a/src/motif/settings.cpp b/src/motif/settings.cpp index 04f2b66dc1..11fd4e7098 100644 --- a/src/motif/settings.cpp +++ b/src/motif/settings.cpp @@ -179,7 +179,7 @@ wxFont wxSystemSettingsNative::GetFont(wxSystemFont index) { case wxSYS_SYSTEM_FIXED_FONT: { - font = wxFont(pointSize, wxMODERN, wxNORMAL, wxNORMAL, false); + font = wxFont(pointSize, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false); break; } case wxSYS_DEVICE_DEFAULT_FONT: @@ -187,7 +187,7 @@ wxFont wxSystemSettingsNative::GetFont(wxSystemFont index) case wxSYS_DEFAULT_GUI_FONT: default: { - font = wxFont(pointSize, wxSWISS, wxNORMAL, wxNORMAL, false); + font = wxFont(pointSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false); break; } } diff --git a/src/motif/utils.cpp b/src/motif/utils.cpp index 480faad86e..210644e9ff 100644 --- a/src/motif/utils.cpp +++ b/src/motif/utils.cpp @@ -629,7 +629,7 @@ wxBitmap wxCreateMaskedBitmap(const wxBitmap& bitmap, const wxColour& colour) srcDC.SelectObjectAsSource(bitmap); destDC.SelectObject(newBitmap); - wxBrush brush(colour, wxSOLID); + wxBrush brush(colour, wxBRUSHSTYLE_SOLID); destDC.SetBackground(brush); destDC.Clear(); destDC.Blit(0, 0, bitmap.GetWidth(), bitmap.GetHeight(), diff --git a/src/motif/window.cpp b/src/motif/window.cpp index c29f053997..fe91644faf 100644 --- a/src/motif/window.cpp +++ b/src/motif/window.cpp @@ -886,7 +886,7 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect) XCopyArea(display, window, window, gc, x1, y1, w1, h1, x2, y2); dcimpl->SetAutoSetting(true); - wxBrush brush(GetBackgroundColour(), wxSOLID); + wxBrush brush(GetBackgroundColour(), wxBRUSHSTYLE_SOLID); dc.SetBrush(brush); // FIXME: needed? wxWindowList::compatibility_iterator cnode = m_children.GetFirst(); @@ -1537,7 +1537,7 @@ void wxWindow::Refresh(bool eraseBack, const wxRect *rect) if (eraseBack) { wxClientDC dc(this); - wxBrush backgroundBrush(GetBackgroundColour(), wxSOLID); + wxBrush backgroundBrush(GetBackgroundColour(), wxBRUSHSTYLE_SOLID); dc.SetBackground(backgroundBrush); wxClientDCImpl * const diff --git a/src/msw/anybutton.cpp b/src/msw/anybutton.cpp index a589aed3d7..c2daf84c7d 100644 --- a/src/msw/anybutton.cpp +++ b/src/msw/anybutton.cpp @@ -280,7 +280,7 @@ public: { default: wxFAIL_MSG( "invalid image alignment" ); - // fall through + wxFALLTHROUGH; case BUTTON_IMAGELIST_ALIGN_LEFT: return wxLEFT; @@ -303,7 +303,7 @@ public: { default: wxFAIL_MSG( "invalid direction" ); - // fall through + wxFALLTHROUGH; case wxLEFT: alignNew = BUTTON_IMAGELIST_ALIGN_LEFT; @@ -524,7 +524,9 @@ void wxAnyButton::AdjustForBitmapSize(wxSize &size) const { wxUxThemeHandle theme(const_cast(this), L"BUTTON"); - MARGINS margins; + // Initialize margins with the default values (at least under + // Windows 7) in case GetThemeMargins() fails. + MARGINS margins = {3, 3, 3, 3}; ::GetThemeMargins(theme, NULL, BP_PUSHBUTTON, PBS_NORMAL, @@ -1148,8 +1150,9 @@ void DrawXPBackground(wxAnyButton *button, HDC hdc, RECT& rectBtn, UINT state) ::DrawThemeBackground(theme, hdc, BP_PUSHBUTTON, iState, &rectBtn, NULL); - // calculate content area margins - MARGINS margins; + // calculate content area margins, using the defaults in case we fail to + // retrieve the current theme margins + MARGINS margins = {3, 3, 3, 3}; ::GetThemeMargins(theme, hdc, BP_PUSHBUTTON, iState, TMT_CONTENTMARGINS, &rectBtn, &margins); ::InflateRect(&rectBtn, -margins.cxLeftWidth, -margins.cyTopHeight); @@ -1343,7 +1346,7 @@ bool wxAnyButton::MSWOnDraw(WXDRAWITEMSTRUCT *wxdis) { default: wxFAIL_MSG( "invalid direction" ); - // fall through + wxFALLTHROUGH; case wxLEFT: rectBitmap.x = rectButton.x + margin.x; diff --git a/src/msw/app.cpp b/src/msw/app.cpp index 2c3d14273b..d6af9e833c 100644 --- a/src/msw/app.cpp +++ b/src/msw/app.cpp @@ -978,7 +978,7 @@ terminate the program,\r\n\ default: wxFAIL_MSG( wxT("unexpected MessageBox() return code") ); - // fall through + wxFALLTHROUGH; case IDRETRY: return false; diff --git a/src/msw/artmsw.cpp b/src/msw/artmsw.cpp index eb7a6c4ec8..1d836fd56e 100644 --- a/src/msw/artmsw.cpp +++ b/src/msw/artmsw.cpp @@ -25,6 +25,7 @@ #include "wx/volume.h" #include "wx/msw/private.h" #include "wx/msw/wrapwin.h" +#include "wx/msw/wrapshl.h" #ifdef SHGSI_ICON #define wxHAS_SHGetStockIconInfo @@ -33,6 +34,39 @@ namespace { +#ifdef SHDefExtractIcon + #define MSW_SHDefExtractIcon SHDefExtractIcon +#else // !defined(SHDefExtractIcon) + +// MinGW doesn't provide SHDefExtractIcon() up to at least the 5.3 version, so +// define it ourselves. +HRESULT +MSW_SHDefExtractIcon(LPCTSTR pszIconFile, int iIndex, UINT uFlags, + HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize) +{ + typedef HRESULT + (WINAPI *SHDefExtractIcon_t)(LPCTSTR, int, UINT, HICON*, HICON*, UINT); + + static SHDefExtractIcon_t s_SHDefExtractIcon = NULL; + if ( !s_SHDefExtractIcon ) + { + wxDynamicLibrary shell32(wxT("shell32.dll")); + wxDL_INIT_FUNC_AW(s_, SHDefExtractIcon, shell32); + + if ( !s_SHDefExtractIcon ) + return E_FAIL; + + // Prevent the DLL from being unloaded while we use its function. + // Normally it's not a problem as shell32.dll is always loaded anyhow. + shell32.Detach(); + } + + return (*s_SHDefExtractIcon)(pszIconFile, iIndex, uFlags, + phiconLarge, phiconSmall, nIconSize); +} + +#endif // !defined(SHDefExtractIcon) + #ifdef wxHAS_SHGetStockIconInfo SHSTOCKICONID MSWGetStockIconIdForArtProviderId(const wxArtID& art_id) @@ -51,6 +85,9 @@ SHSTOCKICONID MSWGetStockIconIdForArtProviderId(const wxArtID& art_id) else if ( art_id == wxART_FLOPPY ) return SIID_DRIVE35; else if ( art_id == wxART_CDROM ) return SIID_DRIVECD; else if ( art_id == wxART_REMOVABLE ) return SIID_DRIVEREMOVE; + else if ( art_id == wxART_PRINT ) return SIID_PRINTER; + else if ( art_id == wxART_EXECUTABLE_FILE ) return SIID_APPLICATION; + else if ( art_id == wxART_NORMAL_FILE ) return SIID_DOCNOASSOC; return SIID_INVALID; }; @@ -81,32 +118,38 @@ MSW_SHGetStockIconInfo(SHSTOCKICONID siid, #endif // #ifdef wxHAS_SHGetStockIconInfo +// Wrapper for SHDefExtractIcon(). +wxBitmap +MSWGetBitmapFromIconLocation(const TCHAR* path, int index, const wxSize& size) +{ + HICON hIcon = NULL; + if ( MSW_SHDefExtractIcon(path, index, 0, &hIcon, NULL, size.x) != S_OK ) + return wxNullBitmap; + + // Note that using "size.x" twice here is not a typo: normally size.y is + // the same anyhow, of course, but if it isn't, the actual icon size would + // be size.x in both directions as we only pass "x" to SHDefExtractIcon() + // above. + wxIcon icon; + if ( !icon.InitFromHICON((WXHICON)hIcon, size.x, size.x) ) + return wxNullBitmap; + + return wxBitmap(icon); +} + wxBitmap MSWGetBitmapForPath(const wxString& path, const wxSize& size, DWORD uFlags = 0) { SHFILEINFO fi; wxZeroMemory(fi); - uFlags |= SHGFI_USEFILEATTRIBUTES | SHGFI_ICON; - if ( size != wxDefaultSize ) - { - if ( size.x <= 16 ) - uFlags |= SHGFI_SMALLICON; - else if ( size.x >= 64 ) - uFlags |= SHGFI_LARGEICON; - } + uFlags |= SHGFI_USEFILEATTRIBUTES | SHGFI_ICONLOCATION; if ( !SHGetFileInfo(path.t_str(), FILE_ATTRIBUTE_DIRECTORY, &fi, sizeof(SHFILEINFO), uFlags) ) - return wxNullBitmap; + return wxNullBitmap; - wxIcon icon; - icon.CreateFromHICON((WXHICON)fi.hIcon); - - wxBitmap bitmap(icon); - ::DestroyIcon(fi.hIcon); - - return bitmap; + return MSWGetBitmapFromIconLocation(fi.szDisplayName, fi.iIcon, size); } #if wxUSE_FSVOLUME @@ -178,33 +221,21 @@ wxBitmap wxWindowsArtProvider::CreateBitmap(const wxArtID& id, { WinStruct sii; - UINT uFlags = SHGSI_ICON; - if ( size != wxDefaultSize ) - { - if ( size.x <= 16 ) - uFlags |= SHGSI_SMALLICON; - else if ( size.x >= 64 ) - uFlags |= SHGSI_LARGEICON; - } + UINT uFlags = SHGSI_ICONLOCATION | SHGSI_SYSICONINDEX; HRESULT res = MSW_SHGetStockIconInfo(stockIconId, uFlags, &sii); if ( res == S_OK ) { - wxIcon icon; - icon.CreateFromHICON( (WXHICON)sii.hIcon ); - - bitmap = wxBitmap(icon); - ::DestroyIcon(sii.hIcon); + const wxSize + sizeNeeded = size.IsFullySpecified() + ? size + : wxArtProvider::GetNativeSizeHint(client); + bitmap = MSWGetBitmapFromIconLocation(sii.szPath, sii.iIcon, + sizeNeeded); if ( bitmap.IsOk() ) { - const wxSize - sizeNeeded = size.IsFullySpecified() - ? size - : wxArtProvider::GetNativeSizeHint(client); - - if ( sizeNeeded.IsFullySpecified() && - bitmap.GetSize() != sizeNeeded ) + if ( bitmap.GetSize() != sizeNeeded ) { wxArtProvider::RescaleBitmap(bitmap, sizeNeeded); } diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index 57bcdc4fd4..3ceea0022c 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -558,6 +558,7 @@ bool wxBitmap::CopyFromIconOrCursor(const wxGDIImage& icon, { default: wxFAIL_MSG( wxT("unknown wxBitmapTransparency value") ); + wxFALLTHROUGH; case wxBitmapTransparency_None: // nothing to do, refData->m_hasAlpha is false by default diff --git a/src/msw/brush.cpp b/src/msw/brush.cpp index f47d6d4bd2..da94288a53 100644 --- a/src/msw/brush.cpp +++ b/src/msw/brush.cpp @@ -186,7 +186,7 @@ HBRUSH wxBrushRefData::GetHBRUSH() default: wxFAIL_MSG( wxT("unknown brush style") ); - // fall through + wxFALLTHROUGH; case wxBRUSHSTYLE_SOLID: m_hBrush = ::CreateSolidBrush(m_colour.GetPixel()); diff --git a/src/msw/calctrl.cpp b/src/msw/calctrl.cpp index a538ff60f1..f03a3f5cbd 100644 --- a/src/msw/calctrl.cpp +++ b/src/msw/calctrl.cpp @@ -196,7 +196,7 @@ wxCalendarCtrl::HitTest(const wxPoint& pos, default: case MCHT_CALENDARWEEKNUM: wxFAIL_MSG( "unexpected" ); - // fall through + wxFALLTHROUGH; case MCHT_NOWHERE: case MCHT_CALENDARBK: diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 41ada622d9..51cf1fe9a5 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -390,7 +390,7 @@ HDC CreateCompatibleDCWithLayout(HDC hdc); // ---------------------------------------------------------------------------- // instead of duplicating the same code which sets and then restores text -// colours in each wxDC method working with wxSTIPPLE_MASK_OPAQUE brushes, +// colours in each wxDC method working with wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE brushes, // encapsulate this in a small helper class // wxBrushAttrsSetter: changes the text colours in the ctor if required and @@ -819,7 +819,7 @@ void wxMSWDCImpl::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord r = (wxCoord)sqrt(dx*dx + dy*dy); - wxBrushAttrsSetter cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling + wxBrushAttrsSetter cc(*this); // needed for wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE handling // treat the special case of full circle separately if ( x1 == x2 && y1 == y2 ) @@ -898,7 +898,7 @@ void wxMSWDCImpl::DoDrawPolygon(int n, wxCoord yoffset, wxPolygonFillMode fillStyle) { - wxBrushAttrsSetter cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling + wxBrushAttrsSetter cc(*this); // needed for wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE handling // Do things less efficiently if we have offsets if (xoffset != 0 || yoffset != 0) @@ -937,7 +937,7 @@ wxMSWDCImpl::DoDrawPolyPolygon(int n, wxCoord yoffset, wxPolygonFillMode fillStyle) { - wxBrushAttrsSetter cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling + wxBrushAttrsSetter cc(*this); // needed for wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE handling int i, cnt; for (i = cnt = 0; i < n; i++) cnt += count[i]; @@ -998,7 +998,7 @@ void wxMSWDCImpl::DoDrawLines(int n, const wxPoint points[], wxCoord xoffset, wx void wxMSWDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { - wxBrushAttrsSetter cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling + wxBrushAttrsSetter cc(*this); // needed for wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE handling wxCoord x2 = x + width; wxCoord y2 = y + height; @@ -1031,7 +1031,7 @@ void wxMSWDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord h void wxMSWDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius) { - wxBrushAttrsSetter cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling + wxBrushAttrsSetter cc(*this); // needed for wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE handling // Now, a negative radius value is interpreted to mean // 'the proportion of the smallest X or Y dimension' @@ -1063,7 +1063,7 @@ void wxMSWDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wx void wxMSWDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { - wxBrushAttrsSetter cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling + wxBrushAttrsSetter cc(*this); // needed for wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE handling // +1 below makes the ellipse more similar to other platforms. // In particular, DoDrawEllipse(x,y,1,1) should draw one point. @@ -1178,7 +1178,7 @@ void wxMSWDCImpl::DoDrawSpline(const wxPointList *points) // Chris Breeze 20/5/98: first implementation of DrawEllipticArc on Windows void wxMSWDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) { - wxBrushAttrsSetter cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling + wxBrushAttrsSetter cc(*this); // needed for wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE handling wxCoord x2 = x + w; wxCoord y2 = y + h; @@ -1713,7 +1713,7 @@ void wxMSWDCImpl::SetLogicalFunction(wxRasterOperationMode function) void wxMSWDCImpl::SetRop(WXHDC dc) { - if ( !dc || m_logicalFunction < 0 ) + if ( !dc ) return; int rop; diff --git a/src/msw/dcmemory.cpp b/src/msw/dcmemory.cpp index d19e6acc16..c398b2c162 100644 --- a/src/msw/dcmemory.cpp +++ b/src/msw/dcmemory.cpp @@ -162,7 +162,7 @@ static void wxDrawRectangle(wxDC& dc, wxCoord x, wxCoord y, wxCoord width, wxCoo { wxBrush brush(dc.GetBrush()); wxPen pen(dc.GetPen()); - if (brush.IsOk() && brush.GetStyle() != wxTRANSPARENT) + if (brush.IsOk() && brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT) { HBRUSH hBrush = (HBRUSH) brush.GetResourceHandle() ; if (hBrush) @@ -175,7 +175,7 @@ static void wxDrawRectangle(wxDC& dc, wxCoord x, wxCoord y, wxCoord width, wxCoo } } width --; height --; - if (pen.IsOk() && pen.GetStyle() != wxTRANSPARENT) + if (pen.IsOk() && pen.GetStyle() != wxPENSTYLE_TRANSPARENT) { dc.DrawLine(x, y, x + width, y); dc.DrawLine(x, y, x, y + height); @@ -192,8 +192,8 @@ void wxMemoryDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoor // (visible with e.g. 70x70 rectangle on a memory DC; see Drawing sample) #if wxUSE_MEMORY_DC_DRAW_RECTANGLE if (m_brush.IsOk() && m_pen.IsOk() && - (m_brush.GetStyle() == wxSOLID || m_brush.GetStyle() == wxTRANSPARENT) && - (m_pen.GetStyle() == wxSOLID || m_pen.GetStyle() == wxTRANSPARENT) && + (m_brush.GetStyle() == wxBRUSHSTYLE_SOLID || m_brush.GetStyle() == wxBRUSHSTYLE_TRANSPARENT) && + (m_pen.GetStyle() == wxPENSTYLE_SOLID || m_pen.GetStyle() == wxPENSTYLE_TRANSPARENT) && (GetLogicalFunction() == wxCOPY)) { wxDrawRectangle(* this, x, y, width, height); diff --git a/src/msw/dialup.cpp b/src/msw/dialup.cpp index c38af22209..dec3014e6c 100644 --- a/src/msw/dialup.cpp +++ b/src/msw/dialup.cpp @@ -541,7 +541,7 @@ HRASCONN wxDialUpManagerMSW::FindActiveConnection() // is used, for example, to select the connection to hang up and so // we may hang up the wrong connection here... wxLogWarning(_("Several active dialup connections found, choosing one randomly.")); - // fall through + wxFALLTHROUGH; case 1: // exactly 1 connection, great @@ -1231,7 +1231,7 @@ static DWORD wxRasMonitorThread(wxRasThreadData *data) default: wxFAIL_MSG( wxT("unexpected return of WaitForMultipleObjects()") ); - // fall through + wxFALLTHROUGH; case WAIT_FAILED: // using wxLogLastError() from here is dangerous: we risk to diff --git a/src/msw/evtloopconsole.cpp b/src/msw/evtloopconsole.cpp index 869ea888fd..17706a16e4 100644 --- a/src/msw/evtloopconsole.cpp +++ b/src/msw/evtloopconsole.cpp @@ -122,7 +122,7 @@ int wxMSWEventLoopBase::GetNextMessageTimeout(WXMSG *msg, unsigned long timeout) default: wxLogDebug("unexpected MsgWaitForMultipleObjects() return " "value %lu", rc); - // fall through + wxFALLTHROUGH; case WAIT_TIMEOUT: return -1; diff --git a/src/msw/filedlg.cpp b/src/msw/filedlg.cpp index 07a9932796..0c6e38681d 100644 --- a/src/msw/filedlg.cpp +++ b/src/msw/filedlg.cpp @@ -517,8 +517,7 @@ int wxFileDialog::ShowModal() case wxT('/'): // convert to backslash ch = wxT('\\'); - - // fall through + wxFALLTHROUGH; case wxT('\\'): while ( i < len - 1 ) @@ -533,7 +532,7 @@ int wxFileDialog::ShowModal() else break; } - // fall through + wxFALLTHROUGH; default: // normal char diff --git a/src/msw/font.cpp b/src/msw/font.cpp index ed9840e0e6..2a74f6d1b2 100644 --- a/src/msw/font.cpp +++ b/src/msw/font.cpp @@ -524,7 +524,7 @@ void wxNativeFontInfo::SetStyle(wxFontStyle style) { default: wxFAIL_MSG( "unknown font style" ); - // fall through + wxFALLTHROUGH; case wxFONTSTYLE_NORMAL: lf.lfItalic = FALSE; diff --git a/src/msw/graphics.cpp b/src/msw/graphics.cpp index 04cca9d732..ebecbeb72a 100644 --- a/src/msw/graphics.cpp +++ b/src/msw/graphics.cpp @@ -358,7 +358,7 @@ class wxGDIPlusContext : public wxGraphicsContext public: wxGDIPlusContext( wxGraphicsRenderer* renderer, const wxDC& dc ); wxGDIPlusContext( wxGraphicsRenderer* renderer, HDC hdc, wxDouble width, wxDouble height ); - wxGDIPlusContext( wxGraphicsRenderer* renderer, HWND hwnd ); + wxGDIPlusContext( wxGraphicsRenderer* renderer, HWND hwnd, wxWindow* window = NULL); wxGDIPlusContext( wxGraphicsRenderer* renderer, Graphics* gr); wxGDIPlusContext(wxGraphicsRenderer* renderer); @@ -1647,7 +1647,7 @@ wxGDIPlusContext::wxGDIPlusContext( wxGraphicsRenderer* renderer, HDC hdc, wxDou } wxGDIPlusContext::wxGDIPlusContext( wxGraphicsRenderer* renderer, const wxDC& dc ) - : wxGraphicsContext(renderer) + : wxGraphicsContext(renderer, dc.GetWindow()) { wxMSWDCImpl *msw = wxDynamicCast( dc.GetImpl() , wxMSWDCImpl ); HDC hdc = (HDC) msw->GetHDC(); @@ -1656,8 +1656,10 @@ wxGDIPlusContext::wxGDIPlusContext( wxGraphicsRenderer* renderer, const wxDC& dc Init(new Graphics(hdc), sz.x, sz.y); } -wxGDIPlusContext::wxGDIPlusContext( wxGraphicsRenderer* renderer, HWND hwnd ) - : wxGraphicsContext(renderer) +wxGDIPlusContext::wxGDIPlusContext( wxGraphicsRenderer* renderer, + HWND hwnd, + wxWindow* window ) + : wxGraphicsContext(renderer, window) { RECT rect = wxGetWindowRect(hwnd); Init(new Graphics(hwnd), rect.right - rect.left, rect.bottom - rect.top); @@ -2492,7 +2494,7 @@ wxGraphicsContext * wxGDIPlusRenderer::CreateContextFromNativeHDC(WXHDC dc) wxGraphicsContext * wxGDIPlusRenderer::CreateContext( wxWindow* window ) { ENSURE_LOADED_OR_RETURN(NULL); - return new wxGDIPlusContext(this, (HWND) window->GetHWND() ); + return new wxGDIPlusContext(this, (HWND) window->GetHWND(), window ); } // Path diff --git a/src/msw/graphicsd2d.cpp b/src/msw/graphicsd2d.cpp index 983372502c..ceda198f64 100644 --- a/src/msw/graphicsd2d.cpp +++ b/src/msw/graphicsd2d.cpp @@ -3462,9 +3462,19 @@ public: class wxD2DContext : public wxGraphicsContext, wxD2DResourceManager { public: - wxD2DContext(wxGraphicsRenderer* renderer, ID2D1Factory* direct2dFactory, HWND hwnd); + // Create the context for the given HWND, which may be associated (if it's + // non-null) with the given wxWindow. + wxD2DContext(wxGraphicsRenderer* renderer, + ID2D1Factory* direct2dFactory, + HWND hwnd, + wxWindow* window = NULL); - wxD2DContext(wxGraphicsRenderer* renderer, ID2D1Factory* direct2dFactory, HDC hdc, const wxSize& dcSize, + // Create the context for the given HDC which may be associated (if it's + // non-null) with the given wxDC. + wxD2DContext(wxGraphicsRenderer* renderer, + ID2D1Factory* direct2dFactory, + HDC hdc, + const wxDC* dc = NULL, D2D1_ALPHA_MODE alphaMode = D2D1_ALPHA_MODE_IGNORE); #if wxUSE_IMAGE @@ -3612,8 +3622,11 @@ private: // wxD2DContext implementation //----------------------------------------------------------------------------- -wxD2DContext::wxD2DContext(wxGraphicsRenderer* renderer, ID2D1Factory* direct2dFactory, HWND hwnd) : - wxGraphicsContext(renderer), m_direct2dFactory(direct2dFactory), +wxD2DContext::wxD2DContext(wxGraphicsRenderer* renderer, + ID2D1Factory* direct2dFactory, + HWND hwnd, + wxWindow* window) : + wxGraphicsContext(renderer, window), m_direct2dFactory(direct2dFactory), #if wxD2D_DEVICE_CONTEXT_SUPPORTED m_renderTargetHolder(new wxD2DDeviceContextResourceHolder(direct2dFactory, hwnd)) #else @@ -3626,13 +3639,21 @@ wxD2DContext::wxD2DContext(wxGraphicsRenderer* renderer, ID2D1Factory* direct2dF Init(); } -wxD2DContext::wxD2DContext(wxGraphicsRenderer* renderer, ID2D1Factory* direct2dFactory, HDC hdc, - const wxSize& dcSize, D2D1_ALPHA_MODE alphaMode) : - wxGraphicsContext(renderer), m_direct2dFactory(direct2dFactory), +wxD2DContext::wxD2DContext(wxGraphicsRenderer* renderer, + ID2D1Factory* direct2dFactory, + HDC hdc, + const wxDC* dc, + D2D1_ALPHA_MODE alphaMode) : + wxGraphicsContext(renderer, dc->GetWindow()), m_direct2dFactory(direct2dFactory), m_renderTargetHolder(new wxD2DDCRenderTargetResourceHolder(direct2dFactory, hdc, alphaMode)) { - m_width = dcSize.GetWidth(); - m_height = dcSize.GetHeight(); + if ( dc ) + { + const wxSize dcSize = dc->GetSize(); + m_width = dcSize.GetWidth(); + m_height = dcSize.GetHeight(); + } + Init(); } @@ -4593,7 +4614,7 @@ wxD2DRenderer::~wxD2DRenderer() wxGraphicsContext* wxD2DRenderer::CreateContext(const wxWindowDC& dc) { - return new wxD2DContext(this, m_direct2dFactory, dc.GetHDC(), dc.GetSize()); + return new wxD2DContext(this, m_direct2dFactory, dc.GetHDC(), &dc); } wxGraphicsContext* wxD2DRenderer::CreateContext(const wxMemoryDC& dc) @@ -4601,7 +4622,7 @@ wxGraphicsContext* wxD2DRenderer::CreateContext(const wxMemoryDC& dc) wxBitmap bmp = dc.GetSelectedBitmap(); wxASSERT_MSG( bmp.IsOk(), wxS("Should select a bitmap before creating wxGraphicsContext") ); - return new wxD2DContext(this, m_direct2dFactory, dc.GetHDC(), dc.GetSize(), + return new wxD2DContext(this, m_direct2dFactory, dc.GetHDC(), &dc, bmp.HasAlpha() ? D2D1_ALPHA_MODE_PREMULTIPLIED : D2D1_ALPHA_MODE_IGNORE); } @@ -4633,12 +4654,12 @@ wxGraphicsContext* wxD2DRenderer::CreateContextFromNativeWindow(void* window) wxGraphicsContext* wxD2DRenderer::CreateContextFromNativeHDC(WXHDC dc) { - return new wxD2DContext(this, m_direct2dFactory, (HDC)dc, wxSize(0, 0)); + return new wxD2DContext(this, m_direct2dFactory, (HDC)dc); } wxGraphicsContext* wxD2DRenderer::CreateContext(wxWindow* window) { - return new wxD2DContext(this, m_direct2dFactory, (HWND)window->GetHWND()); + return new wxD2DContext(this, m_direct2dFactory, (HWND)window->GetHWND(), window); } #if wxUSE_IMAGE diff --git a/src/msw/joystick.cpp b/src/msw/joystick.cpp index 3290460ab6..761477f833 100644 --- a/src/msw/joystick.cpp +++ b/src/msw/joystick.cpp @@ -37,23 +37,6 @@ #include -// Use optimised count trailing zeros where available. -static int wxCtz(unsigned x) -{ - wxCHECK_MSG(x > 0, 0, "Undefined for x == 0."); -#ifdef __GNUC__ - return __builtin_ctz(x); -#else - int n; - n = 1; - if ((x & 0x0000FFFF) == 0) {n = n +16; x = x >>16;} - if ((x & 0x000000FF) == 0) {n = n + 8; x = x >> 8;} - if ((x & 0x0000000F) == 0) {n = n + 4; x = x >> 4;} - if ((x & 0x00000003) == 0) {n = n + 2; x = x >> 2;} - return n - (x & 1); -#endif -} - enum { wxJS_AXIS_X = 0, @@ -84,13 +67,13 @@ public: { m_catchwin = win; m_polling = pollingFreq; - }; + } private: void SendEvent(wxEventType type, long ts, int change = 0); int m_joystick; - UINT m_buttons; + int m_buttons; wxWindow* m_catchwin; int m_polling; JOYINFO m_joyInfo; @@ -141,9 +124,9 @@ void* wxJoystickThread::Entry() // "Current button number that is pressed.", but it turns out // it is the *total* number of buttons pressed. if (deltaUp) - SendEvent(wxEVT_JOY_BUTTON_UP, ts, wxCtz(deltaUp)+1); + SendEvent(wxEVT_JOY_BUTTON_UP, ts, deltaUp); if (deltaDown) - SendEvent(wxEVT_JOY_BUTTON_DOWN, ts, wxCtz(deltaDown)+1); + SendEvent(wxEVT_JOY_BUTTON_DOWN, ts, deltaDown); if ((m_joyInfo.wXpos != m_lastJoyInfo.wXpos) || (m_joyInfo.wYpos != m_lastJoyInfo.wYpos) || diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 45041dcf6f..c557c559f3 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -2145,7 +2145,7 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) case HDN_BEGINTRACKA: case HDN_BEGINTRACKW: eventType = wxEVT_LIST_COL_BEGIN_DRAG; - // fall through + wxFALLTHROUGH; case HDN_ITEMCHANGING: if ( eventType == wxEVT_NULL ) @@ -2171,7 +2171,7 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) eventType = wxEVT_LIST_COL_DRAGGING; } - // fall through + wxFALLTHROUGH; case HDN_ENDTRACKA: case HDN_ENDTRACKW: @@ -2244,7 +2244,7 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) { case LVN_BEGINRDRAG: eventType = wxEVT_LIST_BEGIN_RDRAG; - // fall through + wxFALLTHROUGH; case LVN_BEGINDRAG: if ( eventType == wxEVT_NULL ) @@ -2675,7 +2675,7 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) return true; } - // fall through + wxFALLTHROUGH; default: processed = false; diff --git a/src/msw/mdi.cpp b/src/msw/mdi.cpp index 6870069d38..98e819ec92 100644 --- a/src/msw/mdi.cpp +++ b/src/msw/mdi.cpp @@ -722,7 +722,7 @@ void wxMDIParentFrame::OnMDICommand(wxCommandEvent& event) case wxID_MDI_WINDOW_TILE_HORZ: wParam |= MDITILE_HORIZONTAL; - // fall through + wxFALLTHROUGH; case wxID_MDI_WINDOW_TILE_VERT: if ( !wParam ) @@ -1152,7 +1152,7 @@ WXLRESULT wxMDIChildFrame::MSWWindowProc(WXUINT message, processed = HandleMDIActivate(act, hwndAct, hwndDeact); } - // fall through + wxFALLTHROUGH; case WM_MOVE: // must pass WM_MOVE to DefMDIChildProc() to recalculate MDI client diff --git a/src/msw/mediactrl_am.cpp b/src/msw/mediactrl_am.cpp index 5379eda8af..5bffd76681 100644 --- a/src/msw/mediactrl_am.cpp +++ b/src/msw/mediactrl_am.cpp @@ -1083,7 +1083,7 @@ bool wxAMMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent, // don't erase the background of our control window so that resizing is a // bit smoother - m_ctrl->SetBackgroundStyle(wxBG_STYLE_CUSTOM); + m_ctrl->SetBackgroundStyle(wxBG_STYLE_PAINT); // success return true; @@ -1369,7 +1369,7 @@ wxLongLong wxAMMediaBackend::GetDuration() { default: wxAMLOG(hr); - // fall through + wxFALLTHROUGH; case S_FALSE: return 0; diff --git a/src/msw/mediactrl_wmp10.cpp b/src/msw/mediactrl_wmp10.cpp index 955303ca58..c220a5a6fb 100644 --- a/src/msw/mediactrl_wmp10.cpp +++ b/src/msw/mediactrl_wmp10.cpp @@ -868,7 +868,7 @@ bool wxWMP10MediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent, // don't erase the background of our control window so that resizing is a // bit smoother - m_ctrl->SetBackgroundStyle(wxBG_STYLE_CUSTOM); + m_ctrl->SetBackgroundStyle(wxBG_STYLE_PAINT); // success return true; diff --git a/src/msw/msgdlg.cpp b/src/msw/msgdlg.cpp index 017991a4b4..6ffc80b43d 100644 --- a/src/msw/msgdlg.cpp +++ b/src/msw/msgdlg.cpp @@ -162,10 +162,7 @@ wxMessageDialog::HookFunction(int code, WXWPARAM wParam, WXLPARAM lParam) void wxMessageDialog::ReplaceStaticWithEdit() { // check if the message box fits the display - int nDisplay = wxDisplay::GetFromWindow(this); - if ( nDisplay == wxNOT_FOUND ) - nDisplay = 0; - const wxRect rectDisplay = wxDisplay(nDisplay).GetClientArea(); + const wxRect rectDisplay = wxDisplay(this).GetClientArea(); if ( rectDisplay.Contains(GetRect()) ) { @@ -833,7 +830,7 @@ int wxMSWMessageDialog::MSWTranslateReturnCode(int msAns) { default: wxFAIL_MSG(wxT("unexpected return code")); - // fall through + wxFALLTHROUGH; case IDCANCEL: ans = wxID_CANCEL; diff --git a/src/msw/ole/droptgt.cpp b/src/msw/ole/droptgt.cpp index e34c8d039a..acb7e44017 100644 --- a/src/msw/ole/droptgt.cpp +++ b/src/msw/ole/droptgt.cpp @@ -681,7 +681,7 @@ static wxDragResult ConvertDragEffectToResult(DWORD dwEffect) default: wxFAIL_MSG(wxT("invalid value in ConvertDragEffectToResult")); - // fall through + wxFALLTHROUGH; case DROPEFFECT_NONE: return wxDragNone; @@ -702,7 +702,7 @@ static DWORD ConvertDragResultToEffect(wxDragResult result) default: wxFAIL_MSG(wxT("invalid value in ConvertDragResultToEffect")); - // fall through + wxFALLTHROUGH; case wxDragNone: return DROPEFFECT_NONE; diff --git a/src/msw/pen.cpp b/src/msw/pen.cpp index 61a8648d3b..17360fb899 100644 --- a/src/msw/pen.cpp +++ b/src/msw/pen.cpp @@ -205,7 +205,7 @@ static int ConvertPenStyle(wxPenStyle style) default: wxFAIL_MSG( wxT("unknown pen style") ); - // fall through + wxFALLTHROUGH; case wxPENSTYLE_DOT: return PS_DOT; @@ -241,7 +241,7 @@ static int ConvertJoinStyle(wxPenJoin join) default: wxFAIL_MSG( wxT("unknown pen join style") ); - // fall through + wxFALLTHROUGH; case wxJOIN_ROUND: return PS_JOIN_ROUND; @@ -260,7 +260,7 @@ static int ConvertCapStyle(wxPenCap cap) default: wxFAIL_MSG( wxT("unknown pen cap style") ); - // fall through + wxFALLTHROUGH; case wxCAP_ROUND: return PS_ENDCAP_ROUND; diff --git a/src/msw/power.cpp b/src/msw/power.cpp index af74be0d88..92ff808675 100644 --- a/src/msw/power.cpp +++ b/src/msw/power.cpp @@ -143,6 +143,7 @@ wxPowerType wxGetPowerType() default: wxLogDebug(wxT("Unknown ACLineStatus=%u"), sps.ACLineStatus); + wxFALLTHROUGH; case 255: break; } diff --git a/src/msw/region.cpp b/src/msw/region.cpp index 8ff88073b3..b7e18d85fd 100644 --- a/src/msw/region.cpp +++ b/src/msw/region.cpp @@ -206,7 +206,7 @@ bool wxRegion::DoCombine(const wxRegion& rgn, wxRegionOp op) default: wxFAIL_MSG( wxT("unknown region operation") ); - // fall through + wxFALLTHROUGH; case wxRGN_AND: case wxRGN_DIFF: @@ -239,7 +239,7 @@ bool wxRegion::DoCombine(const wxRegion& rgn, wxRegionOp op) default: wxFAIL_MSG( wxT("unknown region operation") ); - // fall through + wxFALLTHROUGH; case wxRGN_COPY: mode = RGN_COPY; diff --git a/src/msw/registry.cpp b/src/msw/registry.cpp index 63d2e1bf70..73631b105c 100644 --- a/src/msw/registry.cpp +++ b/src/msw/registry.cpp @@ -1332,7 +1332,7 @@ wxString wxRegKey::FormatValue(const wxString& name) const case wxT('\\'): // escape special symbol rhs += wxT('\\'); - // fall through + wxFALLTHROUGH; default: rhs += *p; @@ -1527,7 +1527,7 @@ long GetMSWViewFlags(wxRegKey::WOW64ViewMode viewMode) default: wxFAIL_MSG("Unknown registry view."); - // fall through + wxFALLTHROUGH; case wxRegKey::WOW64ViewMode_Default: // Use default registry view for the current application, diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index ec96a10635..52637d901c 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -1997,7 +1997,7 @@ bool wxTextCtrl::MSWShouldPreProcessMessage(WXMSG* msg) { default: wxFAIL_MSG( wxT("how many modifiers have we got?") ); - // fall through + wxFALLTHROUGH; case 0: switch ( vkey ) @@ -2006,14 +2006,14 @@ bool wxTextCtrl::MSWShouldPreProcessMessage(WXMSG* msg) // This one is only special for multi line controls. if ( !IsMultiLine() ) break; - // fall through + wxFALLTHROUGH; case VK_DELETE: case VK_HOME: case VK_END: return false; } - // fall through + wxFALLTHROUGH; case 2: break; @@ -2297,7 +2297,7 @@ bool wxTextCtrl::SendUpdateEvent() default: wxFAIL_MSG( wxT("unexpected wxTextCtrl::m_updatesCount value") ); - // fall through + wxFALLTHROUGH; case -1: // we hadn't updated the control ourselves, this event comes from diff --git a/src/msw/thread.cpp b/src/msw/thread.cpp index 5c94613f46..a04625d4fd 100644 --- a/src/msw/thread.cpp +++ b/src/msw/thread.cpp @@ -258,7 +258,7 @@ wxMutexError wxMutexInternal::LockTimeout(DWORD milliseconds) // the previous caller died without releasing the mutex, so even // though we did get it, log a message about this wxLogDebug(wxT("WaitForSingleObject() returned WAIT_ABANDONED")); - // fall through + wxFALLTHROUGH; case WAIT_OBJECT_0: // ok @@ -269,7 +269,7 @@ wxMutexError wxMutexInternal::LockTimeout(DWORD milliseconds) default: wxFAIL_MSG(wxT("impossible return value in wxMutex::Lock")); - // fall through + wxFALLTHROUGH; case WAIT_FAILED: wxLogLastError(wxT("WaitForSingleObject(mutex)")); diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index df9e001c93..b883d9d8f9 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -756,8 +756,7 @@ void wxTopLevelWindowMSW::DoGetPosition(int *x, int *y) const { // we must use the correct display for the translation as the // task bar might be shown on one display but not the other one - int n = wxDisplay::GetFromWindow(this); - wxDisplay dpy(n == wxNOT_FOUND ? 0 : n); + wxDisplay dpy(this); const wxPoint ptOfs = dpy.GetClientArea().GetPosition() - dpy.GetGeometry().GetPosition(); @@ -916,11 +915,7 @@ bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style) // resize to the size of the display containing us, falling back to the // primary one - int dpy = wxDisplay::GetFromWindow(this); - if ( dpy == wxNOT_FOUND ) - dpy = 0; - - const wxRect rect = wxDisplay(dpy).GetGeometry(); + const wxRect rect = wxDisplay(this).GetGeometry(); SetSize(rect); diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index d7e9094a02..e9f9defff4 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -3114,8 +3114,7 @@ wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) processed = true; } } - - // fall through + wxFALLTHROUGH; case WM_RBUTTONUP: #if wxUSE_DRAGIMAGE @@ -3288,7 +3287,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) { case TVN_BEGINDRAG: eventType = wxEVT_TREE_BEGIN_DRAG; - // fall through + wxFALLTHROUGH; case TVN_BEGINRDRAG: { @@ -3379,7 +3378,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) case TVN_GETDISPINFO: eventType = wxEVT_TREE_GET_INFO; - // fall through + wxFALLTHROUGH; case TVN_SETDISPINFO: { @@ -3403,7 +3402,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) { default: wxLogDebug(wxT("unexpected code %d in TVN_ITEMEXPAND message"), tv->action); - // fall through + wxFALLTHROUGH; case TVE_EXPAND: what = IDX_EXPAND; @@ -3471,7 +3470,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) { eventType = wxEVT_TREE_SEL_CHANGED; } - // fall through + wxFALLTHROUGH; case TVN_SELCHANGINGA: case TVN_SELCHANGINGW: @@ -3690,7 +3689,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) break; } } - // fall through + wxFALLTHROUGH; default: return wxControl::MSWOnNotify(idCtrl, lParam, result); diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index 2fc500a202..74a3a596c3 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -713,11 +713,11 @@ int wxKill(long pid, wxSignal sig, wxKillError *krc, int flags) default: wxFAIL_MSG( wxT("unexpected WaitForSingleObject() return") ); - // fall through + wxFALLTHROUGH; case WAIT_FAILED: wxLogLastError(wxT("WaitForSingleObject")); - // fall through + wxFALLTHROUGH; case WAIT_TIMEOUT: // Process didn't terminate: normally this is a failure but not @@ -1270,10 +1270,11 @@ wxWinVersion wxGetWinVersion() } break; - + case 10: return wxWinVersion_10; } + break; default: // Do nothing just to silence GCC warning break; diff --git a/src/msw/window.cpp b/src/msw/window.cpp index d17cf3f39e..e17b851b59 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -1561,7 +1561,7 @@ WXDWORD wxWindowMSW::MSWGetStyle(long flags, WXDWORD *exstyle) const default: case wxBORDER_DEFAULT: wxFAIL_MSG( wxT("unknown border style") ); - // fall through + wxFALLTHROUGH; case wxBORDER_NONE: case wxBORDER_SIMPLE: @@ -2257,7 +2257,7 @@ wxSize wxWindowMSW::DoGetBorderSize() const default: wxFAIL_MSG( wxT("unknown border style") ); - // fall through + wxFALLTHROUGH; case wxBORDER_NONE: border = 0; @@ -2540,7 +2540,7 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg) case VK_PRIOR: bForward = false; - // fall through + wxFALLTHROUGH; case VK_NEXT: // we treat PageUp/Dn as arrows because chances are that @@ -4502,7 +4502,7 @@ bool wxWindowMSW::HandlePower(WXWPARAM wParam, default: wxLogDebug(wxT("Unknown WM_POWERBROADCAST(%d) event"), wParam); - // fall through + wxFALLTHROUGH; // these messages are currently not mapped to wx events case PBT_APMQUERYSTANDBY: @@ -5106,7 +5106,7 @@ bool wxWindowMSW::HandleEraseBkgnd(WXHDC hdc) return true; } } - // fall through + wxFALLTHROUGH; case wxBG_STYLE_SYSTEM: if ( !DoEraseBackground(hdc) ) diff --git a/src/osx/carbon/dcprint.cpp b/src/osx/carbon/dcprint.cpp index 9c4978f843..9c12d4b688 100644 --- a/src/osx/carbon/dcprint.cpp +++ b/src/osx/carbon/dcprint.cpp @@ -149,7 +149,7 @@ bool wxMacCarbonPrinterDC::StartDoc( wxPrinterDC* dc , const wxString& message if (m_err == noErr) useDefaultResolution = true; } - + // Ignore errors which may occur while retrieving the resolution and just // use the default one. if ( useDefaultResolution ) @@ -366,7 +366,7 @@ void wxPrinterDCImpl::StartPage() m_logicalFunction = wxCOPY; // m_textAlignment = wxALIGN_TOP_LEFT; - m_backgroundMode = wxTRANSPARENT; + m_backgroundMode = wxBRUSHSTYLE_TRANSPARENT; m_textForegroundColour = *wxBLACK; m_textBackgroundColour = *wxWHITE; diff --git a/src/osx/carbon/graphics.cpp b/src/osx/carbon/graphics.cpp index 16f58329da..6ff597cd02 100644 --- a/src/osx/carbon/graphics.cpp +++ b/src/osx/carbon/graphics.cpp @@ -228,7 +228,7 @@ public : { switch ( m_hatch ) { - case wxBDIAGONAL_HATCH : + case wxHATCHSTYLE_BDIAGONAL : { CGPoint pts[] = { @@ -238,7 +238,7 @@ public : } break; - case wxCROSSDIAG_HATCH : + case wxHATCHSTYLE_CROSSDIAG : { CGPoint pts[] = { @@ -249,7 +249,7 @@ public : } break; - case wxFDIAGONAL_HATCH : + case wxHATCHSTYLE_FDIAGONAL : { CGPoint pts[] = { @@ -259,7 +259,7 @@ public : } break; - case wxCROSS_HATCH : + case wxHATCHSTYLE_CROSS : { CGPoint pts[] = { @@ -270,7 +270,7 @@ public : } break; - case wxHORIZONTAL_HATCH : + case wxHATCHSTYLE_HORIZONTAL : { CGPoint pts[] = { @@ -280,7 +280,7 @@ public : } break; - case wxVERTICAL_HATCH : + case wxHATCHSTYLE_VERTICAL : { CGPoint pts[] = { @@ -1303,7 +1303,11 @@ bool wxMacCoreGraphicsPathData::Contains( wxDouble x, wxDouble y, wxPolygonFillM class WXDLLEXPORT wxMacCoreGraphicsContext : public wxGraphicsContext { public: - wxMacCoreGraphicsContext( wxGraphicsRenderer* renderer, CGContextRef cgcontext, wxDouble width = 0, wxDouble height = 0 ); + wxMacCoreGraphicsContext( wxGraphicsRenderer* renderer, + CGContextRef cgcontext, + wxDouble width = 0, + wxDouble height = 0, + wxWindow* window = NULL ); wxMacCoreGraphicsContext( wxGraphicsRenderer* renderer, wxWindow* window ); @@ -1311,6 +1315,12 @@ public: ~wxMacCoreGraphicsContext(); + // Enable offset on non-high DPI displays, i.e. those with scale factor <= 1. + void SetEnableOffsetFromScaleFactor(double factor) + { + m_enableOffset = factor <= 1.0; + } + void Init(); virtual void StartPage( wxDouble width, wxDouble height ) wxOVERRIDE; @@ -1342,7 +1352,7 @@ public: virtual bool SetAntialiasMode(wxAntialiasMode antialias) wxOVERRIDE; virtual bool SetInterpolationQuality(wxInterpolationQuality interpolation) wxOVERRIDE; - + virtual bool SetCompositionMode(wxCompositionMode op) wxOVERRIDE; virtual void BeginLayer(wxDouble opacity) wxOVERRIDE; @@ -1382,15 +1392,15 @@ public: // draws a path by first filling and then stroking virtual void DrawPath( const wxGraphicsPath &path, wxPolygonFillMode fillStyle = wxODDEVEN_RULE ) wxOVERRIDE; - + // paints a transparent rectangle (only useful for bitmaps or windows) virtual void ClearRectangle(wxDouble x, wxDouble y, wxDouble w, wxDouble h) wxOVERRIDE; - + virtual bool ShouldOffset() const wxOVERRIDE { if ( !m_enableOffset ) return false; - + int penwidth = 0 ; if ( !m_pen.IsNull() ) { @@ -1418,10 +1428,10 @@ public: virtual void DrawBitmap( const wxGraphicsBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h ) wxOVERRIDE; virtual void DrawIcon( const wxIcon &icon, wxDouble x, wxDouble y, wxDouble w, wxDouble h ) wxOVERRIDE; - + // fast convenience methods - - + + virtual void DrawRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h ) wxOVERRIDE; void SetNativeContext( CGContextRef cg ); @@ -1509,7 +1519,12 @@ void wxMacCoreGraphicsContext::Init() m_interpolation = wxINTERPOLATION_DEFAULT; } -wxMacCoreGraphicsContext::wxMacCoreGraphicsContext( wxGraphicsRenderer* renderer, CGContextRef cgcontext, wxDouble width, wxDouble height ) : wxGraphicsContext(renderer) +wxMacCoreGraphicsContext::wxMacCoreGraphicsContext( wxGraphicsRenderer* renderer, + CGContextRef cgcontext, + wxDouble width, + wxDouble height, + wxWindow* window ) + : wxGraphicsContext(renderer, window) { Init(); SetNativeContext(cgcontext); @@ -1518,11 +1533,13 @@ wxMacCoreGraphicsContext::wxMacCoreGraphicsContext( wxGraphicsRenderer* renderer m_initTransform = m_cgContext ? CGContextGetCTM(m_cgContext) : CGAffineTransformIdentity; } -wxMacCoreGraphicsContext::wxMacCoreGraphicsContext( wxGraphicsRenderer* renderer, wxWindow* window ): wxGraphicsContext(renderer) +wxMacCoreGraphicsContext::wxMacCoreGraphicsContext( wxGraphicsRenderer* renderer, + wxWindow* window ) + : wxGraphicsContext(renderer, window) { Init(); - m_enableOffset = window->GetContentScaleFactor() <= 1; + SetEnableOffsetFromScaleFactor(window->GetContentScaleFactor()); wxSize sz = window->GetSize(); m_width = sz.x; m_height = sz.y; @@ -1600,7 +1617,7 @@ void wxMacCoreGraphicsContext::Flush() bool wxMacCoreGraphicsContext::EnsureIsValid() { CheckInvariants(); - + if ( !m_cgContext ) { if (m_invisible) @@ -1712,7 +1729,7 @@ bool wxMacCoreGraphicsContext::SetInterpolationQuality(wxInterpolationQuality in { if (!EnsureIsValid()) return true; - + if (m_interpolation == interpolation) return true; @@ -1927,7 +1944,7 @@ void wxMacCoreGraphicsContext::Clip( const wxRegion ®ion ) // allow usage as measuring context // wxASSERT_MSG( m_cgContext != NULL, "Needs a valid context for clipping" ); #endif - CheckInvariants(); + CheckInvariants(); } // clips drawings to the rect @@ -1952,7 +1969,7 @@ void wxMacCoreGraphicsContext::Clip( wxDouble x, wxDouble y, wxDouble w, wxDoubl // wxFAIL_MSG( "Needs a valid context for clipping" ); #endif } - CheckInvariants(); + CheckInvariants(); } // resets the clipping to original extent @@ -1985,7 +2002,7 @@ void wxMacCoreGraphicsContext::ResetClip() // wxFAIL_MSG( "Needs a valid context for clipping" ); #endif } - CheckInvariants(); + CheckInvariants(); } void wxMacCoreGraphicsContext::GetClipBox(wxDouble* x, wxDouble* y, wxDouble* w, wxDouble* h) @@ -2039,7 +2056,7 @@ void wxMacCoreGraphicsContext::StrokePath( const wxGraphicsPath &path ) ((wxMacCoreGraphicsPenData*)m_pen.GetRefData())->Apply(this); CGContextAddPath( m_cgContext , (CGPathRef) path.GetNativePath() ); CGContextStrokePath( m_cgContext ); - + CheckInvariants(); } @@ -2094,7 +2111,7 @@ void wxMacCoreGraphicsContext::DrawPath( const wxGraphicsPath &path , wxPolygonF CGContextAddPath( m_cgContext , (CGPathRef) path.GetNativePath() ); CGContextDrawPath( m_cgContext , mode ); - + CheckInvariants(); } @@ -2126,7 +2143,7 @@ void wxMacCoreGraphicsContext::FillPath( const wxGraphicsPath &path , wxPolygonF else CGContextFillPath( m_cgContext ); } - + CheckInvariants(); } @@ -2246,7 +2263,7 @@ void wxMacCoreGraphicsContext::DrawBitmap( const wxGraphicsBitmap &bmp, wxDouble wxMacDrawCGImage( m_cgContext , &r , image ); } #endif - + CheckInvariants(); } @@ -2264,7 +2281,7 @@ void wxMacCoreGraphicsContext::DrawIcon( const wxIcon &icon, wxDouble x, wxDoubl wxOSXDrawNSImage( m_cgContext, &r, icon.GetImage()); } #endif - + CheckInvariants(); } @@ -2301,9 +2318,9 @@ void wxMacCoreGraphicsContext::DoDrawText( const wxString &str, wxDouble x, wxDo wxCFDictionaryRef fontattr(wxCFRetain(fref->OSXGetCTFontAttributes())); wxCFMutableDictionaryRef inlinefontattr; - + bool setColorsInLine = false; - + // if we emulate boldness the stroke color is not taken from the current context // therefore we have to set it explicitly if ( fontattr.GetValue(kCTStrokeWidthAttributeName) != NULL) @@ -2314,7 +2331,7 @@ void wxMacCoreGraphicsContext::DoDrawText( const wxString &str, wxDouble x, wxDo inlinefontattr.SetValue(kCTForegroundColorAttributeName,col); inlinefontattr.SetValue(kCTStrokeColorAttributeName,col); } - + wxCFRef attrtext( CFAttributedStringCreate(kCFAllocatorDefault, text, setColorsInLine ? inlinefontattr : fontattr ) ); wxCFRef line( CTLineCreateWithAttributedString(attrtext) ); @@ -2335,7 +2352,7 @@ void wxMacCoreGraphicsContext::DoDrawText( const wxString &str, wxDouble x, wxDo CGFloat width = CTLineGetTypographicBounds(line, NULL, NULL, NULL); CGPoint points[] = { {0.0, -2.0}, {width, -2.0} }; - + CGContextSetStrokeColorWithColor(m_cgContext, col); CGContextSetShouldAntialias(m_cgContext, false); CGContextSetLineWidth(m_cgContext, 1.0); @@ -2400,7 +2417,7 @@ void wxMacCoreGraphicsContext::GetTextExtent( const wxString &str, wxDouble *wid wxMacCoreGraphicsFontData* fref = (wxMacCoreGraphicsFontData*)m_font.GetRefData(); wxCFStringRef text(strToMeasure, wxLocale::GetSystemEncoding() ); - + wxCFRef attrtext( CFAttributedStringCreate(kCFAllocatorDefault, text, fref->OSXGetCTFontAttributes() ) ); wxCFRef line( CTLineCreateWithAttributedString(attrtext) ); @@ -2419,7 +2436,7 @@ void wxMacCoreGraphicsContext::GetTextExtent( const wxString &str, wxDouble *wid if ( externalLeading ) *externalLeading = l; - CheckInvariants(); + CheckInvariants(); } void wxMacCoreGraphicsContext::GetPartialTextExtents(const wxString& text, wxArrayDouble& widths) const @@ -2462,7 +2479,7 @@ void wxMacCoreGraphicsContext::ClearRectangle( wxDouble x, wxDouble y, wxDouble { if (!EnsureIsValid()) return; - + CGRect rect = CGRectMake( (CGFloat) x , (CGFloat) y , (CGFloat) w , (CGFloat) h ); CGContextClearRect(m_cgContext, rect); } @@ -2472,10 +2489,10 @@ void wxMacCoreGraphicsContext::DrawRectangle( wxDouble x, wxDouble y, wxDouble w if (!EnsureIsValid()) return; - if (m_composition == wxCOMPOSITION_DEST) - return; + if (m_composition == wxCOMPOSITION_DEST) + return; - // when using shading, we have to go back to drawing paths + // when using shading, we have to go back to drawing paths if ( !m_brush.IsNull() && ((wxMacCoreGraphicsBrushData*)m_brush.GetRefData())->IsShading() ) { wxGraphicsContext::DrawRectangle( x,y,w,h ); @@ -2488,7 +2505,7 @@ void wxMacCoreGraphicsContext::DrawRectangle( wxDouble x, wxDouble y, wxDouble w ((wxMacCoreGraphicsBrushData*)m_brush.GetRefData())->Apply(this); CGContextFillRect(m_cgContext, rect); } - + wxQuartzOffsetHelper helper( m_cgContext , ShouldOffset() ); if ( !m_pen.IsNull() ) { @@ -2694,26 +2711,18 @@ wxGraphicsRenderer* wxGraphicsRenderer::GetDefaultRenderer() wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateContext( const wxWindowDC& dc ) { - const wxDCImpl* impl = dc.GetImpl(); - wxWindowDCImpl *win_impl = wxDynamicCast( impl, wxWindowDCImpl ); - if (win_impl) - { - int w, h; - win_impl->GetSize( &w, &h ); - CGContextRef cgctx = 0; + wxWindow* const win = dc.GetWindow(); + wxCHECK_MSG( win, NULL, "Invalid wxWindowDC" ); - wxASSERT_MSG(win_impl->GetWindow(), "Invalid wxWindow in wxMacCoreGraphicsRenderer::CreateContext"); - if (win_impl->GetWindow()) - cgctx = (CGContextRef)(win_impl->GetWindow()->MacGetCGContextRef()); + const wxSize sz = win->GetSize(); - // having a cgctx being NULL is fine (will be created on demand) - // this is the case for all wxWindowDCs except wxPaintDC - wxMacCoreGraphicsContext *context = - new wxMacCoreGraphicsContext( this, cgctx, (wxDouble) w, (wxDouble) h ); - context->EnableOffset(dc.GetContentScaleFactor() < 2); - return context; - } - return NULL; + // having a cgctx being NULL is fine (will be created on demand) + // this is the case for all wxWindowDCs except wxPaintDC + CGContextRef cgctx = (CGContextRef)(win->MacGetCGContextRef()); + wxMacCoreGraphicsContext *context = + new wxMacCoreGraphicsContext( this, cgctx, sz.x, sz.y, win ); + context->SetEnableOffsetFromScaleFactor(dc.GetContentScaleFactor()); + return context; } wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateContext( const wxMemoryDC& dc ) @@ -2727,7 +2736,7 @@ wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateContext( const wxMemoryDC& mem_impl->GetSize( &w, &h ); wxMacCoreGraphicsContext* context = new wxMacCoreGraphicsContext( this, (CGContextRef)(mem_impl->GetGraphicsContext()->GetNativeContext()), (wxDouble) w, (wxDouble) h ); - context->EnableOffset(dc.GetContentScaleFactor() < 2); + context->SetEnableOffsetFromScaleFactor(dc.GetContentScaleFactor()); return context; } #endif diff --git a/src/osx/carbon/statbrma.cpp b/src/osx/carbon/statbrma.cpp index 1685619090..09b872d342 100644 --- a/src/osx/carbon/statbrma.cpp +++ b/src/osx/carbon/statbrma.cpp @@ -110,7 +110,7 @@ void wxStatusBarMac::InitColours() wxColour bg = wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE); m_textActive = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT); m_textInactive = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT); - + if ( bg.Red() < 128 ) { // dark mode appearance @@ -222,7 +222,7 @@ void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event)) if ( GetFont().IsOk() ) dc.SetFont(GetFont()); - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); // compute char height only once for all panes: int textHeight = dc.GetCharHeight(); diff --git a/src/osx/cocoa/dataview.mm b/src/osx/cocoa/dataview.mm index 09a532dbef..6842102502 100644 --- a/src/osx/cocoa/dataview.mm +++ b/src/osx/cocoa/dataview.mm @@ -2295,8 +2295,33 @@ wxDataViewItem wxCocoaDataViewControl::GetTopItem() const wxRect wxCocoaDataViewControl::GetRectangle(const wxDataViewItem& item, const wxDataViewColumn *columnPtr) { - return wxFromNSRect([m_osxView superview],[m_OutlineView frameOfCellAtColumn:GetColumnPosition(columnPtr) + NSView* const parent = [m_osxView superview]; + + wxRect r = wxFromNSRect(parent, [m_OutlineView frameOfCellAtColumn:GetColumnPosition(columnPtr) row:[m_OutlineView rowForItem:[m_DataSource getDataViewItemFromBuffer:item]]]); + + // For hidden items, i.e. items not shown because their parent is + // collapsed, the native method returns rectangles with negative width, but + // we're supposed to just return an empty rectangle in this case. To be on + // the safe side, also check for the height as well, even if it seems to be + // always 0 in this case. + if ( r.width < 0 || r.height < 0 ) + return wxRect(); + + // Also adjust the vertical coordinates to use physical window coordinates + // instead of the logical ones returned by frameOfCellAtColumn:row: + NSScrollView* const scrollView = [m_OutlineView enclosingScrollView]; + const wxRect + visible = wxFromNSRect(parent, scrollView.contentView.visibleRect); + + // We are also supposed to return empty rectangle if the item is not + // visible because it is scrolled out of view. + if ( r.GetBottom() < visible.GetTop() || r.GetTop() > visible.GetBottom() ) + return wxRect(); + + r.y -= visible.y; + + return r; } bool wxCocoaDataViewControl::IsExpanded(const wxDataViewItem& item) const diff --git a/src/osx/cocoa/nonownedwnd.mm b/src/osx/cocoa/nonownedwnd.mm index a1084ccc15..61ea6270a0 100644 --- a/src/osx/cocoa/nonownedwnd.mm +++ b/src/osx/cocoa/nonownedwnd.mm @@ -1092,10 +1092,18 @@ bool wxNonOwnedWindowCocoaImpl::EnableFullScreenView(bool enable) if (enable) { collectionBehavior |= NSWindowCollectionBehaviorFullScreenPrimary; + collectionBehavior &= ~NSWindowCollectionBehaviorFullScreenAuxiliary; } else { + // Note that just turning "Full Screen Primary" is not enough, the + // window would still be made full screen when the green button in the + // title bar is pressed, and we need to explicitly turn on the "Full + // Screen Auxiliary" style to prevent this from happening. This works, + // at least under 10.11 and 10.14, even though it's not really clear + // from the documentation that it should. collectionBehavior &= ~NSWindowCollectionBehaviorFullScreenPrimary; + collectionBehavior |= NSWindowCollectionBehaviorFullScreenAuxiliary; } [m_macWindow setCollectionBehavior: collectionBehavior]; diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index 3695a1b185..45cfdd7c37 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -2575,8 +2575,11 @@ void wxWidgetCocoaImpl::SetVisibility( bool visible ) [m_osxView setHidden:(visible ? NO:YES)]; // trigger redraw upon shown for layer-backed views - if( m_osxView.layer && !m_osxView.isHiddenOrHasHiddenAncestor ) - SetNeedsDisplay(NULL); +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14 + if ( wxPlatformInfo::Get().CheckOSVersion(10, 14 ) ) + if( !m_osxView.isHiddenOrHasHiddenAncestor ) + SetNeedsDisplay(NULL); +#endif } double wxWidgetCocoaImpl::GetContentScaleFactor() const @@ -3032,7 +3035,7 @@ static void SetSubviewsNeedDisplay( NSView *view ) { for ( NSView *sub in view.subviews ) { - if ( sub.isHidden || !sub.layer ) + if ( sub.isHidden ) continue; [sub setNeedsDisplay:YES]; @@ -3050,8 +3053,10 @@ void wxWidgetCocoaImpl::SetNeedsDisplay( const wxRect* where ) // Layer-backed views (which are all in Mojave's Dark Mode) may not have // their children implicitly redrawn with the parent. For compatibility, // do it manually here: - if ( m_osxView.layer ) +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14 + if ( wxPlatformInfo::Get().CheckOSVersion(10, 14 ) ) SetSubviewsNeedDisplay(m_osxView); +#endif } bool wxWidgetCocoaImpl::GetNeedsDisplay() const diff --git a/src/osx/core/bitmap.cpp b/src/osx/core/bitmap.cpp index 5170f3f53b..fcfb40816b 100644 --- a/src/osx/core/bitmap.cpp +++ b/src/osx/core/bitmap.cpp @@ -1062,7 +1062,9 @@ wxBitmap wxBitmap::GetSubBitmap(const wxRect &rect) const maskbuf.UngetWriteBuf( maskbufsize ) ; } - ret.SetMask( new wxMask( maskbuf , destwidth , destheight , rowBytes ) ) ; + wxMask* const mask = new wxMask(); + mask->OSXCreate( maskbuf , destwidth , destheight , rowBytes ); + ret.SetMask(mask) ; } else if ( HasAlpha() ) ret.UseAlpha() ; @@ -1505,22 +1507,14 @@ wxMask::wxMask(const wxMask &tocopy) : wxMaskBase() wxMask::wxMask( const wxBitmap& bitmap, const wxColour& colour ) { Init() ; - wxMaskBase::Create( bitmap, colour ); + Create( bitmap, colour ); } // Construct a mask from a mono bitmap (copies the bitmap). wxMask::wxMask( const wxBitmap& bitmap ) { Init() ; - wxMaskBase::Create( bitmap ); -} - -// Construct a mask from a mono bitmap (copies the bitmap). - -wxMask::wxMask( const wxMemoryBuffer& data, int width , int height , int bytesPerRow ) -{ - Init() ; - Create( data, width , height , bytesPerRow ); + Create( bitmap ); } wxMask::~wxMask() @@ -1591,7 +1585,7 @@ void wxMask::RealizeNative() // Create a mask from a mono bitmap (copies the bitmap). -bool wxMask::Create(const wxMemoryBuffer& data,int width , int height , int bytesPerRow) +bool wxMask::OSXCreate(const wxMemoryBuffer& data,int width , int height , int bytesPerRow) { wxASSERT( data.GetDataLen() == (size_t)(height * bytesPerRow) ) ; diff --git a/src/osx/core/hidjoystick.cpp b/src/osx/core/hidjoystick.cpp index feace2517e..cf47209311 100644 --- a/src/osx/core/hidjoystick.cpp +++ b/src/osx/core/hidjoystick.cpp @@ -872,7 +872,7 @@ void* wxJoystickThread::Entry() wxevent.SetEventType(wxEVT_JOY_BUTTON_UP); } - wxevent.SetButtonChange(nIndex+1); + wxevent.SetButtonChange(1 << nIndex); } else if (nIndex == wxJS_AXIS_X) { diff --git a/src/osx/core/sound.cpp b/src/osx/core/sound.cpp index f97c11eb2f..1c5ec6e2dc 100644 --- a/src/osx/core/sound.cpp +++ b/src/osx/core/sound.cpp @@ -94,6 +94,7 @@ void wxOSXAudioToolboxSoundData::DoStop() if ( m_playing ) { m_playing = false; + AudioServicesRemoveSystemSoundCompletion(m_soundID); AudioServicesDisposeSystemSoundID (m_soundID); wxSound::SoundStopped(this); diff --git a/src/osx/dataview_osx.cpp b/src/osx/dataview_osx.cpp index f49a360dc6..57a1cf3970 100644 --- a/src/osx/dataview_osx.cpp +++ b/src/osx/dataview_osx.cpp @@ -547,10 +547,24 @@ wxDataViewColumn *wxDataViewCtrl::GetCurrentColumn() const wxRect wxDataViewCtrl::GetItemRect(wxDataViewItem const& item, wxDataViewColumn const* columnPtr) const { - if (item.IsOk() && (columnPtr != NULL)) - return GetDataViewPeer()->GetRectangle(item,columnPtr); - else - return wxRect(); + if ( !item.IsOk() ) + return wxRect(); + + wxRect rect = GetDataViewPeer()->GetRectangle(item, columnPtr ? columnPtr : GetColumn(0)); + + if ( !columnPtr ) + { + const unsigned columnCount = GetColumnCount(); + if ( columnCount != 1 ) + { + // Extend the rectangle to the rightmost part of the last column. + const wxRect rectLastCol = GetDataViewPeer()->GetRectangle(item, GetColumn(columnCount - 1)); + rect.SetRight(rectLastCol.GetRight()); + } + //else: We already have the rectangle we need. + } + + return rect; } int wxDataViewCtrl::GetSelectedItemsCount() const diff --git a/src/osx/window_osx.cpp b/src/osx/window_osx.cpp index a8242fc83c..be965a4890 100644 --- a/src/osx/window_osx.cpp +++ b/src/osx/window_osx.cpp @@ -1919,6 +1919,8 @@ void wxWindowMac::MacUpdateClippedRects() const bool wxWindowMac::MacDoRedraw( long time ) { bool handled = false ; + if ( !IsShownOnScreen() ) + return handled; wxRegion formerUpdateRgn = m_updateRegion; wxRegion clientUpdateRgn = formerUpdateRgn; diff --git a/src/png b/src/png index a016282f47..772e393c7e 160000 --- a/src/png +++ b/src/png @@ -1 +1 @@ -Subproject commit a016282f4752b1177da5722efda7e3045a4ecdf1 +Subproject commit 772e393c7eb95f0424d2d895abd5f8ad0131f500 diff --git a/src/propgrid/advprops.cpp b/src/propgrid/advprops.cpp index b18e0ad834..5a9af11668 100644 --- a/src/propgrid/advprops.cpp +++ b/src/propgrid/advprops.cpp @@ -1085,7 +1085,7 @@ int wxSystemColourProperty::ColToInd( const wxColour& colour ) const if ( colour == GetColour(ind) ) { /*wxLogDebug(wxS("%s(%s): Index %i for ( getcolour(%i,%i,%i), colour(%i,%i,%i))"), - GetClassName(),GetLabel().c_str(), + GetClassName(),GetLabel(), (int)i,(int)GetColour(ind).Red(),(int)GetColour(ind).Green(),(int)GetColour(ind).Blue(), (int)colour.Red(),(int)colour.Green(),(int)colour.Blue());*/ return ind; @@ -2294,8 +2294,6 @@ bool wxDateProperty::StringToValue( wxVariant& variant, const wxString& text, wxString wxDateProperty::ValueToString( wxVariant& value, int argFlags ) const { - const wxChar* format = (const wxChar*) NULL; - wxDateTime dateTime = value.GetDateTime(); if ( !dateTime.IsValid() ) @@ -2311,61 +2309,32 @@ wxString wxDateProperty::ValueToString( wxVariant& value, ms_defaultDateFormat = DetermineDefaultDateFormat( showCentury ); } + wxString format; if ( !m_format.empty() && !(argFlags & wxPG_FULL_VALUE) ) - format = m_format.c_str(); + format = m_format; // Determine default from locale - // NB: This is really simple stuff, but can't figure anything - // better without proper support in wxLocale - if ( !format ) - format = ms_defaultDateFormat.c_str(); + if ( format.empty() ) + format = ms_defaultDateFormat; return dateTime.Format(format); } wxString wxDateProperty::DetermineDefaultDateFormat( bool showCentury ) { - // This code is basically copied from datectlg.cpp's SetFormat - // - wxString format; - - wxDateTime dt; - dt.ParseFormat(wxS("2003-10-13"), wxS("%Y-%m-%d")); - wxString str(dt.Format(wxS("%x"))); - - const wxChar *p = str.c_str(); - while ( *p ) - { - int n=wxAtoi(p); - if (n == dt.GetDay()) - { - format.Append(wxS("%d")); - p += 2; - } - else if (n == (int)dt.GetMonth()+1) - { - format.Append(wxS("%m")); - p += 2; - } - else if (n == dt.GetYear()) - { - format.Append(wxS("%Y")); - p += 4; - } - else if (n == (dt.GetYear() % 100)) - { - if (showCentury) - format.Append(wxS("%Y")); - else - format.Append(wxS("%y")); - p += 2; - } - else - format.Append(*p++); - } + // This code is based on datectlg.cpp's GetLocaleDateFormat() +#if wxUSE_INTL + wxString format = wxLocale::GetOSInfo(wxLOCALE_SHORT_DATE_FMT); + if ( showCentury ) + format.Replace(wxS("%y"), wxS("%Y")); + else + format.Replace(wxS("%Y"), wxS("%y")); return format; +#else + return wxS("%x"); +#endif // wxUSE_INTL/!wxUSE_INTL } bool wxDateProperty::DoSetAttribute( const wxString& name, wxVariant& value ) diff --git a/src/propgrid/editors.cpp b/src/propgrid/editors.cpp index 99ec7ed02f..fce63e54bd 100644 --- a/src/propgrid/editors.cpp +++ b/src/propgrid/editors.cpp @@ -1543,7 +1543,7 @@ public: m_state = 0; m_boxHeight = 12; - SetBackgroundStyle( wxBG_STYLE_CUSTOM ); + SetBackgroundStyle( wxBG_STYLE_PAINT ); } virtual ~wxSimpleCheckBox(); diff --git a/src/propgrid/property.cpp b/src/propgrid/property.cpp index a09beb72e1..9716d3676d 100644 --- a/src/propgrid/property.cpp +++ b/src/propgrid/property.cpp @@ -295,7 +295,7 @@ bool wxPGDefaultRenderer::Render( wxDC& dc, const wxRect& rect, { wxString unitsString = property->GetAttribute(wxPG_ATTR_UNITS, wxEmptyString); if ( !unitsString.empty() ) - text = wxString::Format(wxS("%s %s"), text.c_str(), unitsString.c_str() ); + text = wxString::Format(wxS("%s %s"), text, unitsString ); } } @@ -781,7 +781,7 @@ wxPropertyGrid* wxPGProperty::GetGrid() const int wxPGProperty::Index( const wxPGProperty* p ) const { - return m_children.Index(const_cast(p)); + return wxPGItemIndexInVector(m_children, const_cast(p)); } bool wxPGProperty::ValidateValue( wxVariant& WXUNUSED(value), wxPGValidationInfo& WXUNUSED(validationInfo) ) const @@ -877,7 +877,7 @@ void wxPGProperty::GetDisplayInfo( unsigned int column, wxASSERT_MSG( cell.GetData(), wxString::Format(wxS("Invalid cell for property %s"), - GetName().c_str()) ); + GetName()) ); // We need to return customized cell object. if (pCell) @@ -1428,7 +1428,7 @@ void wxPGProperty::SetValue( wxVariant value, wxVariant* pList, int flags ) wxVariant newValue; AdaptListToValue(value, &newValue); value = newValue; - //wxLogDebug(wxS(">> %s.SetValue() adapted list value to type '%s'"),GetName().c_str(),value.GetType().c_str()); + //wxLogDebug(wxS(">> %s.SetValue() adapted list value to type '%s'"),GetName(),value.GetType()); } if ( HasFlag( wxPG_PROP_AGGREGATE) ) @@ -1444,7 +1444,7 @@ void wxPGProperty::SetValue( wxVariant value, wxVariant* pList, int flags ) wxVariantList::iterator node; unsigned int i = 0; - //wxLogDebug(wxS(">> %s.SetValue() pList parsing"),GetName().c_str()); + //wxLogDebug(wxS(">> %s.SetValue() pList parsing"),GetName()); // Children in list can be in any order, but we will give hint to // GetPropertyByNameWH(). This optimizes for full list parsing. @@ -1454,7 +1454,7 @@ void wxPGProperty::SetValue( wxVariant value, wxVariant* pList, int flags ) wxPGProperty* child = GetPropertyByNameWH(childValue.GetName(), i); if ( child ) { - //wxLogDebug(wxS("%i: child = %s, childValue.GetType()=%s"),i,child->GetBaseName().c_str(),childValue.GetType().c_str()); + //wxLogDebug(wxS("%i: child = %s, childValue.GetType()=%s"),i,child->GetBaseName(),childValue.GetType()); if ( childValue.IsType(wxPG_VARIANT_TYPE_LIST) ) { if ( child->HasFlag(wxPG_PROP_AGGREGATE) && !(flags & wxPG_SETVAL_AGGREGATED) ) @@ -1924,7 +1924,7 @@ double wxPGProperty::GetAttributeAsDouble( const wxString& name, double defVal ) wxVariant wxPGProperty::GetAttributesAsList() const { wxVariantList tempList; - wxVariant v( tempList, wxString::Format(wxS("@%s@attr"),m_name.c_str()) ); + wxVariant v( tempList, wxString::Format(wxS("@%s@attr"),m_name) ); wxPGAttributeStorage::const_iterator it = m_attributes.StartIteration(); wxVariant variant; @@ -2416,17 +2416,7 @@ wxPGProperty* wxPGProperty::InsertChild( int index, void wxPGProperty::RemoveChild( wxPGProperty* p ) { - wxArrayPGProperty::iterator it; - wxArrayPGProperty& children = m_children; - - for ( it=children.begin(); it != children.end(); ++it ) - { - if ( *it == p ) - { - children.erase(it); - break; - } - } + wxPGRemoveItemFromVector(m_children, p); } void wxPGProperty::RemoveChild(unsigned int index) @@ -2436,12 +2426,8 @@ void wxPGProperty::RemoveChild(unsigned int index) void wxPGProperty::SortChildren(int (*fCmp)(wxPGProperty**, wxPGProperty**)) { - m_children.Sort(fCmp); - -#if 0 - // For wxVector w/ wxUSE_STL=1, you would use code like this instead: - std::sort(m_children.begin(), m_children.end(), fCmp); -#endif + wxArray_SortFunction sf(fCmp); + std::sort(m_children.begin(), m_children.end(), sf); } void wxPGProperty::AdaptListToValue( wxVariant& list, wxVariant* value ) const @@ -2468,7 +2454,7 @@ void wxPGProperty::AdaptListToValue( wxVariant& list, wxVariant* value ) const unsigned int n = 0; wxVariant childValue = list[n]; - //wxLogDebug(wxS(">> %s.AdaptListToValue()"),GetBaseName().c_str()); + //wxLogDebug(wxS(">> %s.AdaptListToValue()"),GetBaseName()); for ( unsigned int i = 0; i < GetChildCount(); i++ ) { @@ -2476,7 +2462,7 @@ void wxPGProperty::AdaptListToValue( wxVariant& list, wxVariant* value ) const if ( childValue.GetName() == child->GetBaseName() ) { - //wxLogDebug(wxS(" %s(n=%i), %s"),childValue.GetName().c_str(),n,childValue.GetType().c_str()); + //wxLogDebug(wxS(" %s(n=%i), %s"),childValue.GetName(),n,childValue.GetType()); if ( childValue.IsType(wxPG_VARIANT_TYPE_LIST) ) { @@ -2650,11 +2636,11 @@ wxPGProperty* wxPGProperty::GetItemAtY( unsigned int y, /* if ( current ) { - wxLogDebug(wxS("%s::GetItemAtY(%i) -> %s"),this->GetLabel().c_str(),y,current->GetLabel().c_str()); + wxLogDebug(wxS("%s::GetItemAtY(%i) -> %s"),this->GetLabel(),y,current->GetLabel()); } else { - wxLogDebug(wxS("%s::GetItemAtY(%i) -> NULL"),this->GetLabel().c_str(),y); + wxLogDebug(wxS("%s::GetItemAtY(%i) -> NULL"),this->GetLabel(),y); } */ diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index 9ea2aeba5f..87b3eef99f 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -137,22 +137,6 @@ DeletedObjects gs_deletedEditorObjects; } // anonymous namespace #endif - // Utility to check if specific item is in a vector. -template -static bool wxPGItemExistsInVector(const wxVector& vector, const T& item) -{ -#if wxUSE_STL - return std::find(vector.begin(), vector.end(), item) != vector.end(); -#else - for (typename wxVector::const_iterator it = vector.begin(); it != vector.end(); ++it) - { - if ( *it == item ) - return true; - } - return false; -#endif // wxUSE_STL/!wxUSE_STL -} - // ----------------------------------------------------------------------- #if wxUSE_INTL @@ -498,7 +482,7 @@ void wxPropertyGrid::Init2() RegainColours(); // This helps with flicker - SetBackgroundStyle( wxBG_STYLE_CUSTOM ); + SetBackgroundStyle( wxBG_STYLE_PAINT ); // Rely on native double-buffering by default. #if wxALWAYS_NATIVE_DOUBLE_BUFFER @@ -1443,7 +1427,7 @@ void wxPropertyGrid::RegainColours() wxColour capForeCol = wxPGAdjustColour(m_colCapBack,colDec,5000,5000,true); if (wxPGGetColAvg(m_colCapBack) < 100) capForeCol = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ); - + m_colCapFore = capForeCol; m_categoryDefaultCell.GetData()->SetFgCol(capForeCol); } @@ -2095,8 +2079,8 @@ int wxPropertyGrid::DoDrawItems( wxDC& dc, /* wxLogDebug(wxS(" -> DoDrawItems(\"%s\" -> \"%s\"") wxS(" %i -> %i height=%i (ch=%i), itemsRect = 0x%lX %i,%i %ix%i)"), - firstItem->GetLabel().c_str(), - lastItem->GetLabel().c_str(), + firstItem->GetLabel(), + lastItem->GetLabel(), firstItemTopY, lastItemBottomY, (int)(lastItemBottomY - firstItemTopY), (int)m_height, @@ -2606,7 +2590,11 @@ void wxPropertyGrid::RefreshProperty( wxPGProperty* p ) { // NB: We must copy the selection. wxArrayPGProperty selection = m_pState->m_selection; - DoSetSelection(selection, wxPG_SEL_FORCE); + int selFlags = wxPG_SEL_FORCE; + // We want to keep property's editor focused. + if ( IsEditorFocused() ) + selFlags |= wxPG_SEL_FOCUS; + DoSetSelection(selection, selFlags); } DrawItemAndChildren(p); @@ -4021,8 +4009,8 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags ) /* if (p) { - wxLogDebug(wxS("SelectProperty( %s (%s[%i]) )"),p->GetLabel().c_str(), - p->m_parent->GetLabel().c_str(),p->GetIndexInParent()); + wxLogDebug(wxS("SelectProperty( %s (%s[%i]) )"),p->GetLabel(), + p->m_parent->GetLabel(),p->GetIndexInParent()); } else { @@ -6438,13 +6426,13 @@ wxPGProperty* wxPropertyGridPopulator::Add( const wxString& propClass, if ( parent->HasFlag(wxPG_PROP_AGGREGATE) ) { - ProcessError(wxString::Format(wxS("new children cannot be added to '%s'"),parent->GetName().c_str())); + ProcessError(wxString::Format(wxS("new children cannot be added to '%s'"),parent->GetName())); return NULL; } if ( !classInfo || !classInfo->IsKindOf(wxCLASSINFO(wxPGProperty)) ) { - ProcessError(wxString::Format(wxS("'%s' is not valid property class"),propClass.c_str())); + ProcessError(wxString::Format(wxS("'%s' is not valid property class"),propClass)); return NULL; } @@ -6487,7 +6475,7 @@ wxPGChoices wxPropertyGridPopulator::ParseChoices( const wxString& choicesString wxString ids = choicesString.substr(1); wxPGHashMapS2P::iterator it = m_dictIdChoices.find(ids); if ( it == m_dictIdChoices.end() ) - ProcessError(wxString::Format(wxS("No choices defined for id '%s'"),ids.c_str())); + ProcessError(wxString::Format(wxS("No choices defined for id '%s'"),ids)); else choices.AssignData((wxPGChoicesData*)it->second); } @@ -6528,7 +6516,7 @@ wxPGChoices wxPropertyGridPopulator::ParseChoices( const wxString& choicesString choices.Add(label, l); } labelValid = false; - //wxLogDebug(wxS("%s, %s"),label.c_str(),value.c_str()); + //wxLogDebug(wxS("%s, %s"),label,value); value.clear(); label.clear(); state = 1; @@ -6645,7 +6633,7 @@ bool wxPropertyGridPopulator::AddAttribute( const wxString& name, } else { - ProcessError(wxString::Format(wxS("Invalid attribute type '%s'"),type.c_str())); + ProcessError(wxString::Format(wxS("Invalid attribute type '%s'"),type)); return false; } } @@ -6659,7 +6647,7 @@ bool wxPropertyGridPopulator::AddAttribute( const wxString& name, void wxPropertyGridPopulator::ProcessError( const wxString& msg ) { - wxLogError(_("Error in resource: %s"),msg.c_str()); + wxLogError(_("Error in resource: %s"),msg); } // ----------------------------------------------------------------------- diff --git a/src/propgrid/propgridiface.cpp b/src/propgrid/propgridiface.cpp index d5083ecac5..307753986e 100644 --- a/src/propgrid/propgridiface.cpp +++ b/src/propgrid/propgridiface.cpp @@ -399,7 +399,7 @@ void wxPGTypeOperationFailed( const wxPGProperty* p, { wxASSERT( p != NULL ); wxLogError( _("Type operation \"%s\" failed: Property labeled \"%s\" is of type \"%s\", NOT \"%s\"."), - op.c_str(), p->GetLabel().c_str(), p->GetValue().GetType().c_str(), typestr.c_str() ); + op, p->GetLabel(), p->GetValue().GetType(), typestr ); } // ----------------------------------------------------------------------- @@ -434,7 +434,7 @@ void wxPropertyGridInterface::SetValidationFailureBehavior( int vfbFlags ) wxPGProperty* wxPropertyGridInterface::GetPropertyByNameA( const wxString& name ) const { wxPGProperty* p = GetPropertyByName(name); - wxASSERT_MSG(p,wxString::Format(wxS("no property with name '%s'"),name.c_str())); + wxASSERT_MSG(p,wxString::Format(wxS("no property with name '%s'"),name)); return p; } @@ -896,15 +896,16 @@ wxPGVIterator wxPropertyGridInterface::GetVIterator( int flags ) const static wxString EscapeDelimiters(const wxString& s) { wxString result; - result.Alloc(s.length()); - const wxChar* ch = s.c_str(); - while (*ch) + result.reserve(s.length()); + + for (wxString::const_iterator it = s.begin(); it != s.end(); ++it) { - if (*ch == wxT(';') || *ch == wxT('|') || *ch == wxT(',')) - result += wxT('\\'); - result += *ch; - ++ch; + wxStringCharType ch = *it; + if ( ch == wxS(';') || ch == wxS('|') || ch == wxS(',') ) + result += wxS('\\'); + result += ch; } + return result; } diff --git a/src/propgrid/propgridpagestate.cpp b/src/propgrid/propgridpagestate.cpp index be18422604..6d11d450a1 100644 --- a/src/propgrid/propgridpagestate.cpp +++ b/src/propgrid/propgridpagestate.cpp @@ -43,44 +43,6 @@ #define wxPG_DEFAULT_SPLITTERX 110 -// Utility to remove given item from the vector. -template -static void wxPGRemoveItemFromVector(wxVector& vector, const T& item) -{ -#if wxUSE_STL - typename wxVector::iterator it = std::find(vector.begin(), vector.end(), item); - if ( it != vector.end() ) - { - vector.erase(it); - } -#else - for (typename wxVector::iterator it = vector.begin(); it != vector.end(); ++it) - { - if ( *it == item ) - { - vector.erase(it); - return; - } - } -#endif // wxUSE_STL/!wxUSE_STL -} - -// Utility to check if specific item is in a vector. -template -static bool wxPGItemExistsInVector(const wxVector& vector, const T& item) -{ -#if wxUSE_STL - return std::find(vector.begin(), vector.end(), item) != vector.end(); -#else - for (typename wxVector::const_iterator it = vector.begin(); it != vector.end(); ++it) - { - if ( *it == item ) - return true; - } - return false; -#endif // wxUSE_STL/!wxUSE_STL -} - // ----------------------------------------------------------------------- // wxPropertyGridIterator // ----------------------------------------------------------------------- @@ -1599,7 +1561,7 @@ void wxPropertyGridPageState::DoSetPropertyValues( const wxVariantList& list, wx wxStrcmp(current->GetType(), p->GetValue().GetType()) == 0, wxString::Format( wxS("setting value of property \"%s\" from variant"), - p->GetName().c_str()) + p->GetName()) ); p->SetValue(*current); diff --git a/src/propgrid/props.cpp b/src/propgrid/props.cpp index 4fbd16c3d1..0d4b3ead19 100644 --- a/src/propgrid/props.cpp +++ b/src/propgrid/props.cpp @@ -385,14 +385,14 @@ bool NumericValidation( const wxPGProperty* property, if ( !maxOk ) msg = wxString::Format( _("Value must be %s or higher."), - smin.c_str()); + smin); else { wxVariant vmax = WXVARIANT(max); wxString smax = property->ValueToString(vmax); msg = wxString::Format( _("Value must be between %s and %s."), - smin.c_str(), smax.c_str()); + smin, smax); } pValidationInfo->SetFailureMessage(msg); } @@ -416,14 +416,14 @@ bool NumericValidation( const wxPGProperty* property, if ( !minOk ) msg = wxString::Format( _("Value must be %s or less."), - smax.c_str()); + smax); else { wxVariant vmin = WXVARIANT(min); wxString smin = property->ValueToString(vmin); msg = wxString::Format( _("Value must be between %s and %s."), - smin.c_str(), smax.c_str()); + smin, smax); } pValidationInfo->SetFailureMessage(msg); } @@ -499,14 +499,14 @@ bool NumericValidation( const wxPGProperty* property, if ( !maxOk ) msg = wxString::Format( _("Value must be %s or higher."), - smin.c_str()); + smin); else { wxVariant vmax = WXVARIANT(max); wxString smax = property->ValueToString(vmax); msg = wxString::Format( _("Value must be between %s and %s."), - smin.c_str(), smax.c_str()); + smin, smax); } pValidationInfo->SetFailureMessage(msg); } @@ -530,14 +530,14 @@ bool NumericValidation( const wxPGProperty* property, if ( !minOk ) msg = wxString::Format( _("Value must be %s or less."), - smax.c_str()); + smax); else { wxVariant vmin = WXVARIANT(min); wxString smin = property->ValueToString(vmin); msg = wxString::Format( _("Value must be between %s and %s."), - smin.c_str(), smax.c_str()); + smin, smax); } pValidationInfo->SetFailureMessage(msg); } @@ -923,7 +923,7 @@ const wxString& wxPropertyGrid::DoubleToString(wxString& target, *precTemplate << wxS('f'); } - target.Printf( precTemplate->c_str(), value ); + target.Printf( *precTemplate, value ); } else { @@ -1131,7 +1131,7 @@ wxString wxBoolProperty::ValueToString( wxVariant& value, else notFmt = wxS("Not %s"); - return wxString::Format(notFmt.c_str(), m_label.c_str()); + return wxString::Format(notFmt, m_label); } } @@ -2315,11 +2315,10 @@ bool wxLongStringProperty::DisplayEditorDialog( wxPGProperty* prop, wxPropertyGr rowsizer->Add(ed, wxSizerFlags(1).Expand().Border(wxALL, spacing)); topsizer->Add(rowsizer, wxSizerFlags(1).Expand()); - wxStdDialogButtonSizer* buttonSizer = new wxStdDialogButtonSizer(); + long btnSizerFlags = wxCANCEL; if ( !prop->HasFlag(wxPG_PROP_READONLY) ) - buttonSizer->AddButton(new wxButton(dlg, wxID_OK)); - buttonSizer->AddButton(new wxButton(dlg, wxID_CANCEL)); - buttonSizer->Realize(); + btnSizerFlags |= wxOK; + wxStdDialogButtonSizer* buttonSizer = dlg->CreateStdDialogButtonSizer(btnSizerFlags); topsizer->Add(buttonSizer, wxSizerFlags(0).Right().Border(wxBOTTOM|wxRIGHT, spacing)); dlg->SetSizer( topsizer ); @@ -2494,10 +2493,7 @@ bool wxPGArrayEditorDialog::Create( wxWindow *parent, topsizer->Add(m_elb, wxSizerFlags(1).Expand().Border(0, spacing)); // Standard dialog buttons - wxStdDialogButtonSizer* buttonSizer = new wxStdDialogButtonSizer(); - buttonSizer->AddButton(new wxButton(this, wxID_OK)); - buttonSizer->AddButton(new wxButton(this, wxID_CANCEL)); - buttonSizer->Realize(); + wxStdDialogButtonSizer* buttonSizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL); topsizer->Add(buttonSizer, wxSizerFlags(0).Right().Border(wxALL, spacing)); m_elb->SetFocus(); diff --git a/src/qt/anybutton.cpp b/src/qt/anybutton.cpp index 216b796979..dc56780af2 100644 --- a/src/qt/anybutton.cpp +++ b/src/qt/anybutton.cpp @@ -58,6 +58,8 @@ void wxAnyButton::QtSetBitmap( const wxBitmap &bitmap ) QPixmap *pixmap = bitmap.GetHandle(); m_qtPushButton->setIcon( QIcon( *pixmap )); m_qtPushButton->setIconSize( pixmap->rect().size() ); + + m_bitmap = bitmap; } void wxAnyButton::SetLabel( const wxString &label ) @@ -70,6 +72,11 @@ QWidget *wxAnyButton::GetHandle() const return m_qtPushButton; } +wxBitmap wxAnyButton::DoGetBitmap(State state) const +{ + return state == State_Normal ? m_bitmap : wxNullBitmap; +} + void wxAnyButton::DoSetBitmap(const wxBitmap& bitmap, State which) { switch ( which ) diff --git a/src/qt/checkbox.cpp b/src/qt/checkbox.cpp index 48baecf281..c248531f72 100644 --- a/src/qt/checkbox.cpp +++ b/src/qt/checkbox.cpp @@ -130,3 +130,14 @@ QWidget *wxCheckBox::GetHandle() const { return m_qtCheckBox; } + +wxString wxCheckBox::GetLabel() const +{ + return wxQtConvertString( m_qtCheckBox->text() ); +} + +void wxCheckBox::SetLabel(const wxString& label) +{ + m_qtCheckBox->setText( wxQtConvertString(label) ); +} + diff --git a/src/qt/combobox.cpp b/src/qt/combobox.cpp index 14af9eb2d9..1080721625 100644 --- a/src/qt/combobox.cpp +++ b/src/qt/combobox.cpp @@ -20,6 +20,8 @@ class wxQtComboBox : public wxQtEventSignalHandler< QComboBox, wxComboBox > { public: wxQtComboBox( wxWindow *parent, wxComboBox *handler ); + virtual void showPopup() wxOVERRIDE; + virtual void hidePopup() wxOVERRIDE; private: void activated(int index); @@ -36,6 +38,20 @@ wxQtComboBox::wxQtComboBox( wxWindow *parent, wxComboBox *handler ) this, &wxQtComboBox::editTextChanged); } +void wxQtComboBox::showPopup() +{ + wxCommandEvent event( wxEVT_COMBOBOX_DROPDOWN, GetHandler()->GetId() ); + EmitEvent( event ); + QComboBox::showPopup(); +} + +void wxQtComboBox::hidePopup() +{ + wxCommandEvent event( wxEVT_COMBOBOX_CLOSEUP, GetHandler()->GetId() ); + EmitEvent( event ); + QComboBox::hidePopup(); +} + void wxQtComboBox::activated(int WXUNUSED(index)) { wxComboBox *handler = GetHandler(); diff --git a/src/qt/dc.cpp b/src/qt/dc.cpp index 38e4e0af21..6fb5ed0e5a 100644 --- a/src/qt/dc.cpp +++ b/src/qt/dc.cpp @@ -159,7 +159,7 @@ void wxQtDCImpl::SetPen(const wxPen& pen) void wxQtDCImpl::SetBrush(const wxBrush& brush) { m_brush = brush; - + if (brush.GetStyle() == wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE) { // Use a monochrome mask: use foreground color for the mask @@ -190,7 +190,7 @@ void wxQtDCImpl::SetBrush(const wxBrush& brush) void wxQtDCImpl::SetBackground(const wxBrush& brush) { m_backgroundBrush = brush; - + if (m_qtPainter->isActive()) m_qtPainter->setBackground(brush.GetHandle()); } @@ -375,7 +375,7 @@ void wxQtDCImpl::Clear() { int width, height; DoGetSize(&width, &height); - + m_qtPainter->eraseRect(QRect(0, 0, width, height)); } @@ -486,7 +486,7 @@ bool wxQtDCImpl::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const if ( col ) { wxCHECK_MSG( m_qtImage != NULL, false, "This DC doesn't support GetPixel()" ); - + QColor pixel = m_qtImage->pixel( x, y ); col->Set( pixel.red(), pixel.green(), pixel.blue(), pixel.alpha() ); @@ -519,7 +519,7 @@ void wxQtDCImpl::DoDrawArc(wxCoord x1, wxCoord y1, qreal penWidth = m_qtPainter->pen().width(); qreal lenRadius = l1.length() - penWidth / 2; QPointF centerToCorner( lenRadius, lenRadius ); - + QRect rectangle = QRectF( center - centerToCorner, center + centerToCorner ).toRect(); // Calculate the angles @@ -530,7 +530,7 @@ void wxQtDCImpl::DoDrawArc(wxCoord x1, wxCoord y1, { spanAngle = -spanAngle; } - + if ( spanAngle == 0 ) m_qtPainter->drawEllipse( rectangle ); else @@ -578,7 +578,7 @@ void wxQtDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, y += penWidth / 2; width -= penWidth; height -= penWidth; - + m_qtPainter->drawRoundedRect( x, y, width, height, radius, radius ); } @@ -591,7 +591,7 @@ void wxQtDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, y += penWidth / 2; width -= penWidth; height -= penWidth; - + if ( m_pen.IsNonTransparent() ) { // Save pen/brush @@ -620,7 +620,7 @@ void wxQtDCImpl::DoCrossHair(wxCoord x, wxCoord y) int left, top, right, bottom; inv.map( w, h, &right, &bottom ); inv.map( 0, 0, &left, &top ); - + m_qtPainter->drawLine( left, y, right, y ); m_qtPainter->drawLine( x, top, x, bottom ); } @@ -636,18 +636,18 @@ void wxQtDCImpl::DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, QPixmap pix = *bmp.GetHandle(); if (pix.depth() == 1) { //Monochrome bitmap, draw using text fore/background - + //Save pen/brush QBrush savedBrush = m_qtPainter->background(); QPen savedPen = m_qtPainter->pen(); - + //Use text colors m_qtPainter->setBackground(QBrush(m_textBackgroundColour.GetQColor())); m_qtPainter->setPen(QPen(m_textForegroundColour.GetQColor())); //Draw m_qtPainter->drawPixmap(x, y, pix); - + //Restore saved settings m_qtPainter->setBackground(savedBrush); m_qtPainter->setPen(savedPen); @@ -668,11 +668,11 @@ void wxQtDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y) // Disable logical function QPainter::CompositionMode savedOp = m_qtPainter->compositionMode(); m_qtPainter->setCompositionMode( QPainter::CompositionMode_SourceOver ); - - if (m_backgroundMode == wxSOLID) + + if (m_backgroundMode == wxBRUSHSTYLE_SOLID) { m_qtPainter->setBackgroundMode(Qt::OpaqueMode); - + //Save pen/brush QBrush savedBrush = m_qtPainter->background(); @@ -698,9 +698,9 @@ void wxQtDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y) void wxQtDCImpl::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle) { - if (m_backgroundMode == wxSOLID) + if (m_backgroundMode == wxBRUSHSTYLE_SOLID) m_qtPainter->setBackgroundMode(Qt::OpaqueMode); - + //Move and rotate (reverse angle direction in Qt and wx) m_qtPainter->translate(x, y); m_qtPainter->rotate(-angle); @@ -712,22 +712,22 @@ void wxQtDCImpl::DoDrawRotatedText(const wxString& text, QPainter::CompositionMode savedOp = m_qtPainter->compositionMode(); m_qtPainter->setCompositionMode( QPainter::CompositionMode_SourceOver ); - if (m_backgroundMode == wxSOLID) + if (m_backgroundMode == wxBRUSHSTYLE_SOLID) { m_qtPainter->setBackgroundMode(Qt::OpaqueMode); - + //Save pen/brush QBrush savedBrush = m_qtPainter->background(); - + //Use text colors m_qtPainter->setBackground(QBrush(m_textBackgroundColour.GetQColor())); - + //Draw m_qtPainter->drawText(x, y, 1, 1, Qt::TextDontClip, wxQtConvertString(text)); - + //Restore saved settings m_qtPainter->setBackground(savedBrush); - + m_qtPainter->setBackgroundMode(Qt::TransparentMode); } else @@ -749,9 +749,9 @@ bool wxQtDCImpl::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord WXUNUSED(ysrcMask) ) { wxQtDCImpl *implSource = (wxQtDCImpl*)source->GetImpl(); - + QImage *qtSource = implSource->GetQImage(); - + // Not a CHECK on purpose if ( !qtSource ) return false; @@ -763,7 +763,7 @@ bool wxQtDCImpl::DoBlit(wxCoord xdest, wxCoord ydest, // Change logical function wxRasterOperationMode savedMode = GetLogicalFunction(); SetLogicalFunction( rop ); - + m_qtPainter->drawImage( QRect( xdest, ydest, width, height ), qtSourceConverted, QRect( xsrc, ysrc, width, height ) ); @@ -806,7 +806,7 @@ void wxQtDCImpl::DoDrawPolygon(int n, const wxPoint points[], } Qt::FillRule fill = (fillStyle == wxWINDING_RULE) ? Qt::WindingFill : Qt::OddEvenFill; - + m_qtPainter->translate(xoffset, yoffset); m_qtPainter->drawPolygon(qtPoints, fill); // Reset transform diff --git a/src/qt/font.cpp b/src/qt/font.cpp index 79e66fc81a..7e328d099a 100644 --- a/src/qt/font.cpp +++ b/src/qt/font.cpp @@ -469,9 +469,18 @@ void wxNativeFontInfo::SetPixelSize(const wxSize& size) void wxNativeFontInfo::SetStyle(wxFontStyle style) { - m_qtFont.setItalic(style == wxFONTSTYLE_ITALIC); -//case wxFONTSTYLE_SLANT: -//case wxFONTSTYLE_NORMAL: + switch(style) + { + case wxFONTSTYLE_ITALIC: + m_qtFont.setStyle(QFont::StyleItalic); + break; + case wxFONTSTYLE_NORMAL: + m_qtFont.setStyle(QFont::StyleNormal); + break; + case wxFONTSTYLE_SLANT: + m_qtFont.setStyle(QFont::StyleOblique); + break; + } } void wxNativeFontInfo::SetNumericWeight(int weight) diff --git a/src/qt/gauge.cpp b/src/qt/gauge.cpp index ffa1c0963d..8952043db8 100644 --- a/src/qt/gauge.cpp +++ b/src/qt/gauge.cpp @@ -58,6 +58,7 @@ bool wxGauge::Create(wxWindow *parent, m_qtProgressBar->setOrientation( wxQtConvertOrientation( style, wxGA_HORIZONTAL )); m_qtProgressBar->setRange( 0, range ); m_qtProgressBar->setTextVisible( style & wxGA_TEXT ); + m_qtProgressBar->setValue(0); return QtCreateControl( parent, id, pos, size, style, validator, name ); } diff --git a/src/qt/menu.cpp b/src/qt/menu.cpp index 61d27b7976..79b1337ecb 100644 --- a/src/qt/menu.cpp +++ b/src/qt/menu.cpp @@ -51,29 +51,38 @@ static wxMenuItem *GetMenuItemAt( const wxMenu *menu, size_t position ) return NULL; } +static void AddItemActionToGroup( const wxMenuItem *groupItem, QAction *itemAction ) +{ + QAction *groupItemAction = groupItem->GetHandle(); + QActionGroup *itemActionGroup = groupItemAction->actionGroup(); + wxASSERT_MSG( itemActionGroup != NULL, "An action group should have been setup" ); + itemActionGroup->addAction( itemAction ); +} static void InsertMenuItemAction( const wxMenu *menu, const wxMenuItem *previousItem, - const wxMenuItem *item, const wxMenuItem *successiveItem ) + wxMenuItem *item, const wxMenuItem *successiveItem ) { QMenu *qtMenu = menu->GetHandle(); QAction *itemAction = item->GetHandle(); switch ( item->GetKind() ) { case wxITEM_RADIO: - // If the previous menu item is a radio item then add this item to the + // If a neighbouring menu item is a radio item then add this item to the // same action group, otherwise start a new group: if ( previousItem != NULL && previousItem->GetKind() == wxITEM_RADIO ) { - QAction *previousItemAction = previousItem->GetHandle(); - QActionGroup *previousItemActionGroup = previousItemAction->actionGroup(); - wxASSERT_MSG( previousItemActionGroup != NULL, "An action group should have been setup" ); - previousItemActionGroup->addAction( itemAction ); + AddItemActionToGroup( previousItem, itemAction ); + } + else if ( successiveItem != NULL && successiveItem->GetKind() == wxITEM_RADIO ) + { + AddItemActionToGroup( successiveItem, itemAction ); } else { QActionGroup *actionGroup = new QActionGroup( qtMenu ); actionGroup->addAction( itemAction ); + item->Check(); wxASSERT_MSG( itemAction->actionGroup() == actionGroup, "Must be the same action group" ); } break; @@ -184,6 +193,8 @@ wxMenuBar::wxMenuBar(size_t count, wxMenu *menus[], const wxString titles[], lon static QMenu *SetTitle( wxMenu *menu, const wxString &title ) { + menu->SetTitle(title); + QMenu *qtMenu = menu->GetHandle(); qtMenu->setTitle( wxQtConvertString( title )); @@ -243,6 +254,12 @@ void wxMenuBar::EnableTop(size_t pos, bool enable) qtAction->setEnabled( enable ); } +bool wxMenuBar::IsEnabledTop(size_t pos) const +{ + QAction *qtAction = GetActionAt( m_qtMenuBar, pos ); + return qtAction->isEnabled(); +} + void wxMenuBar::SetMenuLabel(size_t pos, const wxString& label) { diff --git a/src/qt/menuitem.cpp b/src/qt/menuitem.cpp index 6ce89dc5be..fa729e33de 100644 --- a/src/qt/menuitem.cpp +++ b/src/qt/menuitem.cpp @@ -165,5 +165,7 @@ void wxQtAction::onActionTriggered( bool checked ) { wxMenuItem *handler = GetHandler(); wxMenu *menu = handler->GetMenu(); + if ( handler->IsCheckable() ) + handler->Check(checked); menu->SendEvent( handler->GetId(), handler->IsCheckable() ? checked : -1 ); } diff --git a/src/qt/spinctrl.cpp b/src/qt/spinctrl.cpp index ee0b1e670d..e7cdeddff7 100644 --- a/src/qt/spinctrl.cpp +++ b/src/qt/spinctrl.cpp @@ -42,8 +42,8 @@ bool wxSpinCtrlQt< T, Widget >::Create( wxWindow *parent, wxWindowID id, m_qtSpinBox->setAccelerated(true); // to match gtk behavior - SetValue( initial ); SetRange( min, max ); + SetValue( initial ); SetIncrement( inc ); if ( !value.IsEmpty() ) diff --git a/src/qt/stattext.cpp b/src/qt/stattext.cpp index c60a6fdd36..8e410bfa10 100644 --- a/src/qt/stattext.cpp +++ b/src/qt/stattext.cpp @@ -62,6 +62,11 @@ void wxStaticText::SetLabel(const wxString& label) m_qtLabel->setText( wxQtConvertString( label ) ); } +wxString wxStaticText::GetLabel() const +{ + return wxQtConvertString( m_qtLabel->text() ); +} + QWidget *wxStaticText::GetHandle() const { return m_qtLabel; diff --git a/src/qt/textctrl.cpp b/src/qt/textctrl.cpp index c600216903..5ef1bd97ff 100644 --- a/src/qt/textctrl.cpp +++ b/src/qt/textctrl.cpp @@ -121,6 +121,8 @@ bool wxTextCtrl::Create(wxWindow *parent, { m_qtLineEdit = new wxQtLineEdit( parent, this ); m_qtTextEdit = NULL; + if ( style & wxTE_PASSWORD ) + m_qtLineEdit->setEchoMode( QLineEdit::Password ); } else { @@ -161,15 +163,26 @@ int wxTextCtrl::GetNumberOfLines() const bool wxTextCtrl::IsModified() const { - return false; + if ( IsSingleLine() ) + return m_qtLineEdit->isModified(); + else + return m_qtTextEdit->isWindowModified(); } void wxTextCtrl::MarkDirty() { + if ( IsSingleLine() ) + return m_qtLineEdit->setModified( true ); + else + return m_qtTextEdit->setWindowModified( true ); } void wxTextCtrl::DiscardEdits() { + if ( IsSingleLine() ) + return m_qtLineEdit->setModified( false ); + else + return m_qtTextEdit->setWindowModified( false ); } bool wxTextCtrl::SetStyle(long WXUNUSED(start), long WXUNUSED(end), const wxTextAttr& WXUNUSED(style)) diff --git a/src/qt/window.cpp b/src/qt/window.cpp index 87feb5ecb7..8342db8c74 100644 --- a/src/qt/window.cpp +++ b/src/qt/window.cpp @@ -936,13 +936,17 @@ void wxWindowQt::SetAcceleratorTable( const wxAcceleratorTable& accel ) { wxWindowBase::SetAcceleratorTable( accel ); - // Disable previously set accelerators - while ( !m_qtShortcuts->isEmpty() ) - delete m_qtShortcuts->takeFirst(); + if ( m_qtShortcuts ) + { + // Disable previously set accelerators + while ( !m_qtShortcuts->isEmpty() ) + delete m_qtShortcuts->takeFirst(); + + // Create new shortcuts (use GetHandle() so all events inside + // the window are handled, not only in the container subwindow) + delete m_qtShortcuts; + } - // Create new shortcuts (use GetHandle() so all events inside - // the window are handled, not only in the container subwindow) - delete m_qtShortcuts; m_qtShortcuts = accel.ConvertShortcutTable( GetHandle() ); // Connect shortcuts to window diff --git a/src/ribbon/art_aui.cpp b/src/ribbon/art_aui.cpp index 83fb98d6e6..ab8993ae51 100644 --- a/src/ribbon/art_aui.cpp +++ b/src/ribbon/art_aui.cpp @@ -471,7 +471,7 @@ void wxRibbonAUIArtProvider::DrawTab(wxDC& dc, if(!label.IsEmpty()) { dc.SetTextForeground(m_tab_label_colour); - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); int offset = 0; if(icon.IsOk()) diff --git a/src/ribbon/art_msw.cpp b/src/ribbon/art_msw.cpp index f2a85811cd..07b4114b59 100644 --- a/src/ribbon/art_msw.cpp +++ b/src/ribbon/art_msw.cpp @@ -1373,7 +1373,7 @@ void wxRibbonMSWArtProvider::DrawTab( { dc.SetFont(m_tab_label_font); dc.SetTextForeground(m_tab_label_colour); - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); int text_height; int text_width; diff --git a/src/ribbon/bar.cpp b/src/ribbon/bar.cpp index 271aa8c46b..9804ec19d7 100644 --- a/src/ribbon/bar.cpp +++ b/src/ribbon/bar.cpp @@ -792,7 +792,7 @@ void wxRibbonBar::CommonInit(long style) { SetArtProvider(new wxRibbonDefaultArtProvider); } - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); m_toggle_button_hovered = false; m_bar_hovered = false; diff --git a/src/ribbon/buttonbar.cpp b/src/ribbon/buttonbar.cpp index 5be028a710..b0976c1750 100644 --- a/src/ribbon/buttonbar.cpp +++ b/src/ribbon/buttonbar.cpp @@ -895,7 +895,7 @@ void wxRibbonButtonBar::CommonInit(long WXUNUSED(style)) m_lock_active_state = false; m_show_tooltips_for_disabled = false; - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); } void wxRibbonButtonBar::SetShowToolTipsForDisabled(bool show) diff --git a/src/ribbon/gallery.cpp b/src/ribbon/gallery.cpp index b9ac96123d..29f39ef711 100644 --- a/src/ribbon/gallery.cpp +++ b/src/ribbon/gallery.cpp @@ -135,7 +135,7 @@ void wxRibbonGallery::CommonInit(long WXUNUSED(style)) m_extension_button_state = wxRIBBON_GALLERY_BUTTON_NORMAL; m_hovered = false; - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); } void wxRibbonGallery::OnMouseEnter(wxMouseEvent& evt) diff --git a/src/ribbon/page.cpp b/src/ribbon/page.cpp index f993ed4faf..93b89c4e5b 100644 --- a/src/ribbon/page.cpp +++ b/src/ribbon/page.cpp @@ -82,7 +82,7 @@ wxRibbonPageScrollButton::wxRibbonPageScrollButton(wxRibbonPage* sibling, const wxSize& size, long style) : wxRibbonControl(sibling->GetParent(), id, pos, size, wxBORDER_NONE) { - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); m_sibling = sibling; m_flags = (style & wxRIBBON_SCROLL_BTN_DIRECTION_MASK) | wxRIBBON_SCROLL_BTN_FOR_PAGE; } @@ -207,7 +207,7 @@ void wxRibbonPage::CommonInit(const wxString& label, const wxBitmap& icon) m_scroll_amount = 0; m_scroll_buttons_visible = false; - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); wxDynamicCast(GetParent(), wxRibbonBar)->AddPage(this); } diff --git a/src/ribbon/panel.cpp b/src/ribbon/panel.cpp index 6964788a35..dc97dac68c 100644 --- a/src/ribbon/panel.cpp +++ b/src/ribbon/panel.cpp @@ -135,7 +135,7 @@ void wxRibbonPanel::CommonInit(const wxString& label, const wxBitmap& icon, long } SetAutoLayout(true); - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); SetMinSize(wxSize(20, 20)); } diff --git a/src/ribbon/toolbar.cpp b/src/ribbon/toolbar.cpp index 80cd8311a9..43e0490e62 100644 --- a/src/ribbon/toolbar.cpp +++ b/src/ribbon/toolbar.cpp @@ -113,7 +113,7 @@ void wxRibbonToolBar::CommonInit(long WXUNUSED(style)) m_nrows_max = 1; m_sizes = new wxSize[1]; m_sizes[0] = wxSize(0, 0); - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); } wxRibbonToolBar::~wxRibbonToolBar() diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index c47cbca289..7cfbe3effc 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -9657,7 +9657,7 @@ bool wxRichTextFieldTypeStandard::Draw(wxRichTextField* obj, wxDC& dc, wxRichTex int w, h, maxDescent; dc.SetFont(m_font); dc.GetTextExtent(m_label, & w, &h, & maxDescent); - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); dc.SetTextForeground(textColour); int x = clientArea.x + (clientArea.width - w)/2; diff --git a/src/richtext/richtextctrl.cpp b/src/richtext/richtextctrl.cpp index 2c93417aee..844f264419 100644 --- a/src/richtext/richtextctrl.cpp +++ b/src/richtext/richtextctrl.cpp @@ -242,7 +242,7 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va const wxValidator& validator, const wxString& name) { style |= wxVSCROLL; - + // If read-only, the programmer probably wants to retain dialog keyboard navigation. // If you don't, then pass wxWANTS_CHARS explicitly. if ((style & wxTE_READONLY) == 0) @@ -283,7 +283,7 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va SetDefaultStyle(defaultAttributes); SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); GetBuffer().Reset(); GetBuffer().SetRichTextCtrl(this); @@ -878,6 +878,7 @@ void wxRichTextCtrl::OnMoveMouse(wxMouseEvent& event) Refresh(); // This is needed in wxMSW, otherwise resetting the position doesn't 'take' SetCaretPosition(oldPos); SetFocusObject(oldFocus, false); + wxFALLTHROUGH; default: break; } EndBatchUndo(); @@ -2180,7 +2181,7 @@ bool wxRichTextCtrl::MoveRight(int noPositions, int flags) SetFocusObject(actualContainer, false /* don't set caret position yet */); bool caretLineStart = true; long caretPosition = FindCaretPositionForCharacterPosition(newPos, hitTest, actualContainer, caretLineStart); - + SelectNone(); SetCaretPosition(caretPosition, caretLineStart); @@ -2511,7 +2512,7 @@ bool wxRichTextCtrl::StartCellSelection(wxRichTextTable* table, wxRichTextParagr SetFocusObject(newCell, false /* don't set caret and clear selection */); MoveCaret(-1, false); SetDefaultStyleToCursorStyle(); - + return true; } @@ -3001,7 +3002,7 @@ void wxRichTextCtrl::SetupScrollbars(bool atTop, bool fromOnPaint) doSetScrollbars = false; } } - + m_lastWindowSize = windowSize; m_setupScrollbarsCount ++; if (m_setupScrollbarsCount > 32000) diff --git a/src/richtext/richtextsymboldlg.cpp b/src/richtext/richtextsymboldlg.cpp index 57512df37a..d500929d31 100644 --- a/src/richtext/richtextsymboldlg.cpp +++ b/src/richtext/richtextsymboldlg.cpp @@ -797,7 +797,7 @@ bool wxSymbolListCtrl::Create(wxWindow *parent, m_colBgSel = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); // flicker-free drawing requires this - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); SetFont(*wxNORMAL_FONT); diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index 4fd42772bb..ffb3db94bc 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -1861,8 +1861,7 @@ void Window::SetPositionRelative(PRectangle rc, Window relativeTo) { position.x = wxRound(position.x + rc.left); position.y = wxRound(position.y + rc.top); - const int currentDisplay = wxDisplay::GetFromWindow(relativeWin); - const wxRect displayRect = wxDisplay(currentDisplay).GetClientArea(); + const wxRect displayRect = wxDisplay(relativeWin).GetClientArea(); if (position.x < displayRect.GetLeft()) position.x = displayRect.GetLeft(); diff --git a/src/stc/ScintillaWX.cpp b/src/stc/ScintillaWX.cpp index dc65fcedf9..12f6c593b7 100644 --- a/src/stc/ScintillaWX.cpp +++ b/src/stc/ScintillaWX.cpp @@ -117,7 +117,7 @@ public: #endif m_ct(ct), m_swx(swx), m_cx(wxDefaultCoord), m_cy(wxDefaultCoord) { - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); SetName("wxSTCCallTip"); } diff --git a/src/tiff b/src/tiff index aa65abe076..c70cb3d7b4 160000 --- a/src/tiff +++ b/src/tiff @@ -1 +1 @@ -Subproject commit aa65abe0762209d40ec5d4343ec426a4d67caf2d +Subproject commit c70cb3d7b4c861083cdc0b6f245f3830c6e42566 diff --git a/src/univ/ctrlrend.cpp b/src/univ/ctrlrend.cpp index c8e828edfd..1ec57ad804 100644 --- a/src/univ/ctrlrend.cpp +++ b/src/univ/ctrlrend.cpp @@ -68,7 +68,7 @@ wxControlRenderer::wxControlRenderer(wxWindow *window, void wxControlRenderer::DrawLabel() { - m_dc.SetBackgroundMode(wxTRANSPARENT); + m_dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); m_dc.SetFont(m_window->GetFont()); m_dc.SetTextForeground(m_window->GetForegroundColour()); @@ -89,7 +89,7 @@ void wxControlRenderer::DrawLabel() void wxControlRenderer::DrawButtonLabel(const wxBitmap& bitmap, wxCoord marginX, wxCoord marginY) { - m_dc.SetBackgroundMode(wxTRANSPARENT); + m_dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); m_dc.SetFont(m_window->GetFont()); m_dc.SetTextForeground(m_window->GetForegroundColour()); diff --git a/src/univ/notebook.cpp b/src/univ/notebook.cpp index 143b8ec82c..b755a5b5a8 100644 --- a/src/univ/notebook.cpp +++ b/src/univ/notebook.cpp @@ -475,7 +475,7 @@ void wxNotebook::DoDrawTab(wxDC& dc, const wxRect& rect, size_t n) bmp.Create(w, h); wxMemoryDC dc; dc.SelectObject(bmp); - dc.SetBackground(wxBrush(GetBackgroundColour(), wxSOLID)); + dc.SetBackground(wxBrush(GetBackgroundColour(), wxBRUSHSTYLE_SOLID)); GetImageList()->Draw(image, dc, 0, 0, wxIMAGELIST_DRAW_NORMAL, true); dc.SelectObject(wxNullBitmap); #else diff --git a/src/univ/stdrend.cpp b/src/univ/stdrend.cpp index d434aac752..33db222a99 100644 --- a/src/univ/stdrend.cpp +++ b/src/univ/stdrend.cpp @@ -199,7 +199,7 @@ void wxStdRenderer::DrawButtonSurface(wxDC& dc, void wxStdRenderer::DrawFocusRect(wxWindow* WXUNUSED(win), wxDC& dc, const wxRect& rect, int WXUNUSED(flags)) { - // draw the pixels manually because the "dots" in wxPen with wxDOT style + // draw the pixels manually because the "dots" in wxPen with wxPENSTYLE_DOT style // may be short traits and not really dots // // note that to behave in the same manner as DrawRect(), we must exclude @@ -774,13 +774,13 @@ void wxStdRenderer::DrawTextLine(wxDC& dc, colBg = dc.GetTextBackground(); dc.SetTextForeground(wxSCHEME_COLOUR(m_scheme, HIGHLIGHT_TEXT)); dc.SetTextBackground(wxSCHEME_COLOUR(m_scheme, HIGHLIGHT)); - dc.SetBackgroundMode(wxSOLID); + dc.SetBackgroundMode(wxBRUSHSTYLE_SOLID); dc.DrawText(s, x, rect.y); dc.GetTextExtent(s, &width, NULL); x += width; - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); dc.SetTextBackground(colBg); dc.SetTextForeground(colFg); } diff --git a/src/univ/themes/mono.cpp b/src/univ/themes/mono.cpp index 0e826fa792..d69fb99941 100644 --- a/src/univ/themes/mono.cpp +++ b/src/univ/themes/mono.cpp @@ -1060,7 +1060,7 @@ void wxMonoRenderer::DrawScrollbarThumb(wxDC& dc, { DrawSolidRect(dc, wxMONO_BG_COL, rect); - // manually draw stipple pattern (wxDFB doesn't implement the wxSTIPPLE + // manually draw stipple pattern (wxDFB doesn't implement the wxBRUSHSTYLE_STIPPLE // brush style): dc.SetPen(m_penFg); for ( wxCoord y = rect.GetTop(); y <= rect.GetBottom(); y++ ) diff --git a/src/unix/fontutil.cpp b/src/unix/fontutil.cpp index 7c26e23ca0..b1ac5be86d 100644 --- a/src/unix/fontutil.cpp +++ b/src/unix/fontutil.cpp @@ -1317,11 +1317,11 @@ static wxNativeFont wxLoadQueryFont(float pointSize, logFont.lfCharSet = MWLF_CHARSET_DEFAULT; // TODO: select appropriate one logFont.lfOutPrecision = MWLF_TYPE_DEFAULT; logFont.lfClipPrecision = 0; // Not used - logFont.lfRoman = (family == wxROMAN ? 1 : 0) ; - logFont.lfSerif = (family == wxSWISS ? 0 : 1) ; + logFont.lfRoman = (family == wxFONTFAMILY_ROMAN ? 1 : 0) ; + logFont.lfSerif = (family == wxFONTFAMILY_SWISS ? 0 : 1) ; logFont.lfSansSerif = !logFont.lfSerif ; - logFont.lfModern = (family == wxMODERN ? 1 : 0) ; - logFont.lfProportional = (family == wxTELETYPE ? 0 : 1) ; + logFont.lfModern = (family == wxFONTFAMILY_MODERN ? 1 : 0) ; + logFont.lfProportional = (family == wxFONTFAMILY_TELETYPE ? 0 : 1) ; logFont.lfOblique = 0; logFont.lfSmallCaps = 0; logFont.lfPitch = 0; // 0 = default diff --git a/src/unix/joystick.cpp b/src/unix/joystick.cpp index 928e9f6fc9..0e51fd5ca6 100644 --- a/src/unix/joystick.cpp +++ b/src/unix/joystick.cpp @@ -181,12 +181,12 @@ void* wxJoystickThread::Entry() if (j_evt.value) { m_buttons |= (1 << j_evt.number); - SendEvent(wxEVT_JOY_BUTTON_DOWN, j_evt.time, j_evt.number); + SendEvent(wxEVT_JOY_BUTTON_DOWN, j_evt.time, 1 << j_evt.number); } else { m_buttons &= ~(1 << j_evt.number); - SendEvent(wxEVT_JOY_BUTTON_UP, j_evt.time, j_evt.number); + SendEvent(wxEVT_JOY_BUTTON_UP, j_evt.time, 1 << j_evt.number); } } } diff --git a/src/unix/mediactrl.cpp b/src/unix/mediactrl.cpp index 1e5bca9bdc..3c55b1ae33 100644 --- a/src/unix/mediactrl.cpp +++ b/src/unix/mediactrl.cpp @@ -1050,7 +1050,7 @@ bool wxGStreamerMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent, // don't erase the background of our control window // so that resizing is a bit smoother - m_ctrl->SetBackgroundStyle(wxBG_STYLE_CUSTOM); + m_ctrl->SetBackgroundStyle(wxBG_STYLE_PAINT); // Create our playbin object m_playbin = gst_element_factory_make ("playbin", "play"); diff --git a/src/unix/mediactrl_gstplayer.cpp b/src/unix/mediactrl_gstplayer.cpp index 235bdbc721..6566dd4010 100644 --- a/src/unix/mediactrl_gstplayer.cpp +++ b/src/unix/mediactrl_gstplayer.cpp @@ -309,7 +309,7 @@ bool wxGStreamerMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent, // don't erase the background of our control window // so that resizing is a bit smoother - m_ctrl->SetBackgroundStyle(wxBG_STYLE_CUSTOM); + m_ctrl->SetBackgroundStyle(wxBG_STYLE_PAINT); // Tell gstreamer to play in our window gpointer window_handle = NULL; diff --git a/src/x11/dc.cpp b/src/x11/dc.cpp index b278aa7ca8..888f15eb58 100644 --- a/src/x11/dc.cpp +++ b/src/x11/dc.cpp @@ -33,7 +33,7 @@ wxX11DCImpl::wxX11DCImpl( wxDC *owner ) : m_font = *wxNORMAL_FONT; m_brush = *wxWHITE_BRUSH; - m_backgroundMode = wxTRANSPARENT; + m_backgroundMode = wxBRUSHSTYLE_TRANSPARENT; } void wxX11DCImpl::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) diff --git a/src/x11/dcclient.cpp b/src/x11/dcclient.cpp index 92dd10d9d4..db1837fca9 100644 --- a/src/x11/dcclient.cpp +++ b/src/x11/dcclient.cpp @@ -1606,7 +1606,7 @@ void wxWindowDCImpl::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) // First draw a rectangle representing the text background, if a text // background is specified - if (m_textBackgroundColour.IsOk () && (m_backgroundMode != wxTRANSPARENT)) + if (m_textBackgroundColour.IsOk () && (m_backgroundMode != wxBRUSHSTYLE_TRANSPARENT)) { // Since X draws from the baseline of the text, must add the text height int cx = 0; @@ -1907,35 +1907,35 @@ void wxWindowDCImpl::SetPen( const wxPen &pen ) int lineStyle = LineSolid; switch (m_pen.GetStyle()) { - case wxUSER_DASH: + case wxPENSTYLE_USER_DASH: { lineStyle = LineOnOffDash; req_nb_dash = m_pen.GetDashCount(); req_dash = (wxX11Dash*)m_pen.GetDash(); break; } - case wxDOT: + case wxPENSTYLE_DOT: { lineStyle = LineOnOffDash; req_nb_dash = 2; req_dash = dotted; break; } - case wxLONG_DASH: + case wxPENSTYLE_LONG_DASH: { lineStyle = LineOnOffDash; req_nb_dash = 2; req_dash = long_dashed; break; } - case wxSHORT_DASH: + case wxPENSTYLE_SHORT_DASH: { lineStyle = LineOnOffDash; req_nb_dash = 2; req_dash = short_dashed; break; } - case wxDOT_DASH: + case wxPENSTYLE_DOT_DASH: { // lineStyle = LineDoubleDash; lineStyle = LineOnOffDash; @@ -1944,10 +1944,10 @@ void wxWindowDCImpl::SetPen( const wxPen &pen ) break; } - case wxTRANSPARENT: - case wxSTIPPLE_MASK_OPAQUE: - case wxSTIPPLE: - case wxSOLID: + case wxPENSTYLE_TRANSPARENT: + case wxPENSTYLE_STIPPLE_MASK_OPAQUE: + case wxPENSTYLE_STIPPLE: + case wxPENSTYLE_SOLID: default: { lineStyle = LineSolid; @@ -2033,7 +2033,7 @@ void wxWindowDCImpl::SetBrush( const wxBrush &brush ) if (m_brush.IsHatch()) { XSetFillStyle( (Display*) m_display, (GC) m_brushGC, FillStippled ); - int num = m_brush.GetStyle() - wxBDIAGONAL_HATCH; + int num = m_brush.GetStyle() - wxBRUSHSTYLE_BDIAGONAL_HATCH; XSetStipple( (Display*) m_display, (GC) m_brushGC, hatches[num] ); } } @@ -2078,7 +2078,7 @@ void wxWindowDCImpl::SetBackground( const wxBrush &brush ) if (m_backgroundBrush.IsHatch()) { XSetFillStyle( (Display*) m_display, (GC) m_bgGC, FillStippled ); - int num = m_backgroundBrush.GetStyle() - wxBDIAGONAL_HATCH; + int num = m_backgroundBrush.GetStyle() - wxBRUSHSTYLE_BDIAGONAL_HATCH; XSetStipple( (Display*) m_display, (GC) m_bgGC, hatches[num] ); } } @@ -2203,7 +2203,7 @@ void wxWindowDCImpl::SetBackgroundMode( int mode ) m_backgroundMode = mode; #if wxUSE_NANOX - GrSetGCUseBackground((GC) m_textGC, mode == wxTRANSPARENT ? FALSE : TRUE); + GrSetGCUseBackground((GC) m_textGC, mode == wxBRUSHSTYLE_TRANSPARENT ? FALSE : TRUE); #endif if (!m_x11window) return; @@ -2214,7 +2214,7 @@ void wxWindowDCImpl::SetBackgroundMode( int mode ) if (m_brush.GetStyle() != wxBRUSHSTYLE_SOLID && m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT) { XSetFillStyle( (Display*) m_display, (GC) m_brushGC, - (m_backgroundMode == wxTRANSPARENT) ? FillStippled : FillOpaqueStippled ); + (m_backgroundMode == wxBRUSHSTYLE_TRANSPARENT) ? FillStippled : FillOpaqueStippled ); } } diff --git a/src/x11/font.cpp b/src/x11/font.cpp index 2662d271b7..8c229a6d3c 100644 --- a/src/x11/font.cpp +++ b/src/x11/font.cpp @@ -316,7 +316,7 @@ void wxFontRefData::InitFromNative() m_pointSize = wxDEFAULT_FONT_SIZE; } - // examine the spacing: if the font is monospaced, assume wxTELETYPE + // examine the spacing: if the font is monospaced, assume wxFONTFAMILY_TELETYPE // family for compatibility with the old code which used it instead of // IsFixedWidth() if ( m_nativeFontInfo.GetXFontComponent(wxXLFD_SPACING).Upper() == wxT('M') ) diff --git a/src/x11/textctrl.cpp b/src/x11/textctrl.cpp index dea9579417..4c1473baa6 100644 --- a/src/x11/textctrl.cpp +++ b/src/x11/textctrl.cpp @@ -229,7 +229,7 @@ bool wxTextCtrl::Create( wxWindow *parent, m_editable = ((m_windowStyle & wxTE_READONLY) == 0); if (HasFlag(wxTE_PASSWORD)) - m_sourceFont = wxFont( 12, wxMODERN, wxNORMAL, wxNORMAL ); + m_sourceFont = wxFont( 12, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL ); else m_sourceFont = GetFont(); @@ -1711,7 +1711,7 @@ void wxTextCtrl::OnPaint( wxPaintEvent &event ) GetClientSize( &size_x, &size_y ); dc.SetPen( *wxTRANSPARENT_PEN ); - dc.SetBrush( wxBrush( wxTHEME_COLOUR(HIGHLIGHT), wxSOLID ) ); + dc.SetBrush( wxBrush( wxTHEME_COLOUR(HIGHLIGHT), wxBRUSHSTYLE_SOLID ) ); int upper = wxMin( (int)m_lines.GetCount(), scroll_y+(size_y/m_lineHeight)+2 ); for (int i = scroll_y; i < upper; i++) { diff --git a/tests/asserthelper.cpp b/tests/asserthelper.cpp index 8f9f36d452..7b25cec2d6 100644 --- a/tests/asserthelper.cpp +++ b/tests/asserthelper.cpp @@ -67,3 +67,11 @@ std::ostream& operator<<(std::ostream& os, const wxPoint& p) return os; } + +std::ostream& operator<<(std::ostream& os, const wxRect& r) +{ + os << "{" + << r.x << ", " << r.y << " " << r.width << "*" << r.height + << "}"; + return os; +} diff --git a/tests/asserthelper.h b/tests/asserthelper.h index ce8c9c6a29..57772453bb 100644 --- a/tests/asserthelper.h +++ b/tests/asserthelper.h @@ -29,16 +29,12 @@ namespace wxTestPrivate std::ostream& operator<<(std::ostream& os, const ColourChannel& cc); } // wxTestPrivate namespace -// this operator is needed to use CPPUNIT_ASSERT_EQUAL with wxColour objects +// Operators used to show the values of the corresponding types when comparing +// them in the unit tests fails. std::ostream& operator<<(std::ostream& os, const wxColour& c); - -// this operator is needed to use CPPUNIT_ASSERT_EQUAL with wxSize objects std::ostream& operator<<(std::ostream& os, const wxSize& s); - -// this operator is needed to use CPPUNIT_ASSERT_EQUAL with wxFont objects std::ostream& operator<<(std::ostream& os, const wxFont& f); - -// this operator is needed to use CPPUNIT_ASSERT_EQUAL with wxPoint objects std::ostream& operator<<(std::ostream& os, const wxPoint& p); +std::ostream& operator<<(std::ostream& os, const wxRect& r); #endif diff --git a/tests/controls/dataviewctrltest.cpp b/tests/controls/dataviewctrltest.cpp index 45c10cf253..83e712a8f3 100644 --- a/tests/controls/dataviewctrltest.cpp +++ b/tests/controls/dataviewctrltest.cpp @@ -22,35 +22,19 @@ #include "wx/dataview.h" #include "testableframe.h" +#include "asserthelper.h" // ---------------------------------------------------------------------------- // test class // ---------------------------------------------------------------------------- -class DataViewCtrlTestCase : public CppUnit::TestCase +class DataViewCtrlTestCase { public: - DataViewCtrlTestCase() { } - - virtual void setUp() wxOVERRIDE; - virtual void tearDown() wxOVERRIDE; - -private: - CPPUNIT_TEST_SUITE( DataViewCtrlTestCase ); - CPPUNIT_TEST( DeleteSelected ); - CPPUNIT_TEST( DeleteNotSelected ); - CPPUNIT_TEST( GetSelectionForMulti ); - CPPUNIT_TEST( GetSelectionForSingle ); - CPPUNIT_TEST_SUITE_END(); - - // Create wxDataViewTreeCtrl with the given style. - void Create(long style); - - void DeleteSelected(); - void DeleteNotSelected(); - void GetSelectionForMulti(); - void GetSelectionForSingle(); + explicit DataViewCtrlTestCase(long style); + ~DataViewCtrlTestCase(); +protected: void TestSelectionFor0and1(); // the dataview control itself @@ -65,17 +49,29 @@ private: wxDECLARE_NO_COPY_CLASS(DataViewCtrlTestCase); }; -// register in the unnamed registry so that these tests are run by default -CPPUNIT_TEST_SUITE_REGISTRATION( DataViewCtrlTestCase ); +class SingleSelectDataViewCtrlTestCase : public DataViewCtrlTestCase +{ +public: + SingleSelectDataViewCtrlTestCase() + : DataViewCtrlTestCase(wxDV_SINGLE) + { + } +}; -// also include in its own registry so that these tests can be run alone -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( DataViewCtrlTestCase, "DataViewCtrlTestCase" ); +class MultiSelectDataViewCtrlTestCase : public DataViewCtrlTestCase +{ +public: + MultiSelectDataViewCtrlTestCase() + : DataViewCtrlTestCase(wxDV_MULTIPLE) + { + } +}; // ---------------------------------------------------------------------------- // test initialization // ---------------------------------------------------------------------------- -void DataViewCtrlTestCase::Create(long style) +DataViewCtrlTestCase::DataViewCtrlTestCase(long style) { m_dvc = new wxDataViewTreeCtrl(wxTheApp->GetTopWindow(), wxID_ANY, @@ -88,33 +84,24 @@ void DataViewCtrlTestCase::Create(long style) m_grandchild = m_dvc->AppendItem(m_child1, "grandchild"); m_child2 = m_dvc->AppendItem(m_root, "child2"); - m_dvc->SetSize(400, 200); - m_dvc->ExpandAncestors(m_root); + m_dvc->Layout(); + m_dvc->Expand(m_root); m_dvc->Refresh(); m_dvc->Update(); } -void DataViewCtrlTestCase::setUp() -{ - Create(wxDV_MULTIPLE); -} - -void DataViewCtrlTestCase::tearDown() +DataViewCtrlTestCase::~DataViewCtrlTestCase() { delete m_dvc; - m_dvc = NULL; - - m_root = - m_child1 = - m_child2 = - m_grandchild = wxDataViewItem(); } // ---------------------------------------------------------------------------- // the tests themselves // ---------------------------------------------------------------------------- -void DataViewCtrlTestCase::DeleteSelected() +TEST_CASE_METHOD(MultiSelectDataViewCtrlTestCase, + "wxDVC::DeleteSelected", + "[wxDataViewCtrl][delete]") { wxDataViewItemArray sel; sel.push_back(m_child1); @@ -128,14 +115,18 @@ void DataViewCtrlTestCase::DeleteSelected() m_dvc->GetSelections(sel); // m_child1 and its children should be removed from the selection now - CPPUNIT_ASSERT_EQUAL( 1, sel.size() ); - CPPUNIT_ASSERT( sel[0] == m_child2 ); + REQUIRE( sel.size() == 1 ); + CHECK( sel[0] == m_child2 ); } -void DataViewCtrlTestCase::DeleteNotSelected() +TEST_CASE_METHOD(MultiSelectDataViewCtrlTestCase, + "wxDVC::DeleteNotSelected", + "[wxDataViewCtrl][delete]") { // TODO not working on OS X as expected -#ifndef __WXOSX__ +#ifdef __WXOSX__ + WARN("Disabled under MacOS because this test currently fails"); +#else wxDataViewItemArray sel; sel.push_back(m_child1); sel.push_back(m_grandchild); @@ -147,9 +138,9 @@ void DataViewCtrlTestCase::DeleteNotSelected() m_dvc->GetSelections(sel); // m_child1 and its children should be unaffected - CPPUNIT_ASSERT_EQUAL( 2, sel.size() ); - CPPUNIT_ASSERT( sel[0] == m_child1 ); - CPPUNIT_ASSERT( sel[1] == m_grandchild ); + REQUIRE( sel.size() == 2 ); + CHECK( sel[0] == m_child1 ); + CHECK( sel[1] == m_grandchild ); #endif } @@ -158,44 +149,117 @@ void DataViewCtrlTestCase::TestSelectionFor0and1() wxDataViewItemArray selections; // Initially there is no selection. - CPPUNIT_ASSERT_EQUAL( 0, m_dvc->GetSelectedItemsCount() ); - CPPUNIT_ASSERT( !m_dvc->HasSelection() ); - CPPUNIT_ASSERT( !m_dvc->GetSelection().IsOk() ); + CHECK( m_dvc->GetSelectedItemsCount() == 0 ); + CHECK( !m_dvc->HasSelection() ); + CHECK( !m_dvc->GetSelection().IsOk() ); - CPPUNIT_ASSERT( !m_dvc->GetSelections(selections) ); - CPPUNIT_ASSERT( selections.empty() ); + CHECK( !m_dvc->GetSelections(selections) ); + CHECK( selections.empty() ); // Select one item. m_dvc->Select(m_child1); - CPPUNIT_ASSERT_EQUAL( 1, m_dvc->GetSelectedItemsCount() ); - CPPUNIT_ASSERT( m_dvc->HasSelection() ); - CPPUNIT_ASSERT( m_dvc->GetSelection().IsOk() ); - CPPUNIT_ASSERT_EQUAL( 1, m_dvc->GetSelections(selections) ); - CPPUNIT_ASSERT( selections[0] == m_child1 ); + CHECK( m_dvc->GetSelectedItemsCount() == 1 ); + CHECK( m_dvc->HasSelection() ); + CHECK( m_dvc->GetSelection().IsOk() ); + REQUIRE( m_dvc->GetSelections(selections) == 1 ); + CHECK( selections[0] == m_child1 ); } -void DataViewCtrlTestCase::GetSelectionForMulti() +TEST_CASE_METHOD(MultiSelectDataViewCtrlTestCase, + "wxDVC::GetSelectionForMulti", + "[wxDataViewCtrl][select]") { wxDataViewItemArray selections; TestSelectionFor0and1(); - // Also test with more than one selected item. m_dvc->Select(m_child2); - CPPUNIT_ASSERT_EQUAL( 2, m_dvc->GetSelectedItemsCount() ); - CPPUNIT_ASSERT( m_dvc->HasSelection() ); - CPPUNIT_ASSERT( !m_dvc->GetSelection().IsOk() ); - CPPUNIT_ASSERT_EQUAL( 2, m_dvc->GetSelections(selections) ); - CPPUNIT_ASSERT( selections[1] == m_child2 ); + CHECK( m_dvc->GetSelectedItemsCount() == 2 ); + CHECK( m_dvc->HasSelection() ); + CHECK( !m_dvc->GetSelection().IsOk() ); + REQUIRE( m_dvc->GetSelections(selections) == 2 ); + CHECK( selections[1] == m_child2 ); } -void DataViewCtrlTestCase::GetSelectionForSingle() +TEST_CASE_METHOD(SingleSelectDataViewCtrlTestCase, + "wxDVC::SingleSelection", + "[wxDataViewCtrl][selection]") { - delete m_dvc; - Create(0); - TestSelectionFor0and1(); } +TEST_CASE_METHOD(SingleSelectDataViewCtrlTestCase, + "wxDVC::IsExpanded", + "[wxDataViewCtrl][expand]") +{ + CHECK( m_dvc->IsExpanded(m_root) ); + CHECK( !m_dvc->IsExpanded(m_child1) ); + // No idea why, but the native NSOutlineView isItemExpanded: method returns + // true for this item for some reason. +#ifdef __WXOSX__ + WARN("Disabled under MacOS: IsExpanded() returns true for grand child"); +#else + CHECK( !m_dvc->IsExpanded(m_grandchild) ); +#endif + CHECK( !m_dvc->IsExpanded(m_child2) ); +} + +TEST_CASE_METHOD(SingleSelectDataViewCtrlTestCase, + "wxDVC::GetItemRect", + "[wxDataViewCtrl][item]") +{ +#ifdef __WXGTK__ + // We need to let the native control have some events to lay itself out. + wxYield(); +#endif // __WXGTK__ + + const wxRect rect1 = m_dvc->GetItemRect(m_child1); + const wxRect rect2 = m_dvc->GetItemRect(m_child2); + + CHECK( rect1 != wxRect() ); + CHECK( rect2 != wxRect() ); + + CHECK( rect1.x == rect2.x ); + CHECK( rect1.width == rect2.width ); + CHECK( rect1.height == rect2.height ); + + { + INFO("First child: " << rect1 << ", second one: " << rect2); + CHECK( rect1.y < rect2.y ); + } + + const wxRect rectNotShown = m_dvc->GetItemRect(m_grandchild); + CHECK( rectNotShown == wxRect() ); + + // Append enough items to make the window scrollable. + for ( int i = 3; i < 100; ++i ) + m_dvc->AppendItem(m_root, wxString::Format("child%d", i)); + + const wxDataViewItem last = m_dvc->AppendItem(m_root, "last"); + + // This should scroll the window to bring this item into view. + m_dvc->EnsureVisible(last); + +#ifdef __WXGTK__ + // And again to let it scroll the correct items into view. + wxYield(); +#endif + + // Check that this was indeed the case. + const wxDataViewItem top = m_dvc->GetTopItem(); + CHECK( top != m_root ); + + // Verify that the coordinates are returned in physical coordinates of the + // window and not the logical coordinates affected by scrolling. + const wxRect rectScrolled = m_dvc->GetItemRect(top); + CHECK( rectScrolled.GetBottom() > 0 ); + CHECK( rectScrolled.GetTop() <= m_dvc->GetClientSize().y ); + + // Also check that the root item is not currently visible (because it's + // scrolled off). + const wxRect rectRoot = m_dvc->GetItemRect(m_root); + CHECK( rectRoot == wxRect() ); +} + #endif //wxUSE_DATAVIEWCTRL diff --git a/tests/filename/filenametest.cpp b/tests/filename/filenametest.cpp index bba94b23cd..240e95205c 100644 --- a/tests/filename/filenametest.cpp +++ b/tests/filename/filenametest.cpp @@ -27,7 +27,7 @@ #ifdef __WINDOWS__ #include "wx/msw/registry.h" - #include + #include "wx/msw/wrapshl.h" #include "wx/msw/ole/oleutils.h" #include "wx/msw/private/comptr.h" #endif // __WINDOWS__ diff --git a/tests/geometry/rect.cpp b/tests/geometry/rect.cpp index 07634a3ce6..94e67c9574 100644 --- a/tests/geometry/rect.cpp +++ b/tests/geometry/rect.cpp @@ -22,18 +22,7 @@ #include "wx/iosfwrap.h" -// ---------------------------------------------------------------------------- -// helper functions -// ---------------------------------------------------------------------------- - -// this operator is needed to use CPPUNIT_ASSERT_EQUAL with wxRects -std::ostream& operator<<(std::ostream& os, const wxRect& r) -{ - os << "{" - << r.x << ", " << r.y << ", " << r.width << ", " << r.height - << "}"; - return os; -} +#include "asserthelper.h" // ---------------------------------------------------------------------------- // test class diff --git a/tests/graphics/affinematrix.cpp b/tests/graphics/affinematrix.cpp index 130c95424b..f2fbdbef67 100644 --- a/tests/graphics/affinematrix.cpp +++ b/tests/graphics/affinematrix.cpp @@ -311,7 +311,7 @@ public: m_gcdc->SetGraphicsContext(ctx); } - virtual void FlushDC() + virtual void FlushDC() wxOVERRIDE { // Apparently, flushing native Direct2D renderer // is not enough to update underlying DC (bitmap) diff --git a/tests/graphics/clippingbox.cpp b/tests/graphics/clippingbox.cpp index 87f56119e9..65ab7ab379 100644 --- a/tests/graphics/clippingbox.cpp +++ b/tests/graphics/clippingbox.cpp @@ -414,7 +414,7 @@ public: virtual ~ClippingBoxTestCaseGCDCDirect2D() {} - virtual void FlushDC() + virtual void FlushDC() wxOVERRIDE { // Apparently, flushing native Direct2D renderer // is not enough to update underlying DC (bitmap) @@ -1616,7 +1616,7 @@ public: virtual ~ClippingBoxTestCaseGCDirect2D() {} - virtual void FlushGC() + virtual void FlushGC() wxOVERRIDE { // Apparently, flushing native Direct2D renderer // is not enough to update underlying DC (bitmap) diff --git a/tests/menu/menu.cpp b/tests/menu/menu.cpp index dbda30cb74..6e6cd6f36b 100644 --- a/tests/menu/menu.cpp +++ b/tests/menu/menu.cpp @@ -406,10 +406,18 @@ void MenuTestCase::RadioItems() // First item of a radio group is checked by default. CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First) ); + // Subsequent items in a group are not checked. + CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 1) ); + +#ifdef __WXQT__ + WARN("Radio check test does not work under Qt"); +#else // Checking the second one make the first one unchecked however. menu->Check(MenuTestCase_First + 1, true); CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First) ); CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 1) ); + menu->Check(MenuTestCase_First, true); +#endif // Adding more radio items after a separator creates another radio group... menu->AppendSeparator(); @@ -418,25 +426,43 @@ void MenuTestCase::RadioItems() menu->AppendRadioItem(MenuTestCase_First + 4, "Radio 4"); // ... which is independent from the first one. + CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First) ); CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 2) ); +#ifdef __WXQT__ + WARN("Radio check test does not work under Qt"); +#else menu->Check(MenuTestCase_First + 3, true); CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 3) ); CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 2) ); - CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 1) ); + CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First) ); + menu->Check(MenuTestCase_First + 2, true); +#endif // Insert an item in the middle of an existing radio group. menu->InsertRadioItem(4, MenuTestCase_First + 5, "Radio 5"); - CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 3) ); + CPPUNIT_ASSERT( menu->IsChecked(MenuTestCase_First + 2) ); + CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 5) ); +#ifdef __WXQT__ + WARN("Radio check test does not work under Qt"); +#else menu->Check( MenuTestCase_First + 5, true ); CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 3) ); + menu->Check( MenuTestCase_First + 3, true ); +#endif // Prepend a couple of items before the first group. menu->PrependRadioItem(MenuTestCase_First + 6, "Radio 6"); menu->PrependRadioItem(MenuTestCase_First + 7, "Radio 7"); + CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 6) ); + CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 7) ); + +#ifdef __WXQT__ + WARN("Radio check test does not work under Qt"); +#else menu->Check(MenuTestCase_First + 7, true); CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 1) ); @@ -444,6 +470,7 @@ void MenuTestCase::RadioItems() // Check that the last radio group still works as expected. menu->Check(MenuTestCase_First + 4, true); CPPUNIT_ASSERT( !menu->IsChecked(MenuTestCase_First + 5) ); +#endif } void MenuTestCase::RemoveAdd() diff --git a/tests/misc/misctests.cpp b/tests/misc/misctests.cpp index b6dd757513..c6f1a0f64b 100644 --- a/tests/misc/misctests.cpp +++ b/tests/misc/misctests.cpp @@ -19,6 +19,8 @@ #include "wx/defs.h" +#include "wx/math.h" + // just some classes using wxRTTI for wxStaticCast() test #include "wx/tarstrm.h" #include "wx/zipstrm.h" @@ -150,3 +152,12 @@ void MiscTestCase::StaticCast() #endif // wxUSE_TARSTREAM } +TEST_CASE("wxCTZ", "[math]") +{ + CHECK( wxCTZ(1) == 0 ); + CHECK( wxCTZ(4) == 2 ); + CHECK( wxCTZ(17) == 0 ); + CHECK( wxCTZ(0x80000000) == 31 ); + + WX_ASSERT_FAILS_WITH_ASSERT( wxCTZ(0) ); +} diff --git a/tests/misc/safearrayconverttest.cpp b/tests/misc/safearrayconverttest.cpp index 495245a805..96d49b1ab9 100644 --- a/tests/misc/safearrayconverttest.cpp +++ b/tests/misc/safearrayconverttest.cpp @@ -126,7 +126,7 @@ void SafeArrayConvertTestCase::VariantListReturnSafeArray() wxVariantDataSafeArray* vsa = wxStaticCastVariantData(variantCopy.GetData(), wxVariantDataSafeArray); - long bound; + long bound wxDUMMY_INITIALIZE(0); CPPUNIT_ASSERT( vsa ); CPPUNIT_ASSERT( safeArray.Attach(vsa->GetValue()) ); @@ -177,7 +177,7 @@ void SafeArrayConvertTestCase::StringsReturnSafeArray() wxVariantDataSafeArray* vsa = wxStaticCastVariantData(variant.GetData(), wxVariantDataSafeArray); - long bound; + long bound wxDUMMY_INITIALIZE(0); CPPUNIT_ASSERT( vsa ); CPPUNIT_ASSERT( safeArray.Attach(vsa->GetValue()) ); diff --git a/tests/regex/regextest.cpp b/tests/regex/regextest.cpp index 2c26019dc5..cc9449e9b7 100644 --- a/tests/regex/regextest.cpp +++ b/tests/regex/regextest.cpp @@ -204,7 +204,7 @@ void RegExTestCase::parseFlags(const wxString& flags) case 'i': m_compileFlags |= wxRE_ICASE; break; case 'o': m_compileFlags |= wxRE_NOSUB; break; case 'n': m_compileFlags |= wxRE_NEWLINE; break; - case 't': if (strchr("ep", m_mode)) break; // else fall through... + case 't': if (strchr("ep", m_mode)) break; wxFALLTHROUGH; // anything else we must skip the test default: diff --git a/wxwidgets.props b/wxwidgets.props new file mode 100644 index 0000000000..074d6b8a30 --- /dev/null +++ b/wxwidgets.props @@ -0,0 +1,30 @@ + + + + + + + + + WXUSINGDLL + + + + __WXMSW__;$(wxUsingDllDefine);%(PreprocessorDefinitions) + $(MSBuildThisFileDirectory)include\msvc;$(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories) + + + __WXMSW__;$(wxUsingDllDefine);%(PreprocessorDefinitions) + $(MSBuildThisFileDirectory)lib\$(wxOutDirName)\$(wxToolkitPrefix)$(wxSuffix);$(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories) + + + $(MSBuildThisFileDirectory)lib\$(wxOutDirName);%(AdditionalLibraryDirectories) + + +