Remove public wxFileHistory::RefreshLabels()
Replace it with a private DoRefreshLabels() and call it ourselves from SetMenuPathStyle() to make the class simpler (and less error-prone, as it's now impossible to forget to call RefreshLabels() any more) to use.
This commit is contained in:
@@ -67,11 +67,9 @@ public:
|
|||||||
void SetBaseId(wxWindowID baseId) { m_idBase = baseId; }
|
void SetBaseId(wxWindowID baseId) { m_idBase = baseId; }
|
||||||
wxWindowID GetBaseId() const { return m_idBase; }
|
wxWindowID GetBaseId() const { return m_idBase; }
|
||||||
|
|
||||||
void SetMenuPathStyle(wxFileHistoryMenuPathStyle style) { m_menuPathStyle = style; }
|
void SetMenuPathStyle(wxFileHistoryMenuPathStyle style);
|
||||||
wxFileHistoryMenuPathStyle GetMenuPathStyle() const { return m_menuPathStyle; }
|
wxFileHistoryMenuPathStyle GetMenuPathStyle() const { return m_menuPathStyle; }
|
||||||
|
|
||||||
void RefreshLabels();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Last n files
|
// Last n files
|
||||||
wxArrayString m_fileHistory;
|
wxArrayString m_fileHistory;
|
||||||
@@ -86,6 +84,9 @@ protected:
|
|||||||
wxFileHistoryMenuPathStyle m_menuPathStyle;
|
wxFileHistoryMenuPathStyle m_menuPathStyle;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void DoRefreshLabels();
|
||||||
|
|
||||||
|
|
||||||
// The ID of the first history menu item (Doesn't have to be wxID_FILE1)
|
// The ID of the first history menu item (Doesn't have to be wxID_FILE1)
|
||||||
wxWindowID m_idBase;
|
wxWindowID m_idBase;
|
||||||
|
|
||||||
|
@@ -125,14 +125,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void Load(const wxConfigBase& config);
|
virtual void Load(const wxConfigBase& config);
|
||||||
|
|
||||||
/**
|
|
||||||
Refresh the labels on all the menu items in the menus used by this
|
|
||||||
file history.
|
|
||||||
|
|
||||||
@since 3.1.5
|
|
||||||
*/
|
|
||||||
void RefreshLabels();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Removes the specified file from the history.
|
Removes the specified file from the history.
|
||||||
*/
|
*/
|
||||||
@@ -169,7 +161,6 @@ public:
|
|||||||
|
|
||||||
By default, the menu item label style is ::wxFH_PATH_SHOW_IF_DIFFERENT.
|
By default, the menu item label style is ::wxFH_PATH_SHOW_IF_DIFFERENT.
|
||||||
|
|
||||||
@remarks Use RefreshLabels() to update any existing menu items to the new style.
|
|
||||||
@since 3.1.5
|
@since 3.1.5
|
||||||
*/
|
*/
|
||||||
void SetMenuPathStyle(wxFileHistoryMenuPathStyle style);
|
void SetMenuPathStyle(wxFileHistoryMenuPathStyle style);
|
||||||
|
@@ -1403,8 +1403,6 @@ void MyFrame::OnFileHistoryStyleItem(wxCommandEvent& event)
|
|||||||
m_fileHistory->SetMenuPathStyle(wxFH_PATH_SHOW_ALWAYS);
|
m_fileHistory->SetMenuPathStyle(wxFH_PATH_SHOW_ALWAYS);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_fileHistory->RefreshLabels();
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -136,10 +136,10 @@ void wxFileHistoryBase::AddFileToHistory(const wxString& file)
|
|||||||
m_fileHistory.insert(m_fileHistory.begin(), file);
|
m_fileHistory.insert(m_fileHistory.begin(), file);
|
||||||
numFiles++;
|
numFiles++;
|
||||||
|
|
||||||
RefreshLabels();
|
DoRefreshLabels();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFileHistoryBase::RefreshLabels()
|
void wxFileHistoryBase::DoRefreshLabels()
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
size_t numFiles = m_fileHistory.size();
|
size_t numFiles = m_fileHistory.size();
|
||||||
@@ -187,6 +187,15 @@ void wxFileHistoryBase::RefreshLabels()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxFileHistoryBase::SetMenuPathStyle(wxFileHistoryMenuPathStyle style)
|
||||||
|
{
|
||||||
|
if ( style != m_menuPathStyle )
|
||||||
|
{
|
||||||
|
m_menuPathStyle = style;
|
||||||
|
DoRefreshLabels();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void wxFileHistoryBase::RemoveFileFromHistory(size_t i)
|
void wxFileHistoryBase::RemoveFileFromHistory(size_t i)
|
||||||
{
|
{
|
||||||
size_t numFiles = m_fileHistory.size();
|
size_t numFiles = m_fileHistory.size();
|
||||||
|
Reference in New Issue
Block a user