diff --git a/include/wx/generic/splitter.h b/include/wx/generic/splitter.h index 2294f431e4..f2fbe2a906 100644 --- a/include/wx/generic/splitter.h +++ b/include/wx/generic/splitter.h @@ -131,6 +131,9 @@ public: // Is the window split? bool IsSplit() const { return (m_windowTwo != nullptr); } + // Return true if wxSP_LIVE_UPDATE is always used. + bool AlwaysUsesLiveUpdate() const; + // Sets the border size void SetBorderSize(int WXUNUSED(width)) { } diff --git a/interface/wx/splitter.h b/interface/wx/splitter.h index 4ff835b2ee..22d564a7ea 100644 --- a/interface/wx/splitter.h +++ b/interface/wx/splitter.h @@ -142,6 +142,20 @@ public: */ virtual ~wxSplitterWindow(); + /** + Returns true if splitter always behaves as if wxSP_LIVE_UPDATE were + specified. + + This function returns true if non-live update mode is not supported and + live update is always used, even if wxSP_LIVE_UPDATE was not explicitly + specified. + + @see wxClientDC::CanBeUsedForDrawing() + + @since 3.3.0 + */ + bool AlwaysUsesLiveUpdate() const; + /** Creation function, for two-step construction. See wxSplitterWindow() for details. diff --git a/samples/splitter/splitter.cpp b/samples/splitter/splitter.cpp index 3d100be780..cee9eafc03 100644 --- a/samples/splitter/splitter.cpp +++ b/samples/splitter/splitter.cpp @@ -254,7 +254,7 @@ MyFrame::MyFrame() "Toggle sash invisibility"); splitMenu->AppendSeparator(); - splitMenu->AppendCheckItem(SPLIT_LIVE, + auto itemLive = splitMenu->AppendCheckItem(SPLIT_LIVE, "&Live update\tCtrl-L", "Toggle live update mode"); splitMenu->AppendCheckItem(SPLIT_BORDER, @@ -306,6 +306,12 @@ MyFrame::MyFrame() menuBar->Check(SPLIT_LIVE, true); m_splitter = new MySplitterWindow(this); + if ( m_splitter->AlwaysUsesLiveUpdate() ) + { + // Only live update mode is supported, so this menu item can't be used. + itemLive->Enable(false); + } + // If you use non-zero gravity you must initialize the splitter with its // correct initial size, otherwise it will change the sash position by a // huge amount when it's resized from its initial default size to its real diff --git a/src/generic/splitter.cpp b/src/generic/splitter.cpp index ed0dc2710d..5636704951 100644 --- a/src/generic/splitter.cpp +++ b/src/generic/splitter.cpp @@ -69,6 +69,11 @@ wxBEGIN_EVENT_TABLE(wxSplitterWindow, wxWindow) #endif // wxMSW wxEND_EVENT_TABLE() +bool wxSplitterWindow::AlwaysUsesLiveUpdate() const +{ + return !wxClientDC::CanBeUsedForDrawing(this); +} + static bool IsLive(wxSplitterWindow* wnd) { // with wxSP_LIVE_UPDATE style the splitter windows are always resized @@ -76,10 +81,7 @@ static bool IsLive(wxSplitterWindow* wnd) // draw the sash at the new position but only resize the windows when the // dragging is finished -- but drawing the sash is done using wxClientDC, // so check if we can use it and always use live resizing if we can't - if ( !wxClientDC::CanBeUsedForDrawing(wnd) ) - return true; - - return wnd->HasFlag(wxSP_LIVE_UPDATE); + return wnd->AlwaysUsesLiveUpdate() || wnd->HasFlag(wxSP_LIVE_UPDATE); } bool wxSplitterWindow::Create(wxWindow *parent, wxWindowID id,