mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 04:36:40 +00:00
[MSPAINT] Add CMainWindow::CanUndo/CanRedo (#5355)
- Add CMainWindow::CanUndo and CMainWindow::CanRedo and use them. - Fix wrongly-disabled Undo/Redo in some cases. CORE-18867
This commit is contained in:
parent
b5335fb90b
commit
64ef3ced9c
2 changed files with 28 additions and 7 deletions
|
@ -416,6 +416,26 @@ void CMainWindow::ProcessFileMenu(HMENU hPopupMenu)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL CMainWindow::CanUndo() const
|
||||||
|
{
|
||||||
|
if (toolsModel.GetActiveTool() == TOOL_TEXT && ::IsWindowVisible(textEditWindow))
|
||||||
|
return (BOOL)textEditWindow.SendMessage(EM_CANUNDO);
|
||||||
|
if (selectionModel.m_bShow && toolsModel.IsSelection())
|
||||||
|
return TRUE;
|
||||||
|
if (ToolBase::pointSP != 0)
|
||||||
|
return TRUE;
|
||||||
|
return imageModel.CanUndo();
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL CMainWindow::CanRedo() const
|
||||||
|
{
|
||||||
|
if (toolsModel.GetActiveTool() == TOOL_TEXT && ::IsWindowVisible(textEditWindow))
|
||||||
|
return FALSE; // There is no "WM_REDO" in EDIT control
|
||||||
|
if (ToolBase::pointSP != 0)
|
||||||
|
return TRUE;
|
||||||
|
return imageModel.CanRedo();
|
||||||
|
}
|
||||||
|
|
||||||
LRESULT CMainWindow::OnInitMenuPopup(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
LRESULT CMainWindow::OnInitMenuPopup(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||||
{
|
{
|
||||||
HMENU menu = (HMENU)wParam;
|
HMENU menu = (HMENU)wParam;
|
||||||
|
@ -437,9 +457,8 @@ LRESULT CMainWindow::OnInitMenuPopup(UINT nMsg, WPARAM wParam, LPARAM lParam, BO
|
||||||
//
|
//
|
||||||
// Edit menu
|
// Edit menu
|
||||||
//
|
//
|
||||||
EnableMenuItem(menu, IDM_EDITUNDO,
|
EnableMenuItem(menu, IDM_EDITUNDO, ENABLED_IF(CanUndo()));
|
||||||
ENABLED_IF(textShown ? textEditWindow.SendMessage(EM_CANUNDO) : imageModel.CanUndo()));
|
EnableMenuItem(menu, IDM_EDITREDO, ENABLED_IF(CanRedo()));
|
||||||
EnableMenuItem(menu, IDM_EDITREDO, ENABLED_IF(textShown ? FALSE : imageModel.CanRedo()));
|
|
||||||
EnableMenuItem(menu, IDM_EDITCUT, ENABLED_IF(textShown ? hasTextSel : trueSelection));
|
EnableMenuItem(menu, IDM_EDITCUT, ENABLED_IF(textShown ? hasTextSel : trueSelection));
|
||||||
EnableMenuItem(menu, IDM_EDITCOPY, ENABLED_IF(textShown ? hasTextSel : trueSelection));
|
EnableMenuItem(menu, IDM_EDITCOPY, ENABLED_IF(textShown ? hasTextSel : trueSelection));
|
||||||
EnableMenuItem(menu, IDM_EDITDELETESELECTION,
|
EnableMenuItem(menu, IDM_EDITDELETESELECTION,
|
||||||
|
@ -448,9 +467,9 @@ LRESULT CMainWindow::OnInitMenuPopup(UINT nMsg, WPARAM wParam, LPARAM lParam, BO
|
||||||
EnableMenuItem(menu, IDM_EDITCOPYTO, ENABLED_IF(trueSelection));
|
EnableMenuItem(menu, IDM_EDITCOPYTO, ENABLED_IF(trueSelection));
|
||||||
EnableMenuItem(menu, IDM_EDITPASTE,
|
EnableMenuItem(menu, IDM_EDITPASTE,
|
||||||
ENABLED_IF(textShown ? ::IsClipboardFormatAvailable(CF_UNICODETEXT) :
|
ENABLED_IF(textShown ? ::IsClipboardFormatAvailable(CF_UNICODETEXT) :
|
||||||
::IsClipboardFormatAvailable(CF_ENHMETAFILE) ||
|
(::IsClipboardFormatAvailable(CF_ENHMETAFILE) ||
|
||||||
::IsClipboardFormatAvailable(CF_DIB) ||
|
::IsClipboardFormatAvailable(CF_DIB) ||
|
||||||
::IsClipboardFormatAvailable(CF_BITMAP)));
|
::IsClipboardFormatAvailable(CF_BITMAP))));
|
||||||
|
|
||||||
//
|
//
|
||||||
// View menu
|
// View menu
|
||||||
|
@ -681,7 +700,7 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
|
||||||
case IDM_EDITREDO:
|
case IDM_EDITREDO:
|
||||||
if (textShown)
|
if (textShown)
|
||||||
{
|
{
|
||||||
// There is no "WM_REDO". Do nothing
|
// There is no "WM_REDO" in EDIT control
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (ToolBase::pointSP != 0) // drawing something?
|
if (ToolBase::pointSP != 0) // drawing something?
|
||||||
|
|
|
@ -35,6 +35,8 @@ public:
|
||||||
BOOL GetSaveFileName(IN OUT LPTSTR pszFile, INT cchMaxFile);
|
BOOL GetSaveFileName(IN OUT LPTSTR pszFile, INT cchMaxFile);
|
||||||
BOOL ChooseColor(IN OUT COLORREF *prgbColor);
|
BOOL ChooseColor(IN OUT COLORREF *prgbColor);
|
||||||
VOID TrackPopupMenu(POINT ptScreen, INT iSubMenu);
|
VOID TrackPopupMenu(POINT ptScreen, INT iSubMenu);
|
||||||
|
BOOL CanUndo() const;
|
||||||
|
BOOL CanRedo() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HMENU m_hMenu;
|
HMENU m_hMenu;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue