From 036e35bf2887f4b3038eb23b4ffd0c25da09ad38 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 5 Apr 2021 16:09:34 +0200 Subject: [PATCH] Rename wxFileHistoryMenuLabelStyle to wxFileHistoryMenuPathStyle It seems useful to have the word "Path" in the name of this enum to indicate that it applies to the paths shown in the menu labels. Also rename the methods using this enum. --- include/wx/filehistory.h | 10 +++++----- interface/wx/filehistory.h | 22 +++++++++++++++------- samples/menu/menu.cpp | 6 +++--- src/common/filehistorycmn.cpp | 6 +++--- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/include/wx/filehistory.h b/include/wx/filehistory.h index f7f0183ad3..ce2a031f36 100644 --- a/include/wx/filehistory.h +++ b/include/wx/filehistory.h @@ -24,7 +24,7 @@ class WXDLLIMPEXP_FWD_CORE wxMenu; class WXDLLIMPEXP_FWD_BASE wxConfigBase; class WXDLLIMPEXP_FWD_BASE wxFileName; -enum wxFileHistoryMenuLabelStyle +enum wxFileHistoryMenuPathStyle { wxFH_HIDE_CURRENT_PATH = 0, wxFH_HIDE_ALL_PATHS = 1, @@ -67,8 +67,8 @@ public: void SetBaseId(wxWindowID baseId) { m_idBase = baseId; } wxWindowID GetBaseId() const { return m_idBase; } - void SetMenuLabelStyle(wxFileHistoryMenuLabelStyle style) { m_menuLabelStyle = style; } - wxFileHistoryMenuLabelStyle GetMenuLabelStyle() const { return m_menuLabelStyle; } + void SetMenuPathStyle(wxFileHistoryMenuPathStyle style) { m_menuPathStyle = style; } + wxFileHistoryMenuPathStyle GetMenuPathStyle() const { return m_menuPathStyle; } void RefreshLabels(); @@ -82,8 +82,8 @@ protected: // Max files to maintain size_t m_fileMaxFiles; - // Style of the labels in the menu - wxFileHistoryMenuLabelStyle m_menuLabelStyle; + // Style of the paths in the menu labels + wxFileHistoryMenuPathStyle m_menuPathStyle; private: // The ID of the first history menu item (Doesn't have to be wxID_FILE1) diff --git a/interface/wx/filehistory.h b/interface/wx/filehistory.h index 29c68fafe8..445dc16c35 100644 --- a/interface/wx/filehistory.h +++ b/interface/wx/filehistory.h @@ -6,11 +6,14 @@ ///////////////////////////////////////////////////////////////////////////// /** - Styles for the labels on menu items for wxFileHistory menus + Styles for the paths shown in wxFileHistory menus. - @since 3.1.5 + The default style is wxFH_HIDE_CURRENT_PATH, i.e. the path of the file is + only shown in the menu if it's different from the path of the first file. + + @since 3.1.5 */ -enum wxFileHistoryMenuLabelStyle +enum wxFileHistoryMenuPathStyle { /** Hide the file path if it matches the path of the first item */ wxFH_HIDE_CURRENT_PATH, @@ -32,8 +35,6 @@ enum wxFileHistoryMenuLabelStyle required in an MDI application, where the file history should appear on each MDI child menu as well as the MDI parent frame. - By default, the menu item label style will be @c wxFH_HIDE_CURRENT_PATH. - @library{wxcore} @category{docview} @@ -151,16 +152,23 @@ public: /** Set the style of the menu item labels. + By default, the menu item label style is ::wxFH_HIDE_CURRENT_PATH. + @remarks Use RefreshLabels() to update any existing menu items to the new style. @since 3.1.5 */ - void SetMenuLabelStyle(wxFileHistoryMenuLabelStyle style); + void SetMenuPathStyle(wxFileHistoryMenuPathStyle style); /** Get the current style of the menu item labels. + + Initially returns ::wxFH_HIDE_CURRENT_PATH. + + @see SetMenuPathStyle() + @since 3.1.5 */ - wxFileHistoryMenuLabelStyle GetMenuLabelStyle() const; + wxFileHistoryMenuPathStyle GetMenuPathStyle() const; }; diff --git a/samples/menu/menu.cpp b/samples/menu/menu.cpp index a32e5a3693..271bba1e3f 100644 --- a/samples/menu/menu.cpp +++ b/samples/menu/menu.cpp @@ -1394,13 +1394,13 @@ void MyFrame::OnFileHistoryStyleItem(wxCommandEvent& event) switch( event.GetId() ) { case Menu_Menu_FileHistory1: - m_fileHistory->SetMenuLabelStyle(wxFH_HIDE_CURRENT_PATH); + m_fileHistory->SetMenuPathStyle(wxFH_HIDE_CURRENT_PATH); break; case Menu_Menu_FileHistory2: - m_fileHistory->SetMenuLabelStyle(wxFH_HIDE_ALL_PATHS); + m_fileHistory->SetMenuPathStyle(wxFH_HIDE_ALL_PATHS); break; case Menu_Menu_FileHistory3: - m_fileHistory->SetMenuLabelStyle(wxFH_SHOW_FULL_PATH); + m_fileHistory->SetMenuPathStyle(wxFH_SHOW_FULL_PATH); break; } diff --git a/src/common/filehistorycmn.cpp b/src/common/filehistorycmn.cpp index b77bdf0a61..0fa0c8d303 100644 --- a/src/common/filehistorycmn.cpp +++ b/src/common/filehistorycmn.cpp @@ -70,7 +70,7 @@ wxFileHistoryBase::wxFileHistoryBase(size_t maxFiles, wxWindowID idBase) { m_fileMaxFiles = maxFiles; m_idBase = idBase; - m_menuLabelStyle = wxFH_HIDE_CURRENT_PATH; + m_menuPathStyle = wxFH_HIDE_CURRENT_PATH; } /* static */ @@ -158,12 +158,12 @@ void wxFileHistoryBase::RefreshLabels() wxString pathInMenu; - if ( m_menuLabelStyle == wxFH_HIDE_ALL_PATHS ) + if ( m_menuPathStyle == wxFH_HIDE_ALL_PATHS ) { // Only show the filename + extension and not the path pathInMenu = currFn.GetFullName(); } - else if ( ( m_menuLabelStyle == wxFH_HIDE_CURRENT_PATH ) && + else if ( ( m_menuPathStyle == wxFH_HIDE_CURRENT_PATH ) && ( currFn.GetPath() == firstFn.GetPath() ) && currFn.HasName() ) { // Hide the path if it is in the same folder as the first file