Moved flicker-removal to GTK+ code
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15878 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -220,17 +220,9 @@ void wxCommandProcessor::Initialize()
|
|||||||
SetMenuStrings();
|
SetMenuStrings();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This reduces flicker in wxGTK+
|
static void wxSetMenuLabel(wxMenu* menu, int id, const wxString& label)
|
||||||
static void wxSetMenuLabelOptimally(wxMenu* menu, int id, const wxString& label)
|
|
||||||
{
|
{
|
||||||
wxString oldLabel = menu->GetLabel(id);
|
menu->SetLabel(id, label);
|
||||||
oldLabel = wxStripMenuCodes(oldLabel.BeforeFirst('\t'));
|
|
||||||
#ifdef __WXGTK__
|
|
||||||
oldLabel.Replace(wxT("_"), wxT("")); // GTK+ only
|
|
||||||
#endif
|
|
||||||
wxString label1 = wxStripMenuCodes(label.BeforeFirst('\t'));
|
|
||||||
if (oldLabel != label1)
|
|
||||||
menu->SetLabel(id, label);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxCommandProcessor::SetMenuStrings()
|
void wxCommandProcessor::SetMenuStrings()
|
||||||
@@ -250,8 +242,7 @@ void wxCommandProcessor::SetMenuStrings()
|
|||||||
else
|
else
|
||||||
buf = wxString(_("Can't &Undo ")) + commandName + m_undoAccelerator;
|
buf = wxString(_("Can't &Undo ")) + commandName + m_undoAccelerator;
|
||||||
|
|
||||||
//m_commandEditMenu->SetLabel(wxID_UNDO, buf);
|
wxSetMenuLabel(m_commandEditMenu, wxID_UNDO, buf);
|
||||||
wxSetMenuLabelOptimally(m_commandEditMenu, wxID_UNDO, buf);
|
|
||||||
|
|
||||||
m_commandEditMenu->Enable(wxID_UNDO, canUndo);
|
m_commandEditMenu->Enable(wxID_UNDO, canUndo);
|
||||||
|
|
||||||
@@ -262,23 +253,23 @@ void wxCommandProcessor::SetMenuStrings()
|
|||||||
wxString redoCommandName(redoCommand->GetName());
|
wxString redoCommandName(redoCommand->GetName());
|
||||||
if (redoCommandName == wxT("")) redoCommandName = _("Unnamed command");
|
if (redoCommandName == wxT("")) redoCommandName = _("Unnamed command");
|
||||||
buf = wxString(_("&Redo ")) + redoCommandName + m_redoAccelerator;
|
buf = wxString(_("&Redo ")) + redoCommandName + m_redoAccelerator;
|
||||||
wxSetMenuLabelOptimally(m_commandEditMenu, wxID_REDO, buf);
|
wxSetMenuLabel(m_commandEditMenu, wxID_REDO, buf);
|
||||||
m_commandEditMenu->Enable(wxID_REDO, TRUE);
|
m_commandEditMenu->Enable(wxID_REDO, TRUE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxSetMenuLabelOptimally(m_commandEditMenu, wxID_REDO, _("&Redo") + m_redoAccelerator);
|
wxSetMenuLabel(m_commandEditMenu, wxID_REDO, _("&Redo") + m_redoAccelerator);
|
||||||
m_commandEditMenu->Enable(wxID_REDO, FALSE);
|
m_commandEditMenu->Enable(wxID_REDO, FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxSetMenuLabelOptimally(m_commandEditMenu, wxID_UNDO, _("&Undo") + m_undoAccelerator);
|
wxSetMenuLabel(m_commandEditMenu, wxID_UNDO, _("&Undo") + m_undoAccelerator);
|
||||||
m_commandEditMenu->Enable(wxID_UNDO, FALSE);
|
m_commandEditMenu->Enable(wxID_UNDO, FALSE);
|
||||||
|
|
||||||
if (m_commands.Number() == 0)
|
if (m_commands.Number() == 0)
|
||||||
{
|
{
|
||||||
wxSetMenuLabelOptimally(m_commandEditMenu, wxID_REDO, _("&Redo") + m_redoAccelerator);
|
wxSetMenuLabel(m_commandEditMenu, wxID_REDO, _("&Redo") + m_redoAccelerator);
|
||||||
m_commandEditMenu->Enable(wxID_REDO, FALSE);
|
m_commandEditMenu->Enable(wxID_REDO, FALSE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -289,7 +280,7 @@ void wxCommandProcessor::SetMenuStrings()
|
|||||||
wxString redoCommandName(redoCommand->GetName());
|
wxString redoCommandName(redoCommand->GetName());
|
||||||
if (redoCommandName == wxT("")) redoCommandName = _("Unnamed command");
|
if (redoCommandName == wxT("")) redoCommandName = _("Unnamed command");
|
||||||
buf = wxString(_("&Redo ")) + redoCommandName + m_redoAccelerator;
|
buf = wxString(_("&Redo ")) + redoCommandName + m_redoAccelerator;
|
||||||
wxSetMenuLabelOptimally(m_commandEditMenu, wxID_REDO, buf);
|
wxSetMenuLabel(m_commandEditMenu, wxID_REDO, buf);
|
||||||
m_commandEditMenu->Enable(wxID_REDO, TRUE);
|
m_commandEditMenu->Enable(wxID_REDO, TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -775,6 +775,14 @@ wxString wxMenuItemBase::GetLabelFromText(const wxString& text)
|
|||||||
|
|
||||||
void wxMenuItem::SetText( const wxString& str )
|
void wxMenuItem::SetText( const wxString& str )
|
||||||
{
|
{
|
||||||
|
// Some optimization to avoid flicker
|
||||||
|
wxString oldLabel = m_text;
|
||||||
|
oldLabel = wxStripMenuCodes(oldLabel.BeforeFirst('\t'));
|
||||||
|
oldLabel.Replace(wxT("_"), wxT(""));
|
||||||
|
wxString label1 = wxStripMenuCodes(str.BeforeFirst('\t'));
|
||||||
|
if (oldLabel == label1)
|
||||||
|
return;
|
||||||
|
|
||||||
DoSetText(str);
|
DoSetText(str);
|
||||||
|
|
||||||
if (m_menuItem)
|
if (m_menuItem)
|
||||||
|
@@ -775,6 +775,14 @@ wxString wxMenuItemBase::GetLabelFromText(const wxString& text)
|
|||||||
|
|
||||||
void wxMenuItem::SetText( const wxString& str )
|
void wxMenuItem::SetText( const wxString& str )
|
||||||
{
|
{
|
||||||
|
// Some optimization to avoid flicker
|
||||||
|
wxString oldLabel = m_text;
|
||||||
|
oldLabel = wxStripMenuCodes(oldLabel.BeforeFirst('\t'));
|
||||||
|
oldLabel.Replace(wxT("_"), wxT(""));
|
||||||
|
wxString label1 = wxStripMenuCodes(str.BeforeFirst('\t'));
|
||||||
|
if (oldLabel == label1)
|
||||||
|
return;
|
||||||
|
|
||||||
DoSetText(str);
|
DoSetText(str);
|
||||||
|
|
||||||
if (m_menuItem)
|
if (m_menuItem)
|
||||||
|
Reference in New Issue
Block a user