From db49de9668e9ba0bc5cfec01a951de168ec58bca Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Thu, 17 May 2018 19:30:59 +0200 Subject: [PATCH 1/8] CMake: correctly detect 64bit for MinGW compilers CMAKE_CL_64 is only defined when using the 64 bit cl compiler from Microsoft. --- build/cmake/init.cmake | 2 +- build/cmake/main.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/cmake/init.cmake b/build/cmake/init.cmake index 06256b1b1d..b22da71efb 100644 --- a/build/cmake/init.cmake +++ b/build/cmake/init.cmake @@ -59,7 +59,7 @@ if(WIN32) message(FATAL_ERROR "Unknown WIN32 compiler type") endif() - if(CMAKE_CL_64) + if(CMAKE_SIZEOF_VOID_P EQUAL 8) set(wxARCH_SUFFIX "_x64") endif() else() diff --git a/build/cmake/main.cmake b/build/cmake/main.cmake index 79b633185f..ca761d8464 100644 --- a/build/cmake/main.cmake +++ b/build/cmake/main.cmake @@ -53,7 +53,7 @@ if(MSVC OR MINGW OR CYGWIN) else() set(wxREQUIRED_OS_DESC "Windows Vista / Windows Server 2008") endif() - if(CMAKE_CL_64) + if(CMAKE_SIZEOF_VOID_P EQUAL 8) wx_string_append(wxREQUIRED_OS_DESC " (x64 Edition)") endif() elseif(APPLE AND NOT IPHONE) From df6b47bc6d08b4e5cbe5c2def4eeca544d8f1432 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Thu, 17 May 2018 19:33:19 +0200 Subject: [PATCH 2/8] CMake: Correct header for debug builds in MinGW compiler --- build/cmake/init.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/cmake/init.cmake b/build/cmake/init.cmake index b22da71efb..fac86758b6 100644 --- a/build/cmake/init.cmake +++ b/build/cmake/init.cmake @@ -109,7 +109,7 @@ else() endif() set(wxSETUP_HEADER_FILE ${wxSETUP_HEADER_PATH}/wx/setup.h) -if(NOT wxBUILD_CUSTOM_SETUP_HEADER_PATH AND MSVC) +if(DEFINED wxSETUP_HEADER_FILE_DEBUG) # Append configuration specific suffix to setup header path wx_string_append(wxSETUP_HEADER_PATH "$<$:d>") endif() From de4e20ee93c0ca36e94fbe9749fcbad25b247498 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Thu, 17 May 2018 19:34:34 +0200 Subject: [PATCH 3/8] CMake: copy missing files for widgets sample --- build/cmake/samples/CMakeLists.txt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/build/cmake/samples/CMakeLists.txt b/build/cmake/samples/CMakeLists.txt index 5916b03935..39f4df2ca3 100644 --- a/build/cmake/samples/CMakeLists.txt +++ b/build/cmake/samples/CMakeLists.txt @@ -189,7 +189,20 @@ if(APPLE) # elsewhere we just compile native.cpp directly. list(APPEND SAMPLE_WIDGETS_SRC native_wrapper.mm) endif() -wx_add_sample(widgets IMPORTANT ${SAMPLE_WIDGETS_SRC} LIBRARIES adv) +wx_list_add_prefix(WIDGETS_RC_FILES icons/ + activityindicator.xpm bmpbtn.xpm bmpcombobox.xpm button.xpm + checkbox.xpm choice.xpm choicebk.xpm clrpicker.xpm + combobox.xpm datepick.xpm dirctrl.xpm dirpicker.xpm + filepicker.xpm fontpicker.xpm gauge.xpm header.xpm + hyperlnk.xpm listbook.xpm listbox.xpm native.xpm + notebook.xpm odcombobox.xpm radiobox.xpm scrolbar.xpm + slider.xpm spinbtn.xpm statbmp.xpm statbox.xpm + stattext.xpm text.xpm timepick.xpm toggle.xpm + ) +wx_add_sample(widgets IMPORTANT ${SAMPLE_WIDGETS_SRC} + DATA ${WIDGETS_RC_FILES} textctrl.cpp + LIBRARIES adv + ) wx_add_sample(wizard LIBRARIES adv DEPENDS wxUSE_WIZARDDLG) wx_add_sample(wrapsizer) From e581b729559003bc4c050e8370699d0f42341d05 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Thu, 17 May 2018 19:42:43 +0200 Subject: [PATCH 4/8] Look in multiple paths when searching for resource files of samples When using an out of source build, the files are not in the default wxWidgets directories. Also search in the current directory, parent directory and sample sub-directories. Closes https://trac.wxwidgets.org/ticket/18118 --- samples/drawing/drawing.cpp | 3 ++- samples/html/help/help.cpp | 10 ++++++++-- samples/webview/webview.cpp | 12 +++++++++--- samples/widgets/statbmp.cpp | 8 +++++++- samples/widgets/textctrl.cpp | 1 + 5 files changed, 27 insertions(+), 7 deletions(-) diff --git a/samples/drawing/drawing.cpp b/samples/drawing/drawing.cpp index a4c6a40a00..563a8b13a1 100644 --- a/samples/drawing/drawing.cpp +++ b/samples/drawing/drawing.cpp @@ -413,7 +413,8 @@ bool MyApp::LoadImages() pathList.Add(wxFileName(argv[0]).GetPath()); pathList.Add(wxT(".")); pathList.Add(wxT("..")); - pathList.Add(wxT("../..")); + pathList.Add(wxT("../drawing")); + pathList.Add(wxT("../../../samples/drawing")); wxString path = pathList.FindValidPath(wxT("pat4.bmp")); if ( !path ) diff --git a/samples/html/help/help.cpp b/samples/html/help/help.cpp index a3746f333a..3833ed2255 100644 --- a/samples/html/help/help.cpp +++ b/samples/html/help/help.cpp @@ -163,10 +163,16 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) help.UseConfig(wxConfig::Get()); bool ret; help.SetTempDir(wxT(".")); - ret = help.AddBook(wxFileName(wxT("helpfiles/testing.hhp"), wxPATH_UNIX)); + + wxPathList pathlist; + pathlist.Add(wxT("./helpfiles")); + pathlist.Add(wxT("../helpfiles")); + pathlist.Add(wxT("../../html/help/helpfiles")); + + ret = help.AddBook(wxFileName(pathlist.FindValidPath(wxT("testing.hhp")), wxPATH_UNIX)); if (! ret) wxMessageBox(wxT("Failed adding book helpfiles/testing.hhp")); - ret = help.AddBook(wxFileName(wxT("helpfiles/another.hhp"), wxPATH_UNIX)); + ret = help.AddBook(wxFileName(pathlist.FindValidPath(wxT("another.hhp")), wxPATH_UNIX)); if (! ret) wxMessageBox(_("Failed adding book helpfiles/another.hhp")); } diff --git a/samples/webview/webview.cpp b/samples/webview/webview.cpp index 362f2bc60b..856169e195 100644 --- a/samples/webview/webview.cpp +++ b/samples/webview/webview.cpp @@ -263,7 +263,7 @@ bool WebApp::OnInit() // Create the memory files wxImage::AddHandler(new wxPNGHandler); - wxMemoryFSHandler::AddFile("logo.png", + wxMemoryFSHandler::AddFile("logo.png", wxBitmap(wxlogo_xpm), wxBITMAP_TYPE_PNG); wxMemoryFSHandler::AddFile("page1.htm", "File System Example" @@ -741,7 +741,13 @@ void WebFrame::OnMode(wxCommandEvent& WXUNUSED(evt)) void WebFrame::OnLoadScheme(wxCommandEvent& WXUNUSED(evt)) { - wxFileName helpfile("../help/doc.zip"); + wxPathList pathlist; + pathlist.Add(wxT(".")); + pathlist.Add(wxT("..")); + pathlist.Add(wxT("../help")); + pathlist.Add(wxT("../../../samples/help")); + + wxFileName helpfile(pathlist.FindValidPath(wxT("doc.zip"))); helpfile.MakeAbsolute(); wxString path = helpfile.GetFullPath(); //Under MSW we need to flip the slashes @@ -1207,7 +1213,7 @@ void WebFrame::OnSelectAll(wxCommandEvent& WXUNUSED(evt)) * Callback invoked when a loading error occurs */ void WebFrame::OnError(wxWebViewEvent& evt) -{ +{ #define WX_ERROR_CASE(type) \ case type: \ category = #type; \ diff --git a/samples/widgets/statbmp.cpp b/samples/widgets/statbmp.cpp index ad100b0df8..08a69c6952 100644 --- a/samples/widgets/statbmp.cpp +++ b/samples/widgets/statbmp.cpp @@ -90,7 +90,13 @@ void StatBmpWidgetsPage::CreateContent() wxString testImage; #if wxUSE_LIBPNG - wxFileName fn("../image/toucan.png"); + wxPathList pathlist; + pathlist.Add(wxT(".")); + pathlist.Add(wxT("..")); + pathlist.Add(wxT("../image")); + pathlist.Add(wxT("../../../samples/image")); + + wxFileName fn(pathlist.FindValidPath(wxT("toucan.png"))); if ( fn.FileExists() ) testImage = fn.GetFullPath(); #endif // wxUSE_LIBPNG diff --git a/samples/widgets/textctrl.cpp b/samples/widgets/textctrl.cpp index d6e2d54f28..c89ba6ca93 100644 --- a/samples/widgets/textctrl.cpp +++ b/samples/widgets/textctrl.cpp @@ -913,6 +913,7 @@ void TextWidgetsPage::OnButtonLoad(wxCommandEvent& WXUNUSED(event)) wxPathList pathlist; pathlist.Add(wxT(".")); pathlist.Add(wxT("..")); + pathlist.Add(wxT("../widgets")); pathlist.Add(wxT("../../../samples/widgets")); wxString filename = pathlist.FindValidPath(wxT("textctrl.cpp")); From 5758832a6ee1f1b4ef6998f270bda7e19155f48c Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Thu, 17 May 2018 19:44:38 +0200 Subject: [PATCH 5/8] Fix invalid image size in wxBitmapComboBox widgets sample When the wxBitmapComboBox is empty, GetBitmapSize() returns size -1,-1. Images can not be scaled to this invalid size. Use the size of the imagelist instead. --- samples/widgets/bmpcombobox.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/samples/widgets/bmpcombobox.cpp b/samples/widgets/bmpcombobox.cpp index 8c00519826..f73feb8978 100644 --- a/samples/widgets/bmpcombobox.cpp +++ b/samples/widgets/bmpcombobox.cpp @@ -694,6 +694,8 @@ void BitmapComboBoxWidgetsPage::LoadWidgetImages( wxArrayString* strings, wxImag // Get size of existing images in list wxSize foundSize = m_combobox->GetBitmapSize(); + if ( !foundSize.IsFullySpecified() ) + foundSize = images->GetSize(); for ( i=0; isize(); i++ ) { From c97963fce0152bab0c145ec85d5cf77b4f3cafc3 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Thu, 17 May 2018 19:49:30 +0200 Subject: [PATCH 6/8] Fix size glitch of WidgetsBookCtrl in widgets sample The entire control is hidden until the dialog is resized. This seems to be caused by (recent changes in) the wxPersistentManager. This is fixed by populating the frame before restoring persistence. (as is described in docs/doxygen/overviews/persistence.h.) --- samples/widgets/widgets.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/widgets/widgets.cpp b/samples/widgets/widgets.cpp index 2b5dfe9082..cb42f7d16e 100644 --- a/samples/widgets/widgets.cpp +++ b/samples/widgets/widgets.cpp @@ -381,8 +381,6 @@ bool WidgetsApp::OnInit() WidgetsFrame::WidgetsFrame(const wxString& title) : wxFrame(NULL, wxID_ANY, title) { - const bool sizeSet = wxPersistentRegisterAndRestore(this, "Main"); - // set the frame icon SetIcon(wxICON(sample)); @@ -514,6 +512,8 @@ WidgetsFrame::WidgetsFrame(const wxString& title) m_panel->SetSizer(sizerTop); + const bool sizeSet = wxPersistentRegisterAndRestore(this, "Main"); + const wxSize sizeMin = m_panel->GetBestSize(); if ( !sizeSet ) SetClientSize(sizeMin); From bfe44c719b938b4d98a8ed6d9c03c92dfed9054c Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sun, 9 Oct 2016 20:03:41 +0200 Subject: [PATCH 7/8] Do not let wxHeaderCtrl determine the minimum width The minimum width will always be equal to the current size of the parent window (from wxGetClientRect). As a result, controls using wxHeaderCtrl can never be shrunk (e.g. using SetSizeHints). Problem is visible when a wxDataViewCtrl gets a lower DPI. The new minimum size is equal to the current size. --- src/msw/headerctrl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/msw/headerctrl.cpp b/src/msw/headerctrl.cpp index 1694a8e288..966f6b04e5 100644 --- a/src/msw/headerctrl.cpp +++ b/src/msw/headerctrl.cpp @@ -195,7 +195,7 @@ wxSize wxHeaderCtrl::DoGetBestSize() const return wxControl::DoGetBestSize(); } - return wxSize(wpos.cx, wpos.cy); + return wxSize(wxDefaultCoord, wpos.cy); } // ---------------------------------------------------------------------------- From e99af740d9633d803befe4fb17912385fb101549 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Fri, 28 Apr 2017 23:04:46 +0200 Subject: [PATCH 8/8] Make wxArtProvider icon size hints DPI aware --- src/msw/artmsw.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/msw/artmsw.cpp b/src/msw/artmsw.cpp index 7c9e9894eb..eb7a6c4ec8 100644 --- a/src/msw/artmsw.cpp +++ b/src/msw/artmsw.cpp @@ -280,11 +280,11 @@ wxSize wxArtProvider::GetNativeSizeHint(const wxArtClient& client) { if ( client == wxART_TOOLBAR ) { - return wxSize(24, 24); + return wxWindow::FromDIP(wxSize(24, 24), NULL); } else if ( client == wxART_MENU ) { - return wxSize(16, 16); + return wxWindow::FromDIP(wxSize(16, 16), NULL); } else if ( client == wxART_FRAME_ICON ) { @@ -299,11 +299,11 @@ wxSize wxArtProvider::GetNativeSizeHint(const wxArtClient& client) } else if (client == wxART_BUTTON) { - return wxSize(16, 16); + return wxWindow::FromDIP(wxSize(16, 16), NULL); } else if (client == wxART_LIST) { - return wxSize(16, 16); + return wxWindow::FromDIP(wxSize(16, 16), NULL); } return wxDefaultSize;