diff --git a/docs/changes.txt b/docs/changes.txt index 3ffbd29f8aa6..f3a08c9d9bff 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -127,6 +127,10 @@ Changes in behaviour not resulting in compilation errors the page on screen, which doesn't make sense without reference to the tab control containing it, use GetPagePosition() to retrieve both of them. +- wxListbook and wxChoicebook now interpret (but ignore) mnemonics in their + page titles, just as the other wx*book classes already did. Double "&" + in the page text if it should be interpreted as a literal "&". + Changes in behaviour which may result in build errors ----------------------------------------------------- diff --git a/include/wx/aui/auibar.h b/include/wx/aui/auibar.h index 9b25ede41db3..70a6a100f1e9 100644 --- a/include/wx/aui/auibar.h +++ b/include/wx/aui/auibar.h @@ -337,6 +337,12 @@ class WXDLLIMPEXP_AUI wxAuiToolBarArt wxWindow* wnd, const wxAuiToolBarItem& item) = 0; + // This function should be used for querying element sizes in the new code, + // as it scales them by the DPI of the provided window. GetElementSize() + // still exists (and is simpler to override), but is usually _not_ what you + // need. + virtual int GetElementSizeForWindow(int elementId, const wxWindow* window); + // Note that these functions work with the size in DIPs, not physical // pixels. virtual int GetElementSize(int elementId) = 0; diff --git a/include/wx/aui/barartmsw.h b/include/wx/aui/barartmsw.h index 9e5b201a366e..6cea1bc611b7 100644 --- a/include/wx/aui/barartmsw.h +++ b/include/wx/aui/barartmsw.h @@ -76,9 +76,6 @@ class WXDLLIMPEXP_AUI wxAuiMSWToolBarArt : public wxAuiGenericToolBarArt wxWindow* wnd, const wxAuiToolBarItem& item) override; - virtual int GetElementSize(int element) override; - virtual void SetElementSize(int elementId, int size) override; - virtual int ShowDropDown(wxWindow* wnd, const wxAuiToolBarItemArray& items) override; diff --git a/include/wx/aui/dockart.h b/include/wx/aui/dockart.h index c73b7f3be0d1..7a5dc8e8d3f7 100644 --- a/include/wx/aui/dockart.h +++ b/include/wx/aui/dockart.h @@ -38,6 +38,13 @@ class WXDLLIMPEXP_AUI wxAuiDockArt virtual ~wxAuiDockArt() = default; virtual wxAuiDockArt* Clone() = 0; + + // This function should be used for querying metrics in the new code, as it + // will scale them by the DPI of the provided window if necessary. The + // older GetMetric() function is kept for compatibility and shouldn't be + // used outside of this class itself. + virtual int GetMetricForWindow(int id, wxWindow* window); + virtual int GetMetric(int id) = 0; virtual void SetMetric(int id, int newVal) = 0; virtual void SetFont(int id, const wxFont& font) = 0; diff --git a/include/wx/aui/serializer.h b/include/wx/aui/serializer.h index cacc5e2733af..a19aae6891b9 100644 --- a/include/wx/aui/serializer.h +++ b/include/wx/aui/serializer.h @@ -65,11 +65,16 @@ struct wxAuiPaneLayoutInfo : wxAuiDockLayoutInfo wxSize floating_size = wxDefaultSize; + // The remaining fields correspond to individual bits of the pane state + // flags instead of corresponding to wxAuiPaneInfo fields directly because + // we prefer not storing the entire state -- this would be less readable + // and extensible. + // True if the pane is currently maximized. - // - // Note that it's the only field of this struct which doesn't directly - // correspond to a field of wxAuiPaneInfo. bool is_maximized = false; + + // True if the pane is currently hidden. + bool is_hidden = false; }; // wxAuiBookSerializer is used for serializing wxAuiNotebook layout. diff --git a/include/wx/datetime.h b/include/wx/datetime.h index 65bda23164c6..eaf02e1f05b8 100644 --- a/include/wx/datetime.h +++ b/include/wx/datetime.h @@ -19,8 +19,6 @@ #include -#include // for INT_MIN - #include "wx/longlong.h" #include "wx/anystr.h" diff --git a/include/wx/filefn.h b/include/wx/filefn.h index 6279cf62155f..0abd2abe0cb6 100644 --- a/include/wx/filefn.h +++ b/include/wx/filefn.h @@ -10,7 +10,6 @@ #ifndef _FILEFN_H_ #define _FILEFN_H_ -#include "wx/list.h" #include "wx/arrstr.h" #include diff --git a/include/wx/filesys.h b/include/wx/filesys.h index ea46f691392a..95208dfdc435 100644 --- a/include/wx/filesys.h +++ b/include/wx/filesys.h @@ -16,6 +16,7 @@ #include "wx/stream.h" #include "wx/datetime.h" #include "wx/filename.h" +#include "wx/list.h" #include diff --git a/include/wx/hashmap.h b/include/wx/hashmap.h index d32466dd1566..a58faa3742b4 100644 --- a/include/wx/hashmap.h +++ b/include/wx/hashmap.h @@ -569,6 +569,7 @@ struct WXDLLIMPEXP_BASE wxStringEqual #define wxPTROP_NOP(pointer) #define _WX_DECLARE_HASH_MAP( KEY_T, VALUE_T, HASH_T, KEY_EQ_T, CLASSNAME, CLASSEXP ) \ +wxCLANG_WARNING_SUPPRESS(unused-member-function) \ _WX_DECLARE_PAIR( KEY_T, VALUE_T, CLASSNAME##_wxImplementation_Pair, CLASSEXP ) \ _WX_DECLARE_HASH_MAP_KEY_EX( KEY_T, CLASSNAME##_wxImplementation_Pair, CLASSNAME##_wxImplementation_KeyEx, CLASSEXP ) \ _WX_DECLARE_HASHTABLE( CLASSNAME##_wxImplementation_Pair, KEY_T, HASH_T, \ @@ -621,7 +622,8 @@ public: \ { \ return GetNode( key ) ? 1u : 0u; \ } \ -} +} \ +wxCLANG_WARNING_RESTORE(unused-member-function) #endif // wxNEEDS_WX_HASH_MAP diff --git a/include/wx/osx/notebook.h b/include/wx/osx/notebook.h index 3d52ad4cdee2..89e3b5214968 100644 --- a/include/wx/osx/notebook.h +++ b/include/wx/osx/notebook.h @@ -14,6 +14,8 @@ // ---------------------------------------------------------------------------- #include "wx/event.h" +#include + // ---------------------------------------------------------------------------- // types // ---------------------------------------------------------------------------- @@ -128,8 +130,25 @@ class WXDLLIMPEXP_CORE wxNotebook : public wxNotebookBase int DoSetSelection(size_t nPage, int flags = 0) override; - // the icon indices - wxArrayInt m_images; +private: + // this vector is synchronized with m_pages in the base class + struct PageData + { + PageData(const wxString& text_, int image_) + : text{text_}, image{image_} + { + } + + PageData(const PageData&) = default; + PageData& operator=(const PageData&) = default; + + PageData(PageData&&) = default; + PageData& operator=(PageData&&) = default; + + wxString text; + int image = wxNOT_FOUND; + }; + std::vector m_pagesData; wxDECLARE_DYNAMIC_CLASS(wxNotebook); wxDECLARE_EVENT_TABLE(); diff --git a/include/wx/statusbr.h b/include/wx/statusbr.h index 8a4506a8d41f..e311a5580b4e 100644 --- a/include/wx/statusbr.h +++ b/include/wx/statusbr.h @@ -15,7 +15,6 @@ #if wxUSE_STATUSBAR #include "wx/control.h" -#include "wx/list.h" #include "wx/dynarray.h" #include "wx/weakref.h" diff --git a/include/wx/strconv.h b/include/wx/strconv.h index ce7022aaff3a..3b332a65be62 100644 --- a/include/wx/strconv.h +++ b/include/wx/strconv.h @@ -15,8 +15,6 @@ #include "wx/chartype.h" #include "wx/buffer.h" -#include - class WXDLLIMPEXP_FWD_BASE wxString; // the error value returned by wxMBConv methods diff --git a/include/wx/stream.h b/include/wx/stream.h index 668a1d19fd3a..a1209b73ebda 100644 --- a/include/wx/stream.h +++ b/include/wx/stream.h @@ -14,7 +14,6 @@ #if wxUSE_STREAMS -#include #include "wx/object.h" #include "wx/string.h" #include "wx/filefn.h" // for wxFileOffset, wxInvalidOffset and wxSeekMode diff --git a/include/wx/string.h b/include/wx/string.h index 0efdf20aebd2..274e7cac48ab 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -27,10 +27,7 @@ #endif #include -#include #include -#include -#include #include "wx/chartype.h" // for wxChar #include "wx/wxcrtbase.h" // for wxChar, wxStrlen() etc. diff --git a/include/wx/unix/private/uilocale.h b/include/wx/unix/private/uilocale.h index 10e6b3a90fd7..6accc495c518 100644 --- a/include/wx/unix/private/uilocale.h +++ b/include/wx/unix/private/uilocale.h @@ -41,6 +41,7 @@ namespace class TempLocaleSetter { public: + wxCLANG_WARNING_SUPPRESS(unused-member-function) explicit TempLocaleSetter(int localeCategory, const wxString& localeId = wxString()) : m_localeCategory(localeCategory), @@ -54,6 +55,7 @@ class TempLocaleSetter setlocale(m_localeCategory, m_localeOrig); free(m_localeOrig); } + wxCLANG_WARNING_RESTORE(unused-member-function) private: const int m_localeCategory; diff --git a/include/wx/utils.h b/include/wx/utils.h index c51f1453096b..c3bed00b7e08 100644 --- a/include/wx/utils.h +++ b/include/wx/utils.h @@ -15,7 +15,6 @@ // ---------------------------------------------------------------------------- #include "wx/object.h" -#include "wx/list.h" #include "wx/filefn.h" #include "wx/versioninfo.h" #include "wx/meta/implicitconversion.h" @@ -48,8 +47,6 @@ class WXDLLIMPEXP_FWD_BASE wxArrayInt; #include #endif -#include - #include // ---------------------------------------------------------------------------- diff --git a/include/wx/xml/xml.h b/include/wx/xml/xml.h index 023337ce33ff..f17ecb58ea9a 100644 --- a/include/wx/xml/xml.h +++ b/include/wx/xml/xml.h @@ -17,7 +17,6 @@ #include "wx/string.h" #include "wx/object.h" -#include "wx/list.h" #include "wx/textbuf.h" #include "wx/versioninfo.h" #include "wx/filefn.h" diff --git a/include/wx/xrc/xmlres.h b/include/wx/xrc/xmlres.h index f6ccad05a13e..b0827da04e6b 100644 --- a/include/wx/xrc/xmlres.h +++ b/include/wx/xrc/xmlres.h @@ -18,7 +18,6 @@ #include "wx/dynarray.h" #include "wx/arrstr.h" #include "wx/datetime.h" -#include "wx/list.h" #include "wx/gdicmn.h" #include "wx/filesys.h" #include "wx/bitmap.h" diff --git a/interface/wx/aui/auibar.h b/interface/wx/aui/auibar.h index a820a0311a39..2a3c456465e0 100644 --- a/interface/wx/aui/auibar.h +++ b/interface/wx/aui/auibar.h @@ -102,7 +102,7 @@ enum wxAuiToolBarArtSetting /** Overflow button size in wxAuiToolBar. */ - wxAUI_TBART_OVERFLOW_SIZE = 2 + wxAUI_TBART_OVERFLOW_SIZE = 2, /** Drop down button size in wxAuiToolBar. @@ -547,8 +547,56 @@ class wxAuiToolBarArt wxWindow* wnd, const wxAuiToolBarItem& item) = 0; - virtual int GetElementSize(int element_id) = 0; - virtual void SetElementSize(int element_id, int size) = 0; + /** + Get the element size scaled by the DPI of the given window. + + This function should be used to get the size of the element in pixels. + + The default version delegates to GetElementSize(), override this + function if a different behaviour (e.g. to use some smarter algorithm + for scaling instead of just multiplying by the DPI factor) is needed. + + @param elementId + One of ::wxAuiToolBarArtSetting elements. + @param window + A valid window, typically wxAuiToolBar itself. + @return + The size of the element in pixels. + + @see SetElementSize() + + @since 3.3.0 + */ + virtual int GetElementSizeForWindow(int elementId, const wxWindow* window); + + /** + Returns the size of the given element in DIPs. + + This function is typically more convenient to override, as it can just + return the same value as was passed to SetElementSize(), but it + shouldn't usually be called, use GetElementSizeForWindow() instead. + + @param elementId + One of ::wxAuiToolBarArtSetting elements. + @return + The size of the element in DIPs. + */ + virtual int GetElementSize(int elementId) = 0; + + /** + Sets the size of the given element in DIPs. + + Note that this function takes the size in DPI-independent pixels and + this size will be scaled by the factor depending on the DPI being + actually used by GetElementSizeForWindow(). In particular, do _not_ use + wxWindow::FromDIP() for the @a size argument passed to this function. + + @param elementId + One of ::wxAuiToolBarArtSetting elements. + @param size + The size of the element in DIPs. + */ + virtual void SetElementSize(int elementId, int size) = 0; virtual int ShowDropDown( wxWindow* wnd, @@ -638,8 +686,24 @@ class wxAuiDefaultToolBarArt : public wxAuiToolBarArt wxWindow* wnd, const wxAuiToolBarItem& item); - virtual int GetElementSize(int element); - virtual void SetElementSize(int element_id, int size); + /** + Return the size of the element. + + Implement the base class pure virtual function by returning the default + element size or the last value passed to SetElementSize(). + */ + virtual int GetElementSize(int elementId); + + /** + Change the size of the element. + + Implements the base class pure virtual function by storing the value to + be returned by GetElementSize() and used by GetElementSizeForWindow(). + + As for the base class function, @a size is in DIPs, _not_ pixels, so + wxWindow::FromDIP() should _not_ be used for it. + */ + virtual void SetElementSize(int elementId, int size); virtual int ShowDropDown(wxWindow* wnd, const wxAuiToolBarItemArray& items); @@ -925,7 +989,19 @@ class wxAuiToolBar : public wxControl void SetToolProportion(int toolId, int proportion); int GetToolProportion(int toolId) const; + /** + Set the tool separation in DIPs. + + Please note that because this function passes @a separation to + wxAuiToolBarArt::SetElementSize() it should be given in DIPs, not in + (logical) pixels. I.e. do _not_ use wxWindow::FromDIP() for this + function argument. + */ void SetToolSeparation(int separation); + + /** + Returns the separation between tools in logical pixels. + */ int GetToolSeparation() const; void SetToolSticky(int toolId, bool sticky); diff --git a/interface/wx/aui/dockart.h b/interface/wx/aui/dockart.h index ec87f89fe1bc..c3b13ce4c315 100644 --- a/interface/wx/aui/dockart.h +++ b/interface/wx/aui/dockart.h @@ -265,10 +265,34 @@ class wxAuiDockArt /** Get the value of a certain setting. @a id can be one of the size values of @b wxAuiPaneDockArtSetting. - Sizes are in DPI-independent pixel values. + + This function returns the same value that was set by SetMetric(), use + GetMetricForWindow() to get the value appropriate for the given window + for metrics that express sizes. */ virtual int GetMetric(int id) = 0; + /** + Get metric value scaled by the DPI of the given window if appropriate. + + Call this function instead of GetMetric() to get the metric value + scaled by the window DPI for the metrics that are expressed in pixels + and must be scaled. + + The default implementation doesn't scale ::wxAUI_DOCKART_SASH_SIZE and + ::wxAUI_DOCKART_PANE_BORDER_SIZE metrics in order to allow setting them + to just a single pixel (which is the default value for the latter in + wxAuiDefaultDockArt) even in high DPI. You may override this function + in your custom art implementation to scale these metrics too if you + prefer to have thicker borders in high DPI. + + Note that values of ::wxAUI_DOCKART_GRADIENT_TYPE are not expressed in + pixels and so should never be scaled by this function. + + @since 3.3.0 + */ + virtual int GetMetricForWindow(int id, wxWindow* window); + /** Set a certain setting with the value @e colour. @a id can be one of the colour values of @b wxAuiPaneDockArtSetting. @@ -282,8 +306,11 @@ class wxAuiDockArt /** Set a certain setting with the value @e new_val. + @a id can be one of the size values of @b wxAuiPaneDockArtSetting. - Sizes should be in DPI-independent pixel values. + + The interpretation of @a new_val depends on the metric being set, see + GetMetricForWindow(). */ virtual void SetMetric(int id, int new_val) = 0; }; diff --git a/interface/wx/aui/serializer.h b/interface/wx/aui/serializer.h index a8c0d248d3f3..c5fb652a966c 100644 --- a/interface/wx/aui/serializer.h +++ b/interface/wx/aui/serializer.h @@ -67,8 +67,9 @@ struct wxAuiTabLayoutInfo : wxAuiDockLayoutInfo This struct is used with wxAuiSerializer and wxAuiDeserializer to store the pane layout. Its fields, including the inherited ones from wxAuiDockLayoutInfo, have the same meaning as the corresponding fields in - wxAuiPaneInfo (with the exception of `is_maximized`), but it doesn't - contain the fields that it wouldn't make sense to serialize. + wxAuiPaneInfo (with the exception of `is_maximized` and `is_hidden`, which + rather correspond to the individual bits of its state field), but it + doesn't contain the fields that it wouldn't make sense to serialize. @since 3.3.0 */ @@ -91,6 +92,9 @@ struct wxAuiPaneLayoutInfo : wxAuiDockLayoutInfo /// True if the pane is currently maximized. bool is_maximized = false; + + /// True if the pane is currently hidden. + bool is_hidden = false; }; /** diff --git a/interface/wx/bookctrl.h b/interface/wx/bookctrl.h index 739609049b65..75248b64700a 100644 --- a/interface/wx/bookctrl.h +++ b/interface/wx/bookctrl.h @@ -139,6 +139,10 @@ class wxBookCtrlBase : public wxControl, public wxWithImages /** Sets the text for the given page. + + The text may contain mnemonics, i.e. accelerator characters preceded by + the ampersand (`&`) character. If you need to include a literal + ampersand in the text, you need to double it, i.e. use `&&`. */ virtual bool SetPageText(size_t page, const wxString& text) = 0; ///@} @@ -257,7 +261,8 @@ class wxBookCtrlBase : public wxControl, public wxWithImages @param page Specifies the new page. @param text - Specifies the text for the new page. + Specifies the text of the new page. Note that it may contain + mnemonic characters, see SetPageText() for more information. @param select Specifies whether the page should be selected. @param imageId @@ -297,7 +302,8 @@ class wxBookCtrlBase : public wxControl, public wxWithImages @param page Specifies the new page. @param text - Specifies the text for the new page. + Specifies the text of the new page. Note that it may contain + mnemonic characters, see SetPageText() for more information. @param select Specifies whether the page should be selected. @param imageId diff --git a/samples/aui/auidemo.cpp b/samples/aui/auidemo.cpp index cb8c69c4fa5a..beb1bde10394 100644 --- a/samples/aui/auidemo.cpp +++ b/samples/aui/auidemo.cpp @@ -1014,7 +1014,7 @@ MyFrame::MyFrame(wxWindow* parent, wxWindow* wnd10 = CreateTextCtrl("This pane will prompt the user before hiding."); // Give this pane an icon, too, just for testing. - int iconSize = FromDIP(m_mgr.GetArtProvider()->GetMetric(wxAUI_DOCKART_CAPTION_SIZE)); + int iconSize = m_mgr.GetArtProvider()->GetMetricForWindow(wxAUI_DOCKART_CAPTION_SIZE, this); // Make it even to use 16 pixel icons with default 17 caption height. iconSize &= ~1; @@ -1587,6 +1587,10 @@ class MyXmlSerializer : public wxAuiSerializer if ( pane.is_maximized ) AddChild(node, "maximized", 1); + // Also don't mark visible pages (as most of them are) as being so. + if ( pane.is_hidden ) + AddChild(node, "hidden", 1); + m_panes->AddChild(node); } @@ -1779,6 +1783,10 @@ class MyXmlDeserializer : public wxAuiDeserializer { pane.is_maximized = GetInt(content) != 0; } + else if ( name == "hidden" ) + { + pane.is_hidden = GetInt(content) != 0; + } else { throw std::runtime_error("Unexpected pane child node name"); diff --git a/samples/notebook/notebook.h b/samples/notebook/notebook.h index 9ee628c5bab3..763e85583edb 100644 --- a/samples/notebook/notebook.h +++ b/samples/notebook/notebook.h @@ -187,7 +187,7 @@ enum ID_COMMANDS */ #define I_WAS_INSERTED_PAGE_NAME "Inserted" -#define RADIOBUTTONS_PAGE_NAME "Radiobuttons" +#define RADIOBUTTONS_PAGE_NAME "Radio &buttons" #define VETO_PAGE_NAME "Veto" #define TEXT_PAGE_NAME "Text" diff --git a/src/aui/auibar.cpp b/src/aui/auibar.cpp index 64793f30fc97..6c76354fa2dc 100644 --- a/src/aui/auibar.cpp +++ b/src/aui/auibar.cpp @@ -130,6 +130,12 @@ wxBitmap wxAuiToolBarItem::GetCurrentBitmapFor(wxWindow* wnd) const return m_bitmap.GetBitmapFor(wnd); } +int +wxAuiToolBarArt::GetElementSizeForWindow(int elementId, const wxWindow* window) +{ + return wxWindow::FromDIP(GetElementSize(elementId), window); +} + wxAuiGenericToolBarArt::wxAuiGenericToolBarArt() { UpdateColoursFromSystem(); @@ -137,10 +143,11 @@ wxAuiGenericToolBarArt::wxAuiGenericToolBarArt() m_flags = 0; m_textOrientation = wxAUI_TBTOOL_TEXT_BOTTOM; - m_separatorSize = wxWindow::FromDIP( 7, nullptr); - m_gripperSize = wxWindow::FromDIP( 7, nullptr); - m_overflowSize = wxWindow::FromDIP(16, nullptr); - m_dropdownSize = wxWindow::FromDIP(10, nullptr); + // Note that these values are intentionally in DIPs. + m_separatorSize = 7; + m_gripperSize = 7; + m_overflowSize = 16; + m_dropdownSize = 10; m_font = *wxNORMAL_FONT; @@ -380,7 +387,7 @@ void wxAuiGenericToolBarArt::DrawDropDownButton( const wxAuiToolBarItem& item, const wxRect& rect) { - int dropdownWidth = GetElementSize(wxAUI_TBART_DROPDOWN_SIZE); + int dropdownWidth = GetElementSizeForWindow(wxAUI_TBART_DROPDOWN_SIZE, wnd); int textWidth = 0, textHeight = 0, textX = 0, textY = 0; int bmpX = 0, bmpY = 0, dropBmpX = 0, dropBmpY = 0; @@ -615,7 +622,7 @@ wxSize wxAuiGenericToolBarArt::GetToolSize( // and add some extra space in front of the drop down button if (item.HasDropDown()) { - int dropdownWidth = GetElementSize(wxAUI_TBART_DROPDOWN_SIZE); + int dropdownWidth = GetElementSizeForWindow(wxAUI_TBART_DROPDOWN_SIZE, wnd); width += dropdownWidth + wnd->FromDIP(4); } @@ -1333,7 +1340,7 @@ void wxAuiToolBar::SetToolSeparation(int separation) int wxAuiToolBar::GetToolSeparation() const { if (m_art) - return m_art->GetElementSize(wxAUI_TBART_SEPARATOR_SIZE); + return m_art->GetElementSizeForWindow(wxAUI_TBART_SEPARATOR_SIZE, this); else return FromDIP(5); } @@ -1961,8 +1968,8 @@ wxSize wxAuiToolBar::RealizeHelper(wxReadOnlyDC& dc, wxOrientation orientation) wxBoxSizer* sizer = new wxBoxSizer(orientation); // add gripper area - int separatorSize = m_art->GetElementSize(wxAUI_TBART_SEPARATOR_SIZE); - int gripperSize = m_art->GetElementSize(wxAUI_TBART_GRIPPER_SIZE); + int separatorSize = m_art->GetElementSizeForWindow(wxAUI_TBART_SEPARATOR_SIZE, this); + int gripperSize = m_art->GetElementSizeForWindow(wxAUI_TBART_GRIPPER_SIZE, this); if (gripperSize > 0 && m_gripperVisible) { m_gripperSizerItem = sizer->AddSpacer(gripperSize); @@ -2098,7 +2105,7 @@ wxSize wxAuiToolBar::RealizeHelper(wxReadOnlyDC& dc, wxOrientation orientation) if (m_windowStyle & wxAUI_TB_OVERFLOW) { - int overflow_size = m_art->GetElementSize(wxAUI_TBART_OVERFLOW_SIZE); + int overflow_size = m_art->GetElementSizeForWindow(wxAUI_TBART_OVERFLOW_SIZE, this); if (overflow_size > 0 && m_overflowVisible) { m_overflowSizerItem = sizer->AddSpacer(overflow_size); @@ -2169,7 +2176,7 @@ wxRect wxAuiToolBar::GetOverflowRect() const { wxRect cli_rect(wxPoint(0,0), GetClientSize()); wxRect overflow_rect = m_overflowSizerItem->GetRect(); - int overflow_size = m_art->GetElementSize(wxAUI_TBART_OVERFLOW_SIZE); + int overflow_size = m_art->GetElementSizeForWindow(wxAUI_TBART_OVERFLOW_SIZE, this); if (m_orientation == wxVERTICAL) { @@ -2472,8 +2479,8 @@ void wxAuiToolBar::OnPaint(wxPaintEvent& WXUNUSED(evt)) bool horizontal = m_orientation == wxHORIZONTAL; - int gripperSize = m_art->GetElementSize(wxAUI_TBART_GRIPPER_SIZE); - int overflowSize = m_art->GetElementSize(wxAUI_TBART_OVERFLOW_SIZE); + int gripperSize = m_art->GetElementSizeForWindow(wxAUI_TBART_GRIPPER_SIZE, this); + int overflowSize = m_art->GetElementSizeForWindow(wxAUI_TBART_OVERFLOW_SIZE, this); // paint the gripper if (gripperSize > 0 && m_gripperSizerItem) @@ -2655,7 +2662,7 @@ void wxAuiToolBar::OnLeftDown(wxMouseEvent& evt) int mouse_x = evt.GetX(); wxRect rect = m_actionItem->m_sizerItem->GetRect(); - int dropdownWidth = m_art->GetElementSize(wxAUI_TBART_DROPDOWN_SIZE); + int dropdownWidth = m_art->GetElementSizeForWindow(wxAUI_TBART_DROPDOWN_SIZE, this); const bool dropDownHit = m_actionItem->m_dropDown && mouse_x >= (rect.x+rect.width-dropdownWidth) && mouse_x < (rect.x+rect.width); @@ -2765,7 +2772,7 @@ void wxAuiToolBar::OnRightDown(wxMouseEvent& evt) if (m_overflowSizerItem && m_art) { - int overflowSize = m_art->GetElementSize(wxAUI_TBART_OVERFLOW_SIZE); + int overflowSize = m_art->GetElementSizeForWindow(wxAUI_TBART_OVERFLOW_SIZE, this); if (overflowSize > 0 && evt.m_x > cli_rect.width - overflowSize && evt.m_y >= 0 && @@ -2837,7 +2844,7 @@ void wxAuiToolBar::OnMiddleDown(wxMouseEvent& evt) if (m_overflowSizerItem && m_art) { - int overflowSize = m_art->GetElementSize(wxAUI_TBART_OVERFLOW_SIZE); + int overflowSize = m_art->GetElementSizeForWindow(wxAUI_TBART_OVERFLOW_SIZE, this); if (overflowSize > 0 && evt.m_x > cli_rect.width - overflowSize && evt.m_y >= 0 && diff --git a/src/aui/barartmsw.cpp b/src/aui/barartmsw.cpp index 0782b090b503..a894b583e74f 100644 --- a/src/aui/barartmsw.cpp +++ b/src/aui/barartmsw.cpp @@ -45,7 +45,9 @@ wxAuiMSWToolBarArt::wxAuiMSWToolBarArt() // TP_DROPDOWNBUTTON is only 7px, too small to fit the dropdown arrow, // use 14px instead. - m_dropdownSize = window->FromDIP(14); + // + // Note that this value is intentionally in DIPs. + m_dropdownSize = 14; m_buttonSize = hThemeToolbar.GetTrueSize(TP_BUTTON); } @@ -396,16 +398,6 @@ wxSize wxAuiMSWToolBarArt::GetToolSize( return wxAuiGenericToolBarArt::GetToolSize(dc, wnd, item); } -int wxAuiMSWToolBarArt::GetElementSize(int element) -{ - return wxAuiGenericToolBarArt::GetElementSize(element); -} - -void wxAuiMSWToolBarArt::SetElementSize(int elementId, int size) -{ - wxAuiGenericToolBarArt::SetElementSize(elementId, size); -} - int wxAuiMSWToolBarArt::ShowDropDown(wxWindow* wnd, const wxAuiToolBarItemArray& items) { diff --git a/src/aui/dockart.cpp b/src/aui/dockart.cpp index a588563a3db9..37ca65718ddd 100644 --- a/src/aui/dockart.cpp +++ b/src/aui/dockart.cpp @@ -179,6 +179,40 @@ wxString wxAuiChopText(wxDC& dc, const wxString& text, int max_size) return ret; } +// ---------------------------------------------------------------------------- +// wxAuiDockArt +// ---------------------------------------------------------------------------- + +int wxAuiDockArt::GetMetricForWindow(int id, wxWindow* window) +{ + // Most, but not all, metrics are adjusted to the window DPI. + bool scale = false; + switch (id) + { + case wxAUI_DOCKART_SASH_SIZE: + case wxAUI_DOCKART_PANE_BORDER_SIZE: + // These sizes are typically small values and we don't scale them + // by default to allow setting them to 1 pixel even in high DPI. + break; + + case wxAUI_DOCKART_CAPTION_SIZE: + case wxAUI_DOCKART_GRIPPER_SIZE: + case wxAUI_DOCKART_PANE_BUTTON_SIZE: + scale = true; + break; + + case wxAUI_DOCKART_GRADIENT_TYPE: + // This value is not in pixels at all and is never scaled. + break; + } + + int value = GetMetric(id); + if ( scale ) + value = wxWindow::FromDIP(value, window); + + return value; +} + // -- wxAuiDefaultDockArt class implementation -- // wxAuiDefaultDockArt is an art provider class which does all of the drawing for @@ -518,11 +552,11 @@ void wxAuiDefaultDockArt::DrawBorder(wxDC& dc, wxWindow* window, const wxRect& _ dc.SetBrush(*wxTRANSPARENT_BRUSH); wxRect rect = _rect; - int i, border_width = window->FromDIP(GetMetric(wxAUI_DOCKART_PANE_BORDER_SIZE)); + const int border_width = GetMetricForWindow(wxAUI_DOCKART_PANE_BORDER_SIZE, window); if (pane.IsToolbar()) { - for (i = 0; i < border_width; ++i) + for (int i = 0; i < border_width; ++i) { dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW))); dc.DrawLine(rect.x, rect.y, rect.x+rect.width, rect.y); @@ -547,7 +581,7 @@ void wxAuiDefaultDockArt::DrawBorder(wxDC& dc, wxWindow* window, const wxRect& _ art->DrawBorder(dc, window, rect); else { - for (i = 0; i < border_width; ++i) + for (int i = 0; i < border_width; ++i) { dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height); rect.Deflate(1); @@ -639,12 +673,14 @@ void wxAuiDefaultDockArt::DrawCaption(wxDC& dc, wxRect clip_rect = rect; clip_rect.width -= window->FromDIP(3); // text offset clip_rect.width -= window->FromDIP(2); // button padding + + const int buttonSize = GetMetricForWindow(wxAUI_DOCKART_PANE_BUTTON_SIZE, window); if (pane.HasCloseButton()) - clip_rect.width -= window->FromDIP(m_buttonSize); + clip_rect.width -= buttonSize; if (pane.HasPinButton()) - clip_rect.width -= window->FromDIP(m_buttonSize); + clip_rect.width -= buttonSize; if (pane.HasMaximizeButton()) - clip_rect.width -= window->FromDIP(m_buttonSize); + clip_rect.width -= buttonSize; wxString draw_text = wxAuiChopText(dc, text, clip_rect.width); diff --git a/src/aui/floatpane.cpp b/src/aui/floatpane.cpp index f9e38fad0502..a32c38f9d8fc 100644 --- a/src/aui/floatpane.cpp +++ b/src/aui/floatpane.cpp @@ -147,10 +147,11 @@ void wxAuiFloatingFrame::SetPaneWindow(const wxAuiPaneInfo& pane) size = m_paneWindow->GetSize(); if (m_ownerMgr && pane.HasGripper()) { + const int gripperSize = m_ownerMgr->m_art->GetMetricForWindow(wxAUI_DOCKART_GRIPPER_SIZE, m_paneWindow); if (pane.HasGripperTop()) - size.y += m_paneWindow->FromDIP(m_ownerMgr->m_art->GetMetric(wxAUI_DOCKART_GRIPPER_SIZE)); + size.y += gripperSize; else - size.x += m_paneWindow->FromDIP(m_ownerMgr->m_art->GetMetric(wxAUI_DOCKART_GRIPPER_SIZE)); + size.x += gripperSize; } SetClientSize(size); diff --git a/src/aui/framemanager.cpp b/src/aui/framemanager.cpp index f01753db322f..71d7544a5554 100644 --- a/src/aui/framemanager.cpp +++ b/src/aui/framemanager.cpp @@ -1438,6 +1438,7 @@ wxAuiManager::CopyLayoutFrom(wxAuiPaneLayoutInfo& layoutInfo, layoutInfo.floating_size = pane.floating_size; layoutInfo.is_maximized = pane.HasFlag(wxAuiPaneInfo::optionMaximized); + layoutInfo.is_hidden = pane.HasFlag(wxAuiPaneInfo::optionHidden); } void @@ -1450,6 +1451,7 @@ wxAuiManager::CopyLayoutTo(const wxAuiPaneLayoutInfo& layoutInfo, pane.floating_size = layoutInfo.floating_size; pane.SetFlag(wxAuiPaneInfo::optionMaximized, layoutInfo.is_maximized); + pane.SetFlag(wxAuiPaneInfo::optionHidden, layoutInfo.is_hidden); } void wxAuiManager::SaveLayout(wxAuiSerializer& serializer) const @@ -1612,9 +1614,9 @@ void wxAuiManager::GetPanePositionsAndSizes(wxAuiDockInfo& dock, for ( auto* p : dock.panes ) { wxAuiPaneInfo& pane = *p; - int caption_size = pane.window->FromDIP(m_art->GetMetric(wxAUI_DOCKART_CAPTION_SIZE)); - int pane_borderSize = pane.window->FromDIP(m_art->GetMetric(wxAUI_DOCKART_PANE_BORDER_SIZE)); - int gripperSize = pane.window->FromDIP(m_art->GetMetric(wxAUI_DOCKART_GRIPPER_SIZE)); + int caption_size = m_art->GetMetricForWindow(wxAUI_DOCKART_CAPTION_SIZE, pane.window); + int pane_borderSize = m_art->GetMetricForWindow(wxAUI_DOCKART_PANE_BORDER_SIZE, pane.window); + int gripperSize = m_art->GetMetricForWindow(wxAUI_DOCKART_GRIPPER_SIZE, pane.window); positions.Add(pane.dock_pos); int size = 0; @@ -1681,10 +1683,10 @@ void wxAuiManager::LayoutAddPane(wxSizer* cont, wxAuiDockUIPart part; wxSizerItem* sizer_item; - int caption_size = pane.window->FromDIP(m_art->GetMetric(wxAUI_DOCKART_CAPTION_SIZE)); - int gripperSize = pane.window->FromDIP(m_art->GetMetric(wxAUI_DOCKART_GRIPPER_SIZE)); - int pane_borderSize = pane.window->FromDIP(m_art->GetMetric(wxAUI_DOCKART_PANE_BORDER_SIZE)); - int pane_button_size = pane.window->FromDIP(m_art->GetMetric(wxAUI_DOCKART_PANE_BUTTON_SIZE)); + int caption_size = m_art->GetMetricForWindow(wxAUI_DOCKART_CAPTION_SIZE, pane.window); + int gripperSize = m_art->GetMetricForWindow(wxAUI_DOCKART_GRIPPER_SIZE, pane.window); + int pane_borderSize = m_art->GetMetricForWindow(wxAUI_DOCKART_PANE_BORDER_SIZE, pane.window); + int pane_button_size = m_art->GetMetricForWindow(wxAUI_DOCKART_PANE_BUTTON_SIZE, pane.window); // find out the orientation of the item (orientation for panes // is the same as the dock's orientation) @@ -1863,7 +1865,7 @@ void wxAuiManager::LayoutAddDock(wxSizer* cont, wxSizerItem* sizer_item; wxAuiDockUIPart part; - int sashSize = m_frame->FromDIP(m_art->GetMetric(wxAUI_DOCKART_SASH_SIZE)); + int sashSize = m_art->GetMetricForWindow(wxAUI_DOCKART_SASH_SIZE, m_frame); int orientation = dock.IsHorizontal() ? wxHORIZONTAL : wxVERTICAL; // resizable bottom and right docks have a sash before them @@ -2019,8 +2021,8 @@ wxSizer* wxAuiManager::LayoutAll(wxAuiPaneInfoArray& panes, wxAuiDockUIPartArray& uiparts, bool spacer_only) { - int pane_borderSize = m_frame->FromDIP(m_art->GetMetric(wxAUI_DOCKART_PANE_BORDER_SIZE)); - int caption_size = m_frame->FromDIP(m_art->GetMetric(wxAUI_DOCKART_CAPTION_SIZE)); + int pane_borderSize = m_art->GetMetricForWindow(wxAUI_DOCKART_PANE_BORDER_SIZE, m_frame); + int caption_size = m_art->GetMetricForWindow(wxAUI_DOCKART_CAPTION_SIZE, m_frame); wxSize cli_size = m_frame->GetClientSize(); @@ -4107,7 +4109,7 @@ bool wxAuiManager::DoEndResizeAction(wxMouseEvent& event) if (m_actionPart && m_actionPart->type==wxAuiDockUIPart::typeDockSizer) { // first, we must calculate the maximum size the dock may be - int sashSize = m_frame->FromDIP(m_art->GetMetric(wxAUI_DOCKART_SASH_SIZE)); + int sashSize = m_art->GetMetricForWindow(wxAUI_DOCKART_SASH_SIZE, m_frame); int used_width = 0, used_height = 0; @@ -4197,9 +4199,9 @@ bool wxAuiManager::DoEndResizeAction(wxMouseEvent& event) int dock_pixels = 0; int new_pixsize = 0; - int caption_size = pane.window->FromDIP(m_art->GetMetric(wxAUI_DOCKART_CAPTION_SIZE)); - int pane_borderSize = pane.window->FromDIP(m_art->GetMetric(wxAUI_DOCKART_PANE_BORDER_SIZE)); - int sashSize = pane.window->FromDIP(m_art->GetMetric(wxAUI_DOCKART_SASH_SIZE)); + int caption_size = m_art->GetMetricForWindow(wxAUI_DOCKART_CAPTION_SIZE, pane.window); + int pane_borderSize = m_art->GetMetricForWindow(wxAUI_DOCKART_PANE_BORDER_SIZE, pane.window); + int sashSize = m_art->GetMetricForWindow(wxAUI_DOCKART_SASH_SIZE, pane.window); wxPoint new_pos(event.m_x - m_actionOffset.x, event.m_y - m_actionOffset.y); diff --git a/src/aui/tabart.cpp b/src/aui/tabart.cpp index d7dc57bd23bc..9446ff70829a 100644 --- a/src/aui/tabart.cpp +++ b/src/aui/tabart.cpp @@ -664,7 +664,7 @@ int wxAuiGenericTabArt::GetBorderWidth(wxWindow* wnd) { wxAuiDockArt* art = mgr->GetArtProvider(); if (art) - return wnd->FromDIP(art->GetMetric(wxAUI_DOCKART_PANE_BORDER_SIZE)); + return art->GetMetricForWindow(wxAUI_DOCKART_PANE_BORDER_SIZE, wnd); } return 1; } @@ -1259,7 +1259,7 @@ int wxAuiSimpleTabArt::GetBorderWidth(wxWindow* wnd) { wxAuiDockArt* art = mgr->GetArtProvider(); if (art) - return wnd->FromDIP(art->GetMetric(wxAUI_DOCKART_PANE_BORDER_SIZE)); + return art->GetMetricForWindow(wxAUI_DOCKART_PANE_BORDER_SIZE, wnd); } return 1; } diff --git a/src/common/datavcmn.cpp b/src/common/datavcmn.cpp index b5580d432106..98a1edcc5513 100644 --- a/src/common/datavcmn.cpp +++ b/src/common/datavcmn.cpp @@ -52,11 +52,13 @@ class wxDataViewEditorCtrlEvtHandler: public wxEvtHandler { m_editorCtrl = editor; m_owner = owner; - m_finished = false; + m_focusOnIdle = false; } +#if defined(__WXGTK__) && !defined(wxHAS_GENERIC_DATAVIEWCTRL) void SetFocusOnIdle( bool focus = true ) { m_focusOnIdle = focus; } +#endif protected: void OnChar( wxKeyEvent &event ); diff --git a/src/common/intl.cpp b/src/common/intl.cpp index 6dfc24d10893..b96c11b527de 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -621,6 +621,7 @@ wxFontEncoding wxLocale::GetSystemEncoding() case 65001: return wxFONTENCODING_UTF8; } + return wxFONTENCODING_SYSTEM; #elif defined(__WXMAC__) CFStringEncoding encoding = 0; encoding = CFStringGetSystemEncoding(); @@ -645,11 +646,11 @@ wxFontEncoding wxLocale::GetSystemEncoding() { return enc; } - //else: return wxFONTENCODING_SYSTEM below } -#endif // Win32/Unix - return wxFONTENCODING_SYSTEM; +#else + return wxFONTENCODING_SYSTEM; +#endif } /* static */ diff --git a/src/common/quantize.cpp b/src/common/quantize.cpp index bce83e102f77..89d3f481db12 100644 --- a/src/common/quantize.cpp +++ b/src/common/quantize.cpp @@ -83,12 +83,14 @@ typedef struct { typedef j_decompress *j_decompress_ptr; struct jpeg_color_quantizer { + wxCLANG_WARNING_SUPPRESS(unused-member-function) JMETHOD(void, start_pass, (j_decompress_ptr cinfo, bool is_pre_scan)); JMETHOD(void, color_quantize, (j_decompress_ptr cinfo, JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows)); JMETHOD(void, finish_pass, (j_decompress_ptr cinfo)); JMETHOD(void, new_color_map, (j_decompress_ptr cinfo)); + wxCLANG_WARNING_RESTORE(unused-member-function) }; diff --git a/src/common/webrequest_curl.cpp b/src/common/webrequest_curl.cpp index adba405fc4bb..3c475c4a1f4e 100644 --- a/src/common/webrequest_curl.cpp +++ b/src/common/webrequest_curl.cpp @@ -1026,9 +1026,9 @@ void SourceSocketPoller::SendEvent(curl_socket_t sock, int result) { // Check if we have any sockets to clean up and do it now, it should be // safe. - for ( auto sock : m_socketsToCleanUp ) + for ( auto sck : m_socketsToCleanUp ) { - StopPolling(sock); + StopPolling(sck); } m_socketsToCleanUp.clear(); diff --git a/src/common/wxcrt.cpp b/src/common/wxcrt.cpp index 3c319b0c6f95..eeba6267bf1f 100644 --- a/src/common/wxcrt.cpp +++ b/src/common/wxcrt.cpp @@ -810,6 +810,7 @@ wxCRT_StrftimeW(wchar_t *s, size_t maxsize, const wchar_t *fmt, const struct tm } #endif // !wxCRT_StrftimeW +#if !defined(wxCRT_StrtoullA) || !defined(wxCRT_StrtoullW) template static wxULongLong_t wxCRT_StrtoullBase(const T* nptr, T** endptr, int base, T* sign) @@ -923,7 +924,9 @@ static wxULongLong_t wxCRT_DoStrtoull(const T* nptr, T** endptr, int base) return uval; } +#endif // !defined(wxCRT_StrtoullA) || !defined(wxCRT_StrtoullW) +#if !defined(wxCRT_StrtollA) || !defined(wxCRT_StrtollW) template static wxLongLong_t wxCRT_DoStrtoll(const T* nptr, T** endptr, int base) { @@ -953,6 +956,7 @@ static wxLongLong_t wxCRT_DoStrtoll(const T* nptr, T** endptr, int base) return val; } +#endif // !defined(wxCRT_StrtollA) || !defined(wxCRT_StrtollW) #ifndef wxCRT_StrtollA wxLongLong_t wxCRT_StrtollA(const char* nptr, char** endptr, int base) @@ -1059,10 +1063,11 @@ static bool wxIsLocaleUtf8() // because a) it may be unavailable in some builds and b) has slightly // different semantics (default locale instead of current) + const char* charset; #if defined(HAVE_LANGINFO_H) && defined(CODESET) // GNU libc provides current character set this way (this conforms to // Unix98) - const char *charset = nl_langinfo(CODESET); + charset = nl_langinfo(CODESET); if ( charset && wxIsCharsetUtf8(charset) ) return true; #endif // HAVE_LANGINFO_H @@ -1079,7 +1084,7 @@ static bool wxIsLocaleUtf8() // any other locale can also use UTF-8 encoding if it's explicitly // specified - const char* charset = strrchr(lc_ctype, '.'); + charset = strrchr(lc_ctype, '.'); if ( charset && wxIsCharsetUtf8(charset + 1) ) return true; } diff --git a/src/generic/buttonbar.cpp b/src/generic/buttonbar.cpp index dfca3fe452e4..d4d46b180a31 100644 --- a/src/generic/buttonbar.cpp +++ b/src/generic/buttonbar.cpp @@ -543,10 +543,10 @@ void wxButtonToolBar::OnLeftUp(wxMouseEvent& event) wxButtonToolBarTool* tool = (wxButtonToolBarTool*) FindToolForPosition(event.GetX(), event.GetY()); if (tool && tool->GetButton() && (event.GetY() > (tool->m_y + tool->GetButton()->GetSize().y))) { - wxCommandEvent event(wxEVT_BUTTON, tool->GetId()); - event.SetEventObject(tool->GetButton()); - if (!GetEventHandler()->ProcessEvent(event)) - event.Skip(); + wxCommandEvent evt(wxEVT_BUTTON, tool->GetId()); + evt.SetEventObject(tool->GetButton()); + if (!GetEventHandler()->ProcessEvent(evt)) + evt.Skip(); } } } diff --git a/src/generic/choicbkg.cpp b/src/generic/choicbkg.cpp index 8400fc1e3191..6d02c1848aaa 100644 --- a/src/generic/choicbkg.cpp +++ b/src/generic/choicbkg.cpp @@ -106,7 +106,7 @@ wxChoicebook::Create(wxWindow *parent, bool wxChoicebook::SetPageText(size_t n, const wxString& strText) { - GetChoiceCtrl()->SetString(n, strText); + GetChoiceCtrl()->SetString(n, RemoveMnemonics(strText)); return true; } @@ -178,7 +178,7 @@ wxChoicebook::InsertPage(size_t n, if ( !wxBookCtrlBase::InsertPage(n, page, text, bSelect, imageId) ) return false; - GetChoiceCtrl()->Insert(text, n); + GetChoiceCtrl()->Insert(RemoveMnemonics(text), n); // if the inserted page is before the selected one, we must update the // index of the selected page diff --git a/src/generic/listbkg.cpp b/src/generic/listbkg.cpp index 22891be71125..ea146dbc5dba 100644 --- a/src/generic/listbkg.cpp +++ b/src/generic/listbkg.cpp @@ -219,7 +219,7 @@ void wxListbook::UpdateSize() bool wxListbook::SetPageText(size_t n, const wxString& strText) { - GetListView()->SetItemText(n, strText); + GetListView()->SetItemText(n, RemoveMnemonics(strText)); return true; } @@ -320,7 +320,7 @@ wxListbook::InsertPage(size_t n, if ( !wxBookCtrlBase::InsertPage(n, page, text, bSelect, imageId) ) return false; - GetListView()->InsertItem(n, text, imageId); + GetListView()->InsertItem(n, RemoveMnemonics(text), imageId); // if the inserted page is before the selected one, we must update the // index of the selected page diff --git a/src/generic/preferencesg.cpp b/src/generic/preferencesg.cpp index 77a548672834..895070b5239b 100644 --- a/src/generic/preferencesg.cpp +++ b/src/generic/preferencesg.cpp @@ -67,6 +67,7 @@ class wxGenericPrefsDialog : public wxDialog m_notebook->AddPage(win, page->GetName()); } +#ifndef wxHAS_PREF_EDITOR_MODELESS int GetSelectedPage() const { return m_notebook->GetSelection(); @@ -76,6 +77,7 @@ class wxGenericPrefsDialog : public wxDialog { m_notebook->ChangeSelection(page); } +#endif // !wxHAS_PREF_EDITOR_MODELESS bool ShouldPreventAppExit() const override { diff --git a/src/gtk/bitmap.cpp b/src/gtk/bitmap.cpp index 5f82496ed285..1a14d4c9129b 100644 --- a/src/gtk/bitmap.cpp +++ b/src/gtk/bitmap.cpp @@ -757,12 +757,12 @@ bool wxBitmap::CreateFromImageAsPixbuf(const wxImage& image) if ( image.HasMask() ) { const size_t out_size = size_t((width + 7) / 8) * unsigned(height); - wxByte* out = new wxByte[out_size]; + out = new wxByte[out_size]; memset(out, 0xff, out_size); const wxByte r_mask = image.GetMaskRed(); const wxByte g_mask = image.GetMaskGreen(); const wxByte b_mask = image.GetMaskBlue(); - const wxByte* in = image.GetData(); + in = image.GetData(); unsigned bit_index = 0; for (int y = 0; y < height; y++) { diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index 8a901e88cf88..4e41c4fa570b 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -4354,12 +4354,12 @@ wxGtkTreeModelNode *wxDataViewCtrlInternal::FindNode( const wxDataViewItem &item } wxGtkTreeModelNode * node = m_root; - for ( const auto& item : list ) + for ( const auto& itm : list ) { wxGtkTreeModelNode* next = nullptr; for (auto child : node->GetNodes()) { - if (child->GetItem() == item) + if (child->GetItem() == itm) { next = child; break; diff --git a/src/gtk/notebook.cpp b/src/gtk/notebook.cpp index eae490c0fe2e..1a3897d30087 100644 --- a/src/gtk/notebook.cpp +++ b/src/gtk/notebook.cpp @@ -16,7 +16,6 @@ #ifndef WX_PRECOMP #include "wx/intl.h" #include "wx/log.h" - #include "wx/utils.h" #include "wx/msgdlg.h" #include "wx/bitmap.h" #endif @@ -47,6 +46,7 @@ class wxGtkNotebookPage GtkWidget* m_label; GtkWidget* m_image; int m_imageIndex; + wxString m_text; }; @@ -215,8 +215,7 @@ wxString wxNotebook::GetPageText( size_t page ) const { wxCHECK_MSG(page < GetPageCount(), wxEmptyString, "invalid notebook index"); - GtkLabel* label = GTK_LABEL(GetNotebookPage(page)->m_label); - return wxString::FromUTF8(gtk_label_get_text(label)); + return GetNotebookPage(page)->m_text; } int wxNotebook::GetPageImage( size_t page ) const @@ -269,8 +268,11 @@ bool wxNotebook::SetPageText( size_t page, const wxString &text ) { wxCHECK_MSG(page < GetPageCount(), false, "invalid notebook index"); - GtkLabel* label = GTK_LABEL(GetNotebookPage(page)->m_label); - gtk_label_set_text(label, text.utf8_str()); + wxGtkNotebookPage* const pageData = GetNotebookPage(page); + pageData->m_text = text; + + GtkLabel* label = GTK_LABEL(pageData->m_label); + gtk_label_set_text(label, RemoveMnemonics(text).utf8_str()); return true; } @@ -500,8 +502,11 @@ bool wxNotebook::InsertPage( size_t position, pageData->m_image = nullptr; } - /* set the label text */ - pageData->m_label = gtk_label_new(wxStripMenuCodes(text).utf8_str()); + // Set the label text: we don't support mnemonics here, but we still need + // to strip them if there are any. Also store the original text to be able + // to return it from GetPageText() later. + pageData->m_text = text; + pageData->m_label = gtk_label_new(RemoveMnemonics(text).utf8_str()); if (m_windowStyle & wxBK_LEFT) gtk_label_set_angle(GTK_LABEL(pageData->m_label), 90); diff --git a/src/gtk/tooltip.cpp b/src/gtk/tooltip.cpp index 20555e18171a..4d9f716771c5 100644 --- a/src/gtk/tooltip.cpp +++ b/src/gtk/tooltip.cpp @@ -80,10 +80,8 @@ void wxToolTip::Enable( bool flag ) if (wx_is_at_least_gtk2(12)) { GtkSettings* settings = gtk_settings_get_default(); - wxGCC_WARNING_SUPPRESS(deprecated-declarations) if (settings) - gtk_settings_set_long_property(settings, "gtk-enable-tooltips", flag, nullptr); - wxGCC_WARNING_RESTORE() + g_object_set(settings, "gtk-enable-tooltips", flag, nullptr); } else #endif @@ -110,10 +108,8 @@ void wxToolTip::SetDelay( long msecs ) if (wx_is_at_least_gtk2(12)) { GtkSettings* settings = gtk_settings_get_default(); - wxGCC_WARNING_SUPPRESS(deprecated-declarations) if (settings) - gtk_settings_set_long_property(settings, "gtk-tooltip-timeout", msecs, nullptr); - wxGCC_WARNING_RESTORE() + g_object_set(settings, "gtk-tooltip-timeout", int(msecs), nullptr); } else #endif diff --git a/src/msw/fswatcher.cpp b/src/msw/fswatcher.cpp index 11fd4a9652f0..3db4632204c6 100644 --- a/src/msw/fswatcher.cpp +++ b/src/msw/fswatcher.cpp @@ -319,24 +319,15 @@ void wxIOCPThread::ProcessNativeEvents(wxVector& events) wxLogTrace( wxTRACE_FSWATCHER, "[iocp] %s", FileNotifyInformationToString(e)); - int nativeFlags = e.Action; - int flags = Native2WatcherFlags(nativeFlags); - if (flags & wxFSW_EVENT_WARNING || flags & wxFSW_EVENT_ERROR) - { - wxFileSystemWatcherEvent - event(flags, - flags & wxFSW_EVENT_ERROR ? wxFSW_WARNING_NONE - : wxFSW_WARNING_GENERAL); - SendEvent(event); - } - // filter out ignored events and those not asked for. - // we never filter out warnings or exceptions - else if ((flags == 0) || !(flags & watch->GetFlags())) + const int flags = Native2WatcherFlags(e.Action); + // filter out ignored events (with flags == 0) and those not asked for. + if (!(flags & watch->GetFlags())) { return; } + // rename case - else if (nativeFlags == FILE_ACTION_RENAMED_OLD_NAME) + if (e.Action == FILE_ACTION_RENAMED_OLD_NAME) { wxFileName oldpath = GetEventPath(*watch, e); wxFileName newpath; @@ -387,8 +378,6 @@ int wxIOCPThread::Native2WatcherFlags(int flags) // ignored as it should always be matched with ***_OLD_NAME { FILE_ACTION_RENAMED_NEW_NAME, 0 }, - // ignore invalid event - { 0, 0 }, }; for (unsigned int i=0; i < WXSIZEOF(flag_mapping); ++i) { @@ -396,9 +385,9 @@ int wxIOCPThread::Native2WatcherFlags(int flags) return flag_mapping[i][1]; } - // never reached - wxFAIL_MSG(wxString::Format("Unknown file notify change %u", flags)); - return -1; + // We can get unknown values here, see #18953, just ignore them because we + // don't know what else to do with them. + return 0; } wxString wxIOCPThread::FileNotifyInformationToString( diff --git a/src/msw/volume.cpp b/src/msw/volume.cpp index 05f834a00927..5b4f14ca685c 100644 --- a/src/msw/volume.cpp +++ b/src/msw/volume.cpp @@ -235,7 +235,6 @@ static void BuildListFromNN(wxArrayString& list, NETRESOURCE* pResSrc, unsigned flagsSet, unsigned flagsUnset) { HANDLE hEnum; - int rc; //----------------------------------------------- // Scope may be all drives or all mounted drives. @@ -249,13 +248,14 @@ static void BuildListFromNN(wxArrayString& list, NETRESOURCE* pResSrc, // Containers cause a recursive call to this function for their own // enumeration. //---------------------------------------------------------------------- - if (rc = s_pWNetOpenEnum(scope, RESOURCETYPE_DISK, 0, pResSrc, &hEnum), rc == NO_ERROR) + if (s_pWNetOpenEnum(scope, RESOURCETYPE_DISK, 0, pResSrc, &hEnum) == NO_ERROR) { DWORD count = 1; DWORD size = 256; NETRESOURCE* pRes = (NETRESOURCE*)malloc(size); memset(pRes, 0, sizeof(NETRESOURCE)); - while (rc = s_pWNetEnumResource(hEnum, &count, pRes, &size), rc == NO_ERROR || rc == ERROR_MORE_DATA) + int rc; + while ((rc = s_pWNetEnumResource(hEnum, &count, pRes, &size)) == NO_ERROR || rc == ERROR_MORE_DATA) { if (s_cancelSearch) break; @@ -366,9 +366,8 @@ static bool BuildRemoteList(wxArrayString& list, NETRESOURCE* pResSrc, { int compare; - while (compare = - wxStricmp(list[iList].c_str(), mounted[iMounted].c_str()), - compare > 0 && iList >= 0) + while ((compare = wxStricmp(list[iList].c_str(), mounted[iMounted].c_str())) > 0 + && iList >= 0) { iList--; } @@ -447,7 +446,7 @@ wxArrayString wxFSVolumeBase::GetVolumes(int flagsSet, int flagsUnset) // The returned list will be sorted alphabetically. We don't pass // our in since we don't want to change to order of the local drives. wxArrayString nn; - if (BuildRemoteList(nn, 0, flagsSet, flagsUnset)) + if (BuildRemoteList(nn, nullptr, flagsSet, flagsUnset)) { for (size_t idx = 0; idx < nn.GetCount(); idx++) list.Add(nn[idx]); diff --git a/src/osx/carbon/dcprint.cpp b/src/osx/carbon/dcprint.cpp index 2b50d799ec14..3dc808fcc9c0 100644 --- a/src/osx/carbon/dcprint.cpp +++ b/src/osx/carbon/dcprint.cpp @@ -307,9 +307,9 @@ bool wxPrinterDCImpl::StartDoc( const wxString& message ) m_ok = m_nativePrinterDC->IsOk() ; if ( !m_ok ) { - wxString message ; - message.Printf( wxT("Print Error %u"), m_nativePrinterDC->GetStatus() ) ; - wxMessageDialog dialog( nullptr , message , wxEmptyString, wxICON_HAND | wxOK) ; + wxString msg; + msg.Printf("Print Error %u", m_nativePrinterDC->GetStatus()); + wxMessageDialog dialog(nullptr, msg, wxString(), wxICON_HAND | wxOK); dialog.ShowModal(); } diff --git a/src/osx/carbon/graphics.cpp b/src/osx/carbon/graphics.cpp index 453d5737ccfb..3a93aa75f408 100644 --- a/src/osx/carbon/graphics.cpp +++ b/src/osx/carbon/graphics.cpp @@ -2965,8 +2965,9 @@ wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateContext( const wxMemoryDC& { #ifdef __WXMAC__ return new wxMacCoreGraphicsContext(this, dc); -#endif +#else return nullptr; +#endif } #if wxUSE_PRINTING_ARCHITECTURE @@ -2974,8 +2975,9 @@ wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateContext( const wxPrinterDC& { #ifdef __WXMAC__ return new wxMacCoreGraphicsContext(this, dc); -#endif +#else return nullptr; +#endif } #endif diff --git a/src/osx/cocoa/notebook.mm b/src/osx/cocoa/notebook.mm index 53c65aa53004..a0a455478f8e 100644 --- a/src/osx/cocoa/notebook.mm +++ b/src/osx/cocoa/notebook.mm @@ -224,7 +224,7 @@ wxInt32 GetValue() const override return [slf indexOfTabViewItem:selectedItem]+1; } - void SetMaximum( wxInt32 maximum ) override + void SetupTabs( const wxNotebook& notebook) override { wxNSTabView* slf = (wxNSTabView*) m_osxView; int cocoacount = [slf numberOfTabViewItems ]; @@ -232,11 +232,23 @@ void SetMaximum( wxInt32 maximum ) override wxTabViewController* controller = [slf delegate]; [slf setDelegate:nil]; + // Update the existing pages in case their label or image changed. + const int maximum = notebook.GetPageCount(); + for ( int i = 0; i < wxMin(maximum, cocoacount); ++i ) + { + SetupTabItem(notebook, i, + [(wxNSTabView*) m_osxView tabViewItemAtIndex:i]); + + } + + // Next also add new pages or delete the no more existing ones. if ( maximum > cocoacount ) { for ( int i = cocoacount ; i < maximum ; ++i ) { NSTabViewItem* item = [[WXCTabViewImageItem alloc] init]; + SetupTabItem(notebook, i, item); + [slf addTabViewItem:item]; [item release]; } @@ -252,28 +264,6 @@ void SetMaximum( wxInt32 maximum ) override [slf setDelegate:controller]; } - void SetupTabs( const wxNotebook& notebook) override - { - int pcount = notebook.GetPageCount(); - - SetMaximum( pcount ); - - for ( int i = 0 ; i < pcount ; ++i ) - { - wxNotebookPage* page = notebook.GetPage(i); - NSTabViewItem* item = [(wxNSTabView*) m_osxView tabViewItemAtIndex:i]; - [item setView:page->GetHandle() ]; - wxCFStringRef cf( page->GetLabel() ); - [item setLabel:cf.AsNSString()]; - - const wxBitmapBundle bitmap = notebook.GetPageBitmapBundle(i); - if ( bitmap.IsOk() ) - { - [(WXCTabViewImageItem*) item setImage: wxOSXGetImageFromBundle(bitmap)]; - } - } - } - int TabHitTest(const wxPoint & pt, long* flags) override { int retval = wxNOT_FOUND; @@ -295,6 +285,21 @@ int TabHitTest(const wxPoint & pt, long* flags) override return retval; } + +private: + void SetupTabItem(const wxNotebook& notebook, int i, NSTabViewItem* item) + { + wxNotebookPage* page = notebook.GetPage(i); + [item setView:page->GetHandle() ]; + wxCFStringRef cf( wxControl::RemoveMnemonics(notebook.GetPageText(i)) ); + [item setLabel:cf.AsNSString()]; + + const wxBitmapBundle bitmap = notebook.GetPageBitmapBundle(i); + if ( bitmap.IsOk() ) + { + [(WXCTabViewImageItem*) item setImage: wxOSXGetImageFromBundle(bitmap)]; + } + } }; diff --git a/src/osx/combobox_osx.cpp b/src/osx/combobox_osx.cpp index 2fc1b35da5e8..96d40380d824 100644 --- a/src/osx/combobox_osx.cpp +++ b/src/osx/combobox_osx.cpp @@ -260,10 +260,10 @@ void wxComboBox::OnChar(wxKeyEvent& event) case WXK_NUMPAD_ENTER: if (m_windowStyle & wxTE_PROCESS_ENTER) { - wxCommandEvent event(wxEVT_TEXT_ENTER, m_windowId); - event.SetEventObject(this); - event.SetString(GetValue()); - if (HandleWindowEvent(event)) + wxCommandEvent evt(wxEVT_TEXT_ENTER, m_windowId); + evt.SetEventObject(this); + evt.SetString(GetValue()); + if (HandleWindowEvent(evt)) return; } @@ -274,9 +274,9 @@ void wxComboBox::OnChar(wxKeyEvent& event) wxButton *def = wxDynamicCast(tlw->GetDefaultItem(), wxButton); if (def && def->IsEnabled()) { - wxCommandEvent event(wxEVT_BUTTON, def->GetId()); - event.SetEventObject(def); - def->Command(event); + wxCommandEvent evt(wxEVT_BUTTON, def->GetId()); + evt.SetEventObject(def); + def->Command(evt); return; } } diff --git a/src/osx/core/bitmap.cpp b/src/osx/core/bitmap.cpp index 7b21bc189343..a696714196b9 100644 --- a/src/osx/core/bitmap.cpp +++ b/src/osx/core/bitmap.cpp @@ -1198,7 +1198,7 @@ void wxBitmap::InitFromImage(const wxImage& image, int depth, double scale) y++) { unsigned char * destination = destinationRowStart; - unsigned char * destinationMask = destinationMaskRowStart; + destinationMask = destinationMaskRowStart; for (int x = 0; x < width; x++) { if ( hasMask ) diff --git a/src/osx/notebook_osx.cpp b/src/osx/notebook_osx.cpp index c0aebcf9494b..0f5dbb851fd1 100644 --- a/src/osx/notebook_osx.cpp +++ b/src/osx/notebook_osx.cpp @@ -118,9 +118,11 @@ bool wxNotebook::SetPageText(size_t nPage, const wxString& strText) { wxCHECK_MSG( IS_VALID_PAGE(nPage), false, wxT("SetPageText: invalid notebook page") ); - wxNotebookPage *page = m_pages[nPage]; - page->SetLabel(wxStripMenuCodes(strText)); - MacSetupTabs(); + if ( m_pagesData[nPage].text != strText ) + { + m_pagesData[nPage].text = strText; + MacSetupTabs(); + } return true; } @@ -129,16 +131,14 @@ wxString wxNotebook::GetPageText(size_t nPage) const { wxCHECK_MSG( IS_VALID_PAGE(nPage), wxEmptyString, wxT("GetPageText: invalid notebook page") ); - wxNotebookPage *page = m_pages[nPage]; - - return page->GetLabel(); + return m_pagesData[nPage].text; } int wxNotebook::GetPageImage(size_t nPage) const { wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("GetPageImage: invalid notebook page") ); - return m_images[nPage]; + return m_pagesData[nPage].image; } bool wxNotebook::SetPageImage(size_t nPage, int nImage) @@ -148,12 +148,12 @@ bool wxNotebook::SetPageImage(size_t nPage, int nImage) wxCHECK_MSG( HasImageList() && nImage < GetImageList()->GetImageCount(), false, wxT("SetPageImage: invalid image index") ); - if ( nImage != m_images[nPage] ) + if ( nImage != m_pagesData[nPage].image ) { // if the item didn't have an icon before or, on the contrary, did have // it but has lost it now, its size will change - but if the icon just // changes, it won't - m_images[nPage] = nImage; + m_pagesData[nPage].image = nImage; MacSetupTabs() ; } @@ -173,7 +173,7 @@ wxNotebookPage* wxNotebook::DoRemovePage(size_t nPage) wxNotebookPage* page = m_pages[nPage] ; m_pages.erase(m_pages.begin() + nPage); - m_images.RemoveAt(nPage); + m_pagesData.erase(m_pagesData.begin() + nPage); MacSetupTabs(); @@ -200,7 +200,7 @@ bool wxNotebook::DeleteAllPages() { wxBookCtrlBase::DeleteAllPages(); - m_images.clear(); + m_pagesData.clear(); MacSetupTabs(); return true; @@ -221,9 +221,7 @@ bool wxNotebook::InsertPage(size_t nPage, // don't show pages by default (we'll need to adjust their size first) pPage->Show( false ) ; - pPage->SetLabel( wxStripMenuCodes(strText) ); - - m_images.Insert( imageId, nPage ); + m_pagesData.insert( m_pagesData.begin() + nPage, {strText, imageId} ); MacSetupTabs(); diff --git a/src/osx/textctrl_osx.cpp b/src/osx/textctrl_osx.cpp index 463f6fd620a5..3f455a3deb49 100644 --- a/src/osx/textctrl_osx.cpp +++ b/src/osx/textctrl_osx.cpp @@ -471,10 +471,10 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) case WXK_NUMPAD_ENTER: if (m_windowStyle & wxTE_PROCESS_ENTER) { - wxCommandEvent event(wxEVT_TEXT_ENTER, m_windowId); - event.SetEventObject( this ); - event.SetString( GetValue() ); - if ( HandleWindowEvent(event) ) + wxCommandEvent evt(wxEVT_TEXT_ENTER, m_windowId); + evt.SetEventObject(this); + evt.SetString(GetValue()); + if (HandleWindowEvent(evt)) return; } @@ -486,9 +486,9 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) wxButton *def = wxDynamicCast(tlw->GetDefaultItem(), wxButton); if ( def && def->IsEnabled() ) { - wxCommandEvent event(wxEVT_BUTTON, def->GetId() ); - event.SetEventObject(def); - def->Command(event); + wxCommandEvent evt(wxEVT_BUTTON, def->GetId()); + evt.SetEventObject(def); + def->Command(evt); return ; } diff --git a/src/qt/accel.cpp b/src/qt/accel.cpp index 05af3ad575c5..afdfdecf6b6e 100644 --- a/src/qt/accel.cpp +++ b/src/qt/accel.cpp @@ -89,7 +89,7 @@ wxObjectRefData *wxAcceleratorTable::CreateRefData() const wxObjectRefData *wxAcceleratorTable::CloneRefData(const wxObjectRefData *data) const { - return new wxAccelRefData(*(wxAccelRefData *)data); + return new wxAccelRefData(*static_cast(data)); } bool wxAcceleratorTable::IsOk() const diff --git a/src/qt/brush.cpp b/src/qt/brush.cpp index 53877420a2c8..082341e060cb 100644 --- a/src/qt/brush.cpp +++ b/src/qt/brush.cpp @@ -51,7 +51,6 @@ static Qt::BrushStyle ConvertBrushStyle(wxBrushStyle style) case wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE: case wxBRUSHSTYLE_STIPPLE_MASK: return Qt::TexturePattern; - break; } return Qt::SolidPattern; } @@ -226,5 +225,5 @@ wxGDIRefData *wxBrush::CreateGDIRefData() const wxGDIRefData *wxBrush::CloneGDIRefData(const wxGDIRefData *data) const { - return new wxBrushRefData(*(wxBrushRefData *)data); + return new wxBrushRefData(*static_cast(data)); } diff --git a/src/qt/cursor.cpp b/src/qt/cursor.cpp index 9a69c45d57f8..5d81e2386da7 100644 --- a/src/qt/cursor.cpp +++ b/src/qt/cursor.cpp @@ -179,5 +179,5 @@ wxGDIRefData *wxCursor::CreateGDIRefData() const wxGDIRefData *wxCursor::CloneGDIRefData(const wxGDIRefData *data) const { - return new wxCursorRefData(*(wxCursorRefData *)data); + return new wxCursorRefData(*static_cast(data)); } diff --git a/src/qt/font.cpp b/src/qt/font.cpp index 768a1955d1ed..6b979a5b33fa 100644 --- a/src/qt/font.cpp +++ b/src/qt/font.cpp @@ -366,7 +366,7 @@ wxGDIRefData *wxFont::CreateGDIRefData() const wxGDIRefData *wxFont::CloneGDIRefData(const wxGDIRefData *data) const { - return new wxFontRefData(*(wxFontRefData *)data); + return new wxFontRefData(*static_cast(data)); } QFont wxFont::GetHandle() const diff --git a/src/qt/pen.cpp b/src/qt/pen.cpp index 7fee1726182c..ba9ed56c5050 100644 --- a/src/qt/pen.cpp +++ b/src/qt/pen.cpp @@ -407,7 +407,7 @@ int wxPen::GetDashes(wxDash **ptr) const { wxCHECK_MSG( IsOk(), -1, "invalid pen" ); - *ptr = (wxDash *)((wxPenRefData *)m_refData)->m_dashes; + *ptr = const_cast(((wxPenRefData*)m_refData)->m_dashes); return ((wxPenRefData *)m_refData)->m_dashesSize; } @@ -423,5 +423,5 @@ wxGDIRefData *wxPen::CreateGDIRefData() const wxGDIRefData *wxPen::CloneGDIRefData(const wxGDIRefData *data) const { - return new wxPenRefData(*(wxPenRefData *)data); + return new wxPenRefData(*static_cast(data)); } diff --git a/src/qt/region.cpp b/src/qt/region.cpp index d529c97d1101..9f7d62becfed 100644 --- a/src/qt/region.cpp +++ b/src/qt/region.cpp @@ -186,7 +186,7 @@ wxGDIRefData *wxRegion::CreateGDIRefData() const wxGDIRefData *wxRegion::CloneGDIRefData(const wxGDIRefData *data) const { - return new wxRegionRefData(*(wxRegionRefData *)data); + return new wxRegionRefData(*static_cast(data)); } bool wxRegion::DoIsEqual(const wxRegion& region) const diff --git a/src/qt/textctrl.cpp b/src/qt/textctrl.cpp index 626a9da54891..445a78847d32 100644 --- a/src/qt/textctrl.cpp +++ b/src/qt/textctrl.cpp @@ -263,7 +263,7 @@ class wxQtMultiLineEdit : public wxQtEdit virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long* pos) const override { - auto qtEdit = static_cast(m_edit); + const auto qtEdit = static_cast(m_edit); auto cursor = qtEdit->cursorForPosition( wxQtConvertPoint(pt) ); auto curRect = qtEdit->cursorRect(cursor); @@ -589,7 +589,7 @@ class wxQtSingleLineEdit : public wxQtEdit virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const override { - auto qtEdit = static_cast(m_edit); + const auto qtEdit = static_cast(m_edit); auto curPos = qtEdit->cursorPositionAt( wxQtConvertPoint(pt) ); auto curRect = qtEdit->cursorRect(); diff --git a/src/qt/textentry.cpp b/src/qt/textentry.cpp index ae3752b714c0..f38f3695303c 100644 --- a/src/qt/textentry.cpp +++ b/src/qt/textentry.cpp @@ -176,8 +176,7 @@ class wxTextAutoCompleteData // The constructor associates us with the given text entry. explicit wxTextAutoCompleteData(wxTextEntry* entry, CompleterType type = CompleterType::StringCompleter) - : m_entry(entry), - m_win(entry->GetEditableWindow()) + : m_win(entry->GetEditableWindow()) { if ( m_win ) { @@ -314,9 +313,6 @@ class wxTextAutoCompleteData event.Skip(); } - // The text entry we're associated with. - wxTextEntry* const m_entry; - // The window of this text entry. wxWindow* const m_win; diff --git a/src/qt/treectrl.cpp b/src/qt/treectrl.cpp index 510b75a61c57..51f9b52475f3 100644 --- a/src/qt/treectrl.cpp +++ b/src/qt/treectrl.cpp @@ -453,7 +453,7 @@ class wxQTreeWidget : public wxQtEventSignalHandler // QT doesn't update the selection until this signal has been processed. // Deferring this event ensures that wxTreeCtrl::GetSelections() returns // the new selection in the wx event handler. - GetHandler()->CallAfter([=]() + GetHandler()->CallAfter([this]() { EmitSelectChangeEvent(wxEVT_TREE_SEL_CHANGED); }); @@ -1131,15 +1131,10 @@ wxTreeItemId wxTreeCtrl::GetNextVisible(const wxTreeItemId& item) const wxASSERT_MSG(IsVisible(item), "this item itself should be visible"); wxTreeItemId id = item; - if ( id.IsOk() ) - { - while ( id = GetNext(id), id.IsOk() ) - { - if ( IsVisible(id) ) - return id; - } - } - return wxTreeItemId(); + do + id = GetNext(id); + while (id.IsOk() && !IsVisible(id)); + return id; } wxTreeItemId wxTreeCtrl::GetPrevVisible(const wxTreeItemId& item) const diff --git a/src/unix/dlunix.cpp b/src/unix/dlunix.cpp index e55db5273c4a..5869d7192e29 100644 --- a/src/unix/dlunix.cpp +++ b/src/unix/dlunix.cpp @@ -222,9 +222,9 @@ void* wxDynamicLibrary::GetModuleFromAddress(const void* addr, wxString* path) #else wxUnusedVar(addr); wxUnusedVar(path); -#endif // HAVE_DLADDR return nullptr; +#endif // HAVE_DLADDR } diff --git a/tests/controls/bookctrlbasetest.cpp b/tests/controls/bookctrlbasetest.cpp index 37cb50520ece..cd06fd2da67e 100644 --- a/tests/controls/bookctrlbasetest.cpp +++ b/tests/controls/bookctrlbasetest.cpp @@ -40,7 +40,7 @@ void BookCtrlBaseTestCase::AddPanels() m_panel2 = new wxPanel(base); m_panel3 = new wxPanel(base); - base->AddPage(m_panel1, "Panel 1", false, 0); + base->AddPage(m_panel1, "Panel &1", false, 0); base->AddPage(m_panel2, "Panel 2", false, 1); base->AddPage(m_panel3, "Panel 3", false, 2); } @@ -74,15 +74,22 @@ void BookCtrlBaseTestCase::Text() { wxBookCtrlBase * const base = GetBase(); - CPPUNIT_ASSERT_EQUAL("Panel 1", base->GetPageText(0)); + const wxString expected(HasBrokenMnemonics() ? "Panel 1" : "Panel &1"); + CPPUNIT_ASSERT_EQUAL(expected, base->GetPageText(0)); base->SetPageText(1, "Some other string"); CPPUNIT_ASSERT_EQUAL("Some other string", base->GetPageText(1)); - base->SetPageText(2, "string with /nline break"); + base->SetPageText(2, "string with\nline break"); - CPPUNIT_ASSERT_EQUAL("string with /nline break", base->GetPageText(2)); + CPPUNIT_ASSERT_EQUAL("string with\nline break", base->GetPageText(2)); + + if ( !HasBrokenMnemonics() ) + { + base->SetPageText(0, "With &mnemonic"); + CPPUNIT_ASSERT_EQUAL("With &mnemonic", base->GetPageText(0)); + } } void BookCtrlBaseTestCase::PageManagement() diff --git a/tests/controls/bookctrlbasetest.h b/tests/controls/bookctrlbasetest.h index 6fb3ed1476d8..07e07f034e72 100644 --- a/tests/controls/bookctrlbasetest.h +++ b/tests/controls/bookctrlbasetest.h @@ -26,6 +26,10 @@ class BookCtrlBaseTestCase virtual wxEventType GetChangingEvent() const = 0; + // Some wxBookCtrlBase-derived classes strip mnemonics and don't return + // them from their GetPageText(), allow them to just return true from here. + virtual bool HasBrokenMnemonics() const { return false; } + // this should be inserted in the derived class CPPUNIT_TEST_SUITE // definition to run all wxBookCtrlBase tests as part of it #define wxBOOK_CTRL_BASE_TESTS() \ diff --git a/tests/controls/choicebooktest.cpp b/tests/controls/choicebooktest.cpp index 7bf72a3d622b..c7866cd031d2 100644 --- a/tests/controls/choicebooktest.cpp +++ b/tests/controls/choicebooktest.cpp @@ -36,6 +36,8 @@ class ChoicebookTestCase : public BookCtrlBaseTestCase, public CppUnit::TestCase virtual wxEventType GetChangingEvent() const override { return wxEVT_CHOICEBOOK_PAGE_CHANGING; } + virtual bool HasBrokenMnemonics() const override { return true; } + CPPUNIT_TEST_SUITE( ChoicebookTestCase ); wxBOOK_CTRL_BASE_TESTS(); CPPUNIT_TEST( Choice ); diff --git a/tests/controls/listbooktest.cpp b/tests/controls/listbooktest.cpp index e8a8ddb1e5cc..c9c7e22a1ae8 100644 --- a/tests/controls/listbooktest.cpp +++ b/tests/controls/listbooktest.cpp @@ -37,6 +37,8 @@ class ListbookTestCase : public BookCtrlBaseTestCase, public CppUnit::TestCase virtual wxEventType GetChangingEvent() const override { return wxEVT_LISTBOOK_PAGE_CHANGING; } + virtual bool HasBrokenMnemonics() const override { return true; } + CPPUNIT_TEST_SUITE( ListbookTestCase ); wxBOOK_CTRL_BASE_TESTS(); CPPUNIT_TEST( ListView );