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.
This commit is contained in:
Vadim Zeitlin
2021-04-05 16:09:34 +02:00
parent 71c26ec4da
commit 036e35bf28
4 changed files with 26 additions and 18 deletions

View File

@@ -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)

View File

@@ -6,11 +6,14 @@
/////////////////////////////////////////////////////////////////////////////
/**
Styles for the labels on menu items for wxFileHistory menus
Styles for the paths shown in wxFileHistory menus.
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;
};

View File

@@ -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;
}

View File

@@ -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