From 6efdb3b337990cac9766a69475a287c8c92449bf Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 19 Oct 2020 01:24:55 +0200 Subject: [PATCH 01/13] Put generic wxDataViewCtrl helpers in an anonymous namespace No real changes, just don't pollute the global namespace unnecessarily. --- src/generic/datavgen.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index fb83cd49cb..d259e93509 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -2993,6 +2993,10 @@ void wxDataViewHeaderWindow::FinishEditing() //----------------------------------------------------------------------------- // Helper class for do operation on the tree node //----------------------------------------------------------------------------- + +namespace +{ + class DoJob { public: @@ -3040,6 +3044,8 @@ bool Walker( wxDataViewTreeNode * node, DoJob & func ) return false; } +} // anonymous namespace + bool wxDataViewMainWindow::ItemAdded(const wxDataViewItem & parent, const wxDataViewItem & item) { if (IsVirtualList()) From c24dddc4628fe5d4d2420c763e601ea77a7a3faf Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 19 Oct 2020 01:25:44 +0200 Subject: [PATCH 02/13] Return empty rectangle from GetItemRect() for collapsed items GetItemByRow() returned a valid row even for an item which was collapsed which is clearly inappropriate for its use in GetItemRect(), which is supposed return an invalid rectangle if the item is not visible. It also might be inappropriate in other cases, but this is not totally clear and it seems like it is supposed to return a valid row even for collapsed items at least sometimes, so just make its behaviour conditional by adding a new flags parameter to GetItemRect() and to Walker() helper used by it itself, so that it could skip over collapsed items. Update the test to show that it succeeds now even when the item is present in the tree, as it only passed before because the item had never been expanded at all, and so wasn't really present in the tree structure and the updated test would have failed without the changes to the code in this commit. --- src/generic/datavgen.cpp | 25 ++++++++++++++++++------- tests/controls/dataviewctrltest.cpp | 6 ++++++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index d259e93509..25a28ae657 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -74,6 +74,13 @@ static const int PADDING_RIGHTLEFT = 3; namespace { +// Flags for Walker() function defined below. +enum WalkFlags +{ + Walk_All, // Visit all items. + Walk_ExpandedOnly // Visit only expanded items. +}; + // The column is either the index of the column to be used for sorting or one // of the special values in this enum: enum @@ -854,7 +861,8 @@ public: // Some useful functions for row and item mapping wxDataViewItem GetItemByRow( unsigned int row ) const; - int GetRowByItem( const wxDataViewItem & item ) const; + int GetRowByItem( const wxDataViewItem & item, + WalkFlags flags = Walk_All ) const; wxDataViewTreeNode * GetTreeNodeByRow( unsigned int row ) const; // We did not need this temporarily @@ -3014,7 +3022,8 @@ public: virtual int operator() ( wxDataViewTreeNode * node ) = 0; }; -bool Walker( wxDataViewTreeNode * node, DoJob & func ) +bool +Walker(wxDataViewTreeNode * node, DoJob & func, WalkFlags flags = Walk_All) { wxCHECK_MSG( node, false, "can't walk NULL node" ); @@ -3028,7 +3037,7 @@ bool Walker( wxDataViewTreeNode * node, DoJob & func ) break; } - if ( node->HasChildren() ) + if ( node->HasChildren() && (flags != Walk_ExpandedOnly || node->IsOpen()) ) { const wxDataViewTreeNodes& nodes = node->GetChildNodes(); @@ -3036,7 +3045,7 @@ bool Walker( wxDataViewTreeNode * node, DoJob & func ) i != nodes.end(); ++i ) { - if ( Walker(*i, func) ) + if ( Walker(*i, func, flags) ) return true; } } @@ -4143,7 +4152,7 @@ wxRect wxDataViewMainWindow::GetItemRect( const wxDataViewItem & item, xpos = 0; } - const int row = GetRowByItem(item); + const int row = GetRowByItem(item, Walk_ExpandedOnly); if ( row == -1 ) { // This means the row is currently not visible at all. @@ -4244,7 +4253,9 @@ private: }; -int wxDataViewMainWindow::GetRowByItem(const wxDataViewItem & item) const +int +wxDataViewMainWindow::GetRowByItem(const wxDataViewItem & item, + WalkFlags flags) const { const wxDataViewModel * model = GetModel(); if( model == NULL ) @@ -4274,7 +4285,7 @@ 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() ); - if ( !Walker( m_root, job ) ) + if ( !Walker( m_root, job, flags ) ) return -1; return job.GetResult(); diff --git a/tests/controls/dataviewctrltest.cpp b/tests/controls/dataviewctrltest.cpp index c88eac22ca..2f88a0aa17 100644 --- a/tests/controls/dataviewctrltest.cpp +++ b/tests/controls/dataviewctrltest.cpp @@ -297,6 +297,12 @@ TEST_CASE_METHOD(SingleSelectDataViewCtrlTestCase, CHECK( rect1.y < rect2.y ); } + // This forces generic implementation to add m_grandchild to the tree, as + // it does it only on demand. We want the item to really be there to check + // that GetItemRect() returns an empty rectangle for collapsed items. + m_dvc->Expand(m_child1); + m_dvc->Collapse(m_child1); + const wxRect rectNotShown = m_dvc->GetItemRect(m_grandchild); CHECK( rectNotShown == wxRect() ); From 931b47234213e2f5dfa387506c77ced3864324e1 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 19 Oct 2020 01:32:49 +0200 Subject: [PATCH 03/13] Add items to generic wxDataViewCtrl immediately in ItemAdded() This reverts the changes of 4dc78a33e0 (Fix adding items to a never opened branch of generic wxDataViewCtrl, 2018-01-17) which was supposed to fix a problem which doesn't seem to be reproducible any longer (and, unfortunately, wasn't recorded in the commit message back then), but introduced another problem instead: postponing adding the node to the tree didn't work correctly in case of depth-first model traversal in the user code calling ItemAdded() for all the items, as in this case the next call to ItemAdded() for a child of the item that wasn't added to the tree because its parent hadn't been opened yet, would result in adding this item and all its siblings to the tree when FindNode(parent) would be called. And this, in turn, would result in the siblings of this item being added to the tree twice. Adding a test reproducing this problem is difficult, as we don't have any way to check the internal state of wxDataViewMainWindow from the outside, so this commit still doesn't do this, unfortunately. Closes #18405. --- src/generic/datavgen.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 25a28ae657..2dfd7a953c 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -3075,14 +3075,6 @@ bool wxDataViewMainWindow::ItemAdded(const wxDataViewItem & parent, const wxData parentNode->SetHasChildren(true); - // If the parent node isn't and hadn't been opened yet, we don't have - // anything to do here, all the items will be added to it when it's - // opened for the first time. - if ( !parentNode->IsOpen() && parentNode->GetChildNodes().empty() ) - { - return true; - } - wxDataViewTreeNode *itemNode = new wxDataViewTreeNode(parentNode, item); itemNode->SetHasChildren(GetModel()->IsContainer(item)); From 2e56f1a8d357eb48467d565b36ad0d68572d9dce Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Tue, 20 Oct 2020 20:38:01 +0200 Subject: [PATCH 04/13] Remove more BCC-specific hdrstop pragma --- src/osx/cocoa/activityindicator.mm | 3 --- src/osx/cocoa/datetimectrl.mm | 3 --- src/osx/cocoa/evtloop.mm | 3 --- src/osx/cocoa/glcanvas.mm | 3 --- src/osx/cocoa/mediactrl.mm | 3 --- src/osx/cocoa/nativewin.mm | 3 --- src/osx/cocoa/notifmsg.mm | 3 --- src/osx/cocoa/overlay.mm | 3 --- src/osx/cocoa/preferences.mm | 3 --- src/osx/cocoa/srchctrl.mm | 3 --- src/osx/cocoa/statbmp.mm | 3 --- src/osx/cocoa/statline.mm | 3 --- src/osx/iphone/evtloop.mm | 3 --- src/osx/iphone/glcanvas.mm | 3 --- src/osx/iphone/statbmp.mm | 3 --- src/richtext/richtextdialogs.pjd | 3 --- src/stc/stc.cpp.in | 3 --- 17 files changed, 51 deletions(-) diff --git a/src/osx/cocoa/activityindicator.mm b/src/osx/cocoa/activityindicator.mm index dd4cfa4195..ac79ffae84 100644 --- a/src/osx/cocoa/activityindicator.mm +++ b/src/osx/cocoa/activityindicator.mm @@ -18,9 +18,6 @@ // for compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#ifdef __BORLANDC__ - #pragma hdrstop -#endif #if wxUSE_ACTIVITYINDICATOR diff --git a/src/osx/cocoa/datetimectrl.mm b/src/osx/cocoa/datetimectrl.mm index 19ca20989b..3157bc21c8 100644 --- a/src/osx/cocoa/datetimectrl.mm +++ b/src/osx/cocoa/datetimectrl.mm @@ -18,9 +18,6 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#ifdef __BORLANDC__ - #pragma hdrstop -#endif #if wxUSE_DATEPICKCTRL diff --git a/src/osx/cocoa/evtloop.mm b/src/osx/cocoa/evtloop.mm index fe45a40cf2..f99d09661d 100644 --- a/src/osx/cocoa/evtloop.mm +++ b/src/osx/cocoa/evtloop.mm @@ -19,9 +19,6 @@ // for compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#ifdef __BORLANDC__ - #pragma hdrstop -#endif #include "wx/evtloop.h" diff --git a/src/osx/cocoa/glcanvas.mm b/src/osx/cocoa/glcanvas.mm index 505b3a5e4b..f6bff5b1fb 100644 --- a/src/osx/cocoa/glcanvas.mm +++ b/src/osx/cocoa/glcanvas.mm @@ -18,9 +18,6 @@ #include "wx/wxprec.h" -#if defined(__BORLANDC__) - #pragma hdrstop -#endif #if wxUSE_GLCANVAS diff --git a/src/osx/cocoa/mediactrl.mm b/src/osx/cocoa/mediactrl.mm index fbeafe201b..65efa33089 100644 --- a/src/osx/cocoa/mediactrl.mm +++ b/src/osx/cocoa/mediactrl.mm @@ -19,9 +19,6 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif //--------------------------------------------------------------------------- // Compilation guard diff --git a/src/osx/cocoa/nativewin.mm b/src/osx/cocoa/nativewin.mm index 82dc4775d1..315dd1d562 100644 --- a/src/osx/cocoa/nativewin.mm +++ b/src/osx/cocoa/nativewin.mm @@ -18,9 +18,6 @@ // for compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#ifdef __BORLANDC__ - #pragma hdrstop -#endif #include "wx/nativewin.h" diff --git a/src/osx/cocoa/notifmsg.mm b/src/osx/cocoa/notifmsg.mm index 2ef3fc8e67..8828aed52c 100644 --- a/src/osx/cocoa/notifmsg.mm +++ b/src/osx/cocoa/notifmsg.mm @@ -18,9 +18,6 @@ // for compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#ifdef __BORLANDC__ - #pragma hdrstop -#endif #include "wx/notifmsg.h" diff --git a/src/osx/cocoa/overlay.mm b/src/osx/cocoa/overlay.mm index 6114d31e0a..6aa2211bca 100644 --- a/src/osx/cocoa/overlay.mm +++ b/src/osx/cocoa/overlay.mm @@ -19,9 +19,6 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#ifdef __BORLANDC__ - #pragma hdrstop -#endif #include "wx/overlay.h" diff --git a/src/osx/cocoa/preferences.mm b/src/osx/cocoa/preferences.mm index 6cb962cdbf..63e6eaf9a5 100644 --- a/src/osx/cocoa/preferences.mm +++ b/src/osx/cocoa/preferences.mm @@ -18,9 +18,6 @@ // for compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#ifdef __BORLANDC__ - #pragma hdrstop -#endif #if wxUSE_PREFERENCES_EDITOR diff --git a/src/osx/cocoa/srchctrl.mm b/src/osx/cocoa/srchctrl.mm index 7cf1695285..b556179e69 100644 --- a/src/osx/cocoa/srchctrl.mm +++ b/src/osx/cocoa/srchctrl.mm @@ -10,9 +10,6 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#ifdef __BORLANDC__ - #pragma hdrstop -#endif #if wxUSE_SEARCHCTRL diff --git a/src/osx/cocoa/statbmp.mm b/src/osx/cocoa/statbmp.mm index 20fd645f7c..9ad43cf4e4 100644 --- a/src/osx/cocoa/statbmp.mm +++ b/src/osx/cocoa/statbmp.mm @@ -18,9 +18,6 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif #if wxUSE_STATBMP diff --git a/src/osx/cocoa/statline.mm b/src/osx/cocoa/statline.mm index 8590d36740..fcee93be62 100644 --- a/src/osx/cocoa/statline.mm +++ b/src/osx/cocoa/statline.mm @@ -18,9 +18,6 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#ifdef __BORLANDC__ - #pragma hdrstop -#endif #if wxUSE_STATLINE diff --git a/src/osx/iphone/evtloop.mm b/src/osx/iphone/evtloop.mm index 8c51b1c348..7e0c695570 100644 --- a/src/osx/iphone/evtloop.mm +++ b/src/osx/iphone/evtloop.mm @@ -19,9 +19,6 @@ // for compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#ifdef __BORLANDC__ - #pragma hdrstop -#endif #include "wx/evtloop.h" diff --git a/src/osx/iphone/glcanvas.mm b/src/osx/iphone/glcanvas.mm index d5125c0086..158edf42ce 100644 --- a/src/osx/iphone/glcanvas.mm +++ b/src/osx/iphone/glcanvas.mm @@ -18,9 +18,6 @@ #include "wx/wxprec.h" -#if defined(__BORLANDC__) - #pragma hdrstop -#endif #if wxUSE_GLCANVAS diff --git a/src/osx/iphone/statbmp.mm b/src/osx/iphone/statbmp.mm index a1095a04a9..0c89368e84 100644 --- a/src/osx/iphone/statbmp.mm +++ b/src/osx/iphone/statbmp.mm @@ -18,9 +18,6 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif #if wxUSE_STATBMP diff --git a/src/richtext/richtextdialogs.pjd b/src/richtext/richtextdialogs.pjd index 353af82f62..889583767a 100644 --- a/src/richtext/richtextdialogs.pjd +++ b/src/richtext/richtextdialogs.pjd @@ -66,9 +66,6 @@ "// For compilers that support precompilation, includes "wx/wx.h". #include "wx/wxprec.h" -#ifdef __BORLANDC__ -#pragma hdrstop -#endif #ifndef WX_PRECOMP #include "wx/wx.h" diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index a3987c47fe..81b5c7bf3f 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -28,9 +28,6 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#ifdef __BORLANDC__ - #pragma hdrstop -#endif #if wxUSE_STC From 1d6a6b934f350663d9896cc5e7e1db8c1ed12e55 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Tue, 20 Oct 2020 20:38:30 +0200 Subject: [PATCH 05/13] Remove a borland check --- samples/nativdlg/dialog1.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/nativdlg/dialog1.rc b/samples/nativdlg/dialog1.rc index 3b008e6421..76fb2c7948 100644 --- a/samples/nativdlg/dialog1.rc +++ b/samples/nativdlg/dialog1.rc @@ -21,7 +21,7 @@ #include "resource.h" -#if !defined(__GNUWIN32__) && !defined(__BORLANDC__) +#if !defined(__GNUWIN32__) #include #endif From b1653024d63cb8aeb7654c5be6190cb20854196f Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Tue, 20 Oct 2020 20:39:05 +0200 Subject: [PATCH 06/13] CMake: remove HAVE_VARIADIC_MACROS check --- build/cmake/setup.cmake | 7 ------- 1 file changed, 7 deletions(-) diff --git a/build/cmake/setup.cmake b/build/cmake/setup.cmake index 18556f077a..4360634ddd 100644 --- a/build/cmake/setup.cmake +++ b/build/cmake/setup.cmake @@ -132,13 +132,6 @@ if(NOT MSVC) endif() endif() -wx_check_c_source_compiles( - "#define test(fmt, ...) printf(fmt, __VA_ARGS__) - test(\"%s %d %p\", \"test\", 1, 0);" - HAVE_VARIADIC_MACROS - stdio.h - ) -#TODO: wxNO_VARIADIC_MACROS if(wxUSE_STL AND CMAKE_CXX_STANDARD EQUAL 98) wx_check_cxx_source_compiles(" std::vector moo; From badf0eb64eed2ba581d34c2f95208d70b565bab8 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Tue, 20 Oct 2020 20:40:50 +0200 Subject: [PATCH 07/13] CMake: add image test files --- build/cmake/tests/gui/CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/build/cmake/tests/gui/CMakeLists.txt b/build/cmake/tests/gui/CMakeLists.txt index 61cc082cc6..91ba5faffb 100644 --- a/build/cmake/tests/gui/CMakeLists.txt +++ b/build/cmake/tests/gui/CMakeLists.txt @@ -164,6 +164,15 @@ set(TEST_GUI_DATA image/horse_box_average_100x100.png image/horse_box_average_150x150.png image/horse_box_average_300x300.png + image/paste_input_background.png + image/paste_input_black.png + image/paste_input_overlay_transparent_border_opaque_square.png + image/paste_input_overlay_transparent_border_semitransparent_circle.png + image/paste_input_overlay_transparent_border_semitransparent_square.png + image/paste_result_background_plus_circle_plus_square.png + image/paste_result_background_plus_overlay_transparent_border_opaque_square.png + image/paste_result_background_plus_overlay_transparent_border_semitransparent_square.png + image/paste_result_no_background_square_over_circle.png intl/ja/internat.mo intl/ja/internat.po ) From 1a2d81354eb3ca3314ca0cdc45dc9f6dca569d1e Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Wed, 21 Oct 2020 00:52:20 +0200 Subject: [PATCH 08/13] Don't call SetupColours when loading a native dialog It makes everything grey. --- src/msw/nativdlg.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/msw/nativdlg.cpp b/src/msw/nativdlg.cpp index ecfde39fbb..a5d359ec60 100644 --- a/src/msw/nativdlg.cpp +++ b/src/msw/nativdlg.cpp @@ -300,7 +300,6 @@ wxWindow* wxWindow::CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd) parent->AddChild(win); win->SubclassWin(hWnd); win->AdoptAttributesFromHWND(); - win->SetupColours(); } return win; From a942dc8a76c557d52023dd2b83ebafc298da1570 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Wed, 21 Oct 2020 00:54:28 +0200 Subject: [PATCH 09/13] Remove hard-coded size and position in native dialog sample --- samples/nativdlg/nativdlg.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/nativdlg/nativdlg.cpp b/samples/nativdlg/nativdlg.cpp index 9b8551ef65..7740b6299a 100644 --- a/samples/nativdlg/nativdlg.cpp +++ b/samples/nativdlg/nativdlg.cpp @@ -39,7 +39,7 @@ bool MyApp::OnInit(void) return false; // Create the main frame window - MyFrame *frame = new MyFrame(NULL, wxID_ANY, "wxWidgets Native Dialog Sample", wxPoint(0, 0), wxSize(300, 250)); + MyFrame *frame = new MyFrame(NULL, wxID_ANY, "wxWidgets Native Dialog Sample", wxDefaultPosition, wxDefaultSize); #if wxUSE_STATUSBAR // Give it a status line @@ -60,7 +60,7 @@ bool MyApp::OnInit(void) frame->SetMenuBar(menu_bar); // Make a panel - frame->panel = new wxWindow(frame, wxID_ANY, wxPoint(0, 0), wxSize(400, 400), 0, "MyMainFrame"); + frame->panel = new wxWindow(frame, wxID_ANY); frame->Show(true); return true; From c2819c8d3862ec44d16ec09b3cb2360f8b20b31c Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Wed, 21 Oct 2020 00:57:42 +0200 Subject: [PATCH 10/13] Update indentation in native dialog sample --- samples/nativdlg/nativdlg.cpp | 50 +++++++++++++++++------------------ samples/nativdlg/nativdlg.h | 20 +++++++------- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/samples/nativdlg/nativdlg.cpp b/samples/nativdlg/nativdlg.cpp index 7740b6299a..088a5a7d2b 100644 --- a/samples/nativdlg/nativdlg.cpp +++ b/samples/nativdlg/nativdlg.cpp @@ -35,45 +35,45 @@ wxIMPLEMENT_APP(MyApp); bool MyApp::OnInit(void) { - if ( !wxApp::OnInit() ) - return false; + if ( !wxApp::OnInit() ) + return false; - // Create the main frame window - MyFrame *frame = new MyFrame(NULL, wxID_ANY, "wxWidgets Native Dialog Sample", wxDefaultPosition, wxDefaultSize); + // Create the main frame window + MyFrame* frame = new MyFrame(NULL, wxID_ANY, "wxWidgets Native Dialog Sample", wxDefaultPosition, wxDefaultSize); #if wxUSE_STATUSBAR - // Give it a status line - frame->CreateStatusBar(2); + // Give it a status line + frame->CreateStatusBar(2); #endif // wxUSE_STATUSBAR - // Make a menubar - wxMenu *file_menu = new wxMenu; + // Make a menubar + wxMenu* file_menu = new wxMenu; - file_menu->Append(RESOURCE_TEST1, "&Dialog box test", "Test dialog box resource"); - file_menu->Append(RESOURCE_QUIT, "E&xit", "Quit program"); + file_menu->Append(RESOURCE_TEST1, "&Dialog box test", "Test dialog box resource"); + file_menu->Append(RESOURCE_QUIT, "E&xit", "Quit program"); - wxMenuBar *menu_bar = new wxMenuBar; + wxMenuBar* menu_bar = new wxMenuBar; - menu_bar->Append(file_menu, "&File"); + menu_bar->Append(file_menu, "&File"); - // Associate the menu bar with the frame - frame->SetMenuBar(menu_bar); + // Associate the menu bar with the frame + frame->SetMenuBar(menu_bar); - // Make a panel - frame->panel = new wxWindow(frame, wxID_ANY); - frame->Show(true); + // Make a panel + frame->panel = new wxWindow(frame, wxID_ANY); + frame->Show(true); - return true; + return true; } wxBEGIN_EVENT_TABLE(MyFrame, wxFrame) - EVT_MENU(RESOURCE_QUIT, MyFrame::OnQuit) - EVT_MENU(RESOURCE_TEST1, MyFrame::OnTest1) +EVT_MENU(RESOURCE_QUIT, MyFrame::OnQuit) +EVT_MENU(RESOURCE_TEST1, MyFrame::OnTest1) wxEND_EVENT_TABLE() // Define my frame constructor -MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size): - wxFrame(parent, id, title, pos, size) +MyFrame::MyFrame(wxWindow* parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size) : + wxFrame(parent, id, title, pos, size) { SetIcon(wxICON(sample)); @@ -82,19 +82,19 @@ MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, c void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) { - Close(true); + Close(true); } void MyFrame::OnTest1(wxCommandEvent& WXUNUSED(event)) { #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) MyDialog dialog; - if (dialog.LoadNativeDialog(this, "dialog1")) + if ( dialog.LoadNativeDialog(this, "dialog1") ) { dialog.ShowModal(); } #else - wxMessageBox("No native dialog support","Platform limitation"); + wxMessageBox("No native dialog support", "Platform limitation"); #endif } diff --git a/samples/nativdlg/nativdlg.h b/samples/nativdlg/nativdlg.h index 732f881704..bedc78786f 100644 --- a/samples/nativdlg/nativdlg.h +++ b/samples/nativdlg/nativdlg.h @@ -9,31 +9,31 @@ ///////////////////////////////////////////////////////////////////////////// // Define a new application -class MyApp: public wxApp +class MyApp : public wxApp { - public: - MyApp(void){} +public: + MyApp(void) {} bool OnInit(void) wxOVERRIDE; }; -class MyFrame: public wxFrame +class MyFrame : public wxFrame { - public: - wxWindow *panel; - MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size); +public: + wxWindow* panel; + MyFrame(wxWindow* parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size); void OnQuit(wxCommandEvent& event); void OnTest1(wxCommandEvent& event); - wxDECLARE_EVENT_TABLE(); + wxDECLARE_EVENT_TABLE(); }; class MyDialog : public wxDialog { - public: +public: void OnOk(wxCommandEvent& event); void OnCancel(wxCommandEvent& event); - wxDECLARE_EVENT_TABLE(); + wxDECLARE_EVENT_TABLE(); }; #define RESOURCE_QUIT 4 From 6a579ce34d51384629932114bf05494387354c5a Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Wed, 21 Oct 2020 01:00:31 +0200 Subject: [PATCH 11/13] Include windows.h in native dialog sample resource file Get rid of compiler specific include. --- samples/nativdlg/dialog1.rc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/samples/nativdlg/dialog1.rc b/samples/nativdlg/dialog1.rc index 76fb2c7948..96a294792c 100644 --- a/samples/nativdlg/dialog1.rc +++ b/samples/nativdlg/dialog1.rc @@ -20,10 +20,7 @@ #define wxID_NO 5104 #include "resource.h" - -#if !defined(__GNUWIN32__) -#include -#endif +#include #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// From 095d1e317cc581c8ff15f54fa4f29047d4acba89 Mon Sep 17 00:00:00 2001 From: Gary Allen Date: Thu, 22 Oct 2020 13:04:23 +0200 Subject: [PATCH 12/13] Add wxGridSelectNone selection mode In this mode the user can't select any cells at all in wxGrid. --- include/wx/generic/grid.h | 3 ++- interface/wx/grid.h | 11 ++++++++++- src/generic/grid.cpp | 1 + src/generic/gridsel.cpp | 40 +++++++++++++++++++++++++++++++++++---- 4 files changed, 49 insertions(+), 6 deletions(-) diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index 6256cefa7c..d78a836773 100644 --- a/include/wx/generic/grid.h +++ b/include/wx/generic/grid.h @@ -1457,7 +1457,8 @@ public: wxGridSelectCells = 0, // allow selecting anything wxGridSelectRows = 1, // allow selecting only entire rows wxGridSelectColumns = 2, // allow selecting only entire columns - wxGridSelectRowsOrColumns = wxGridSelectRows | wxGridSelectColumns + wxGridSelectRowsOrColumns = wxGridSelectRows | wxGridSelectColumns, + wxGridSelectNone = 4 // disallow selecting anything }; // Different behaviour of the TAB key when the end (or the beginning, for diff --git a/interface/wx/grid.h b/interface/wx/grid.h index f24fe4df53..9e33e41e4d 100644 --- a/interface/wx/grid.h +++ b/interface/wx/grid.h @@ -2945,7 +2945,16 @@ public: @since 2.9.1 */ - wxGridSelectRowsOrColumns + wxGridSelectRowsOrColumns, + + /** + The selection mode allowing no selections to be made at all. + + The user won't be able to select any cells in this mode. + + @since 3.1.5 + */ + wxGridSelectNone }; /** diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 184010743c..edffab4e97 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -4631,6 +4631,7 @@ wxGrid::DoGridCellLeftDown(wxMouseEvent& event, // mode and is compatible with 2.8 behaviour (see #12062). switch ( m_selection->GetSelectionMode() ) { + case wxGridSelectNone: case wxGridSelectCells: case wxGridSelectRowsOrColumns: // nothing to do in these cases diff --git a/src/generic/gridsel.cpp b/src/generic/gridsel.cpp index af0dced594..e6ac723923 100644 --- a/src/generic/gridsel.cpp +++ b/src/generic/gridsel.cpp @@ -98,6 +98,13 @@ void wxGridSelection::SetSelectionMode( wxGrid::wxGridSelectionModes selmode ) if (selmode == m_selectionMode) return; + if (selmode == wxGrid::wxGridSelectNone) + { + ClearSelection(); + m_selectionMode = selmode; + return; + } + if ( m_selectionMode != wxGrid::wxGridSelectCells ) { // if changing form row to column selection @@ -127,6 +134,7 @@ void wxGridSelection::SetSelectionMode( wxGrid::wxGridSelectionModes selmode ) switch ( selmode ) { case wxGrid::wxGridSelectCells: + case wxGrid::wxGridSelectNone: wxFAIL_MSG("unreachable"); break; @@ -160,7 +168,8 @@ void wxGridSelection::SetSelectionMode( wxGrid::wxGridSelectionModes selmode ) void wxGridSelection::SelectRow(int row, const wxKeyboardState& kbd) { - if ( m_selectionMode == wxGrid::wxGridSelectColumns ) + if ( m_selectionMode == wxGrid::wxGridSelectColumns || + m_selectionMode == wxGrid::wxGridSelectNone ) return; Select(wxGridBlockCoords(row, 0, row, m_grid->GetNumberCols() - 1), @@ -169,7 +178,8 @@ void wxGridSelection::SelectRow(int row, const wxKeyboardState& kbd) void wxGridSelection::SelectCol(int col, const wxKeyboardState& kbd) { - if ( m_selectionMode == wxGrid::wxGridSelectRows ) + if ( m_selectionMode == wxGrid::wxGridSelectRows || + m_selectionMode == wxGrid::wxGridSelectNone ) return; Select(wxGridBlockCoords(0, col, m_grid->GetNumberRows() - 1, col), @@ -214,6 +224,10 @@ void wxGridSelection::SelectBlock( int topRow, int leftCol, else allowed = 0; break; + + case wxGrid::wxGridSelectNone: + allowed = 0; + break; } wxASSERT_MSG(allowed != -1, "unknown selection mode?"); @@ -246,6 +260,10 @@ wxGridSelection::DeselectBlock(const wxGridBlockCoords& block, const wxKeyboardState& kbd, wxEventType eventType) { + // In wxGridSelectNone mode, all blocks should already be deselected. + if ( m_selectionMode == wxGrid::wxGridSelectNone ) + return; + const wxGridBlockCoords canonicalizedBlock = block.Canonicalize(); size_t count, n; @@ -312,6 +330,10 @@ wxGridSelection::DeselectBlock(const wxGridBlockCoords& block, else splitOrientation = wxVERTICAL; break; + + case wxGrid::wxGridSelectNone: + wxFAIL_MSG("unreachable"); + break; } wxASSERT_MSG( splitOrientation != -1, "unknown selection mode" ); @@ -517,10 +539,14 @@ bool wxGridSelection::ExtendCurrentBlock(const wxGridCellCoords& blockStart, wxASSERT( blockStart.GetRow() != -1 && blockStart.GetCol() != -1 && blockEnd.GetRow() != -1 && blockEnd.GetCol() != -1 ); + if ( m_selectionMode == wxGrid::wxGridSelectNone ) + return false; + // If selection doesn't contain the current cell (which also covers the // special case of nothing being selected yet), we have to create a new // block containing it because it doesn't make sense to extend any existing // block to non-selected current cell. + if ( !IsInSelection(m_grid->GetGridCursorCoords()) ) { SelectBlock(blockStart, blockEnd, kbd, eventType); @@ -574,6 +600,10 @@ bool wxGridSelection::ExtendCurrentBlock(const wxGridCellCoords& blockStart, canChangeCol = true; } break; + + case wxGrid::wxGridSelectNone: + wxFAIL_MSG("unreachable"); + break; } if ( canChangeRow ) @@ -754,7 +784,8 @@ wxGridCellCoordsArray wxGridSelection::GetBlockSelectionBottomRight() const // is, anyhow, the best we can do. wxArrayInt wxGridSelection::GetRowSelection() const { - if ( m_selectionMode == wxGrid::wxGridSelectColumns ) + if ( m_selectionMode == wxGrid::wxGridSelectColumns || + m_selectionMode == wxGrid::wxGridSelectNone ) return wxArrayInt(); wxIntSortedArray uniqueRows; @@ -785,7 +816,8 @@ wxArrayInt wxGridSelection::GetRowSelection() const // See comments for GetRowSelection(). wxArrayInt wxGridSelection::GetColSelection() const { - if ( m_selectionMode == wxGrid::wxGridSelectRows ) + if ( m_selectionMode == wxGrid::wxGridSelectRows || + m_selectionMode == wxGrid::wxGridSelectNone ) return wxArrayInt(); wxIntSortedArray uniqueCols; From f765c06f1ae3fff8e3e354d40f6e996e7266af6a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 31 Oct 2020 17:13:06 +0100 Subject: [PATCH 13/13] Show new wxGridSelectNone mode in the grid sample Allow testing the new selection mode interactively. --- samples/grid/griddemo.cpp | 7 +++++++ samples/grid/griddemo.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/samples/grid/griddemo.cpp b/samples/grid/griddemo.cpp index 8056c6da1f..2d345f6796 100644 --- a/samples/grid/griddemo.cpp +++ b/samples/grid/griddemo.cpp @@ -316,6 +316,7 @@ wxBEGIN_EVENT_TABLE( GridFrame, wxFrame ) EVT_MENU( ID_SELROWS, GridFrame::SelectRows ) EVT_MENU( ID_SELCOLS, GridFrame::SelectCols ) EVT_MENU( ID_SELROWSORCOLS, GridFrame::SelectRowsOrCols ) + EVT_MENU( ID_SELNONE, GridFrame::SelectNone ) EVT_MENU( ID_FREEZE_OR_THAW, GridFrame::FreezeOrThaw ) @@ -536,6 +537,7 @@ GridFrame::GridFrame() selectionMenu->Append( ID_SELROWS, "Select &rows" ); selectionMenu->Append( ID_SELCOLS, "Select col&umns" ); selectionMenu->Append( ID_SELROWSORCOLS, "Select rows &or columns" ); + selectionMenu->Append( ID_SELNONE, "&Disallow selection" ); wxMenu *autosizeMenu = new wxMenu; autosizeMenu->Append( ID_SIZE_ROW, "Selected &row data" ); @@ -1443,6 +1445,11 @@ void GridFrame::SelectRowsOrCols( wxCommandEvent& WXUNUSED(ev) ) grid->SetSelectionMode( wxGrid::wxGridSelectRowsOrColumns ); } +void GridFrame::SelectNone( wxCommandEvent& WXUNUSED(ev) ) +{ + grid->SetSelectionMode( wxGrid::wxGridSelectNone ); +} + void GridFrame::FreezeOrThaw(wxCommandEvent& ev) { if ( ev.IsChecked() ) diff --git a/samples/grid/griddemo.h b/samples/grid/griddemo.h index fa196b0643..0957d40b8d 100644 --- a/samples/grid/griddemo.h +++ b/samples/grid/griddemo.h @@ -76,6 +76,7 @@ class GridFrame : public wxFrame void SelectRows( wxCommandEvent& ); void SelectCols( wxCommandEvent& ); void SelectRowsOrCols( wxCommandEvent& ); + void SelectNone( wxCommandEvent& ); void FreezeOrThaw( wxCommandEvent& ); @@ -192,6 +193,7 @@ public: ID_SELROWS, ID_SELCOLS, ID_SELROWSORCOLS, + ID_SELNONE, ID_SET_CELL_FG_COLOUR, ID_SET_CELL_BG_COLOUR, ID_VTABLE,