diff --git a/include/wx/propgrid/propgrid.h b/include/wx/propgrid/propgrid.h index 06b070675a..25387ea632 100644 --- a/include/wx/propgrid/propgrid.h +++ b/include/wx/propgrid/propgrid.h @@ -438,7 +438,7 @@ private: // These are used with wxPropertyGrid::AddActionTrigger() and // wxPropertyGrid::ClearActionTriggers(). -enum class wxPGKeyboardActions +enum class wxPGKeyboardAction { #if WXWIN_COMPATIBILITY_3_2 Invalid = 0, @@ -471,22 +471,25 @@ enum class wxPGKeyboardActions }; #if WXWIN_COMPATIBILITY_3_2 -wxDEPRECATED_MSG("use wxPGKeyboardActions::Invalid instead") -constexpr wxPGKeyboardActions wxPG_ACTION_INVALID { wxPGKeyboardActions::Invalid }; -wxDEPRECATED_MSG("use wxPGKeyboardActions::NextProperty instead") -constexpr wxPGKeyboardActions wxPG_ACTION_NEXT_PROPERTY { wxPGKeyboardActions::NextProperty }; -wxDEPRECATED_MSG("use wxPGKeyboardActions::PrevProperty instead") -constexpr wxPGKeyboardActions wxPG_ACTION_PREV_PROPERTY { wxPGKeyboardActions::PrevProperty }; -wxDEPRECATED_MSG("use wxPGKeyboardActions::ExpandProperty instead") -constexpr wxPGKeyboardActions wxPG_ACTION_EXPAND_PROPERTY { wxPGKeyboardActions::ExpandProperty }; -wxDEPRECATED_MSG("use wxPGKeyboardActions::CollapseProperty instead") -constexpr wxPGKeyboardActions wxPG_ACTION_COLLAPSE_PROPERTY { wxPGKeyboardActions::CollapseProperty }; -wxDEPRECATED_MSG("use wxPGKeyboardActions::CancelEdit instead") -constexpr wxPGKeyboardActions wxPG_ACTION_CANCEL_EDIT { wxPGKeyboardActions::CancelEdit }; -wxDEPRECATED_MSG("use wxPGKeyboardActions::Edit instead") -constexpr wxPGKeyboardActions wxPG_ACTION_EDIT { wxPGKeyboardActions::Edit }; -wxDEPRECATED_MSG("use wxPGKeyboardActions::PressButton instead") -constexpr wxPGKeyboardActions wxPG_ACTION_PRESS_BUTTON { wxPGKeyboardActions::PressButton }; +wxDEPRECATED_MSG("use wxPGKeyboardAction type instead") +typedef wxPGKeyboardAction wxPGKeyboardActions; + +wxDEPRECATED_MSG("use wxPGKeyboardAction::Invalid instead") +constexpr wxPGKeyboardAction wxPG_ACTION_INVALID { wxPGKeyboardAction::Invalid }; +wxDEPRECATED_MSG("use wxPGKeyboardAction::NextProperty instead") +constexpr wxPGKeyboardAction wxPG_ACTION_NEXT_PROPERTY { wxPGKeyboardAction::NextProperty }; +wxDEPRECATED_MSG("use wxPGKeyboardAction::PrevProperty instead") +constexpr wxPGKeyboardAction wxPG_ACTION_PREV_PROPERTY { wxPGKeyboardAction::PrevProperty }; +wxDEPRECATED_MSG("use wxPGKeyboardAction::ExpandProperty instead") +constexpr wxPGKeyboardAction wxPG_ACTION_EXPAND_PROPERTY { wxPGKeyboardAction::ExpandProperty }; +wxDEPRECATED_MSG("use wxPGKeyboardAction::CollapseProperty instead") +constexpr wxPGKeyboardAction wxPG_ACTION_COLLAPSE_PROPERTY { wxPGKeyboardAction::CollapseProperty }; +wxDEPRECATED_MSG("use wxPGKeyboardAction::CancelEdit instead") +constexpr wxPGKeyboardAction wxPG_ACTION_CANCEL_EDIT { wxPGKeyboardAction::CancelEdit }; +wxDEPRECATED_MSG("use wxPGKeyboardAction::Edit instead") +constexpr wxPGKeyboardAction wxPG_ACTION_EDIT { wxPGKeyboardAction::Edit }; +wxDEPRECATED_MSG("use wxPGKeyboardAction::PressButton instead") +constexpr wxPGKeyboardAction wxPG_ACTION_PRESS_BUTTON { wxPGKeyboardAction::PressButton }; #endif // WXWIN_COMPATIBILITY_3_2 // ----------------------------------------------------------------------- @@ -585,20 +588,20 @@ public: // Adds given key combination to trigger given action. // Here is a sample code to make Enter key press move focus to // the next property. - // propGrid->AddActionTrigger(wxPGKeyboardActions::NextProperty, WXK_RETURN); + // propGrid->AddActionTrigger(wxPGKeyboardAction::NextProperty, WXK_RETURN); // propGrid->DedicateKey(WXK_RETURN); // action - Which action to trigger. See @ref propgrid_keyboard_actions. // keycode - Which keycode triggers the action. // modifiers - Which key event modifiers, in addition to keycode, are needed to // trigger the action. #if WXWIN_COMPATIBILITY_3_2 - wxDEPRECATED_MSG("use AddActionTrigger with 'action' argument as wxPGKeyboardActions") + wxDEPRECATED_MSG("use AddActionTrigger with 'action' argument as wxPGKeyboardAction") void AddActionTrigger(int action, int keycode, int modifiers) { - AddActionTrigger(static_cast(action), keycode, modifiers); + AddActionTrigger(static_cast(action), keycode, modifiers); } #endif // WXWIN_COMPATIBILITY_3_2 - void AddActionTrigger(wxPGKeyboardActions action, int keycode, int modifiers = 0); + void AddActionTrigger(wxPGKeyboardAction action, int keycode, int modifiers = 0); // Dedicates a specific keycode to wxPropertyGrid. This means that such // key presses will not be redirected to editor controls. @@ -632,13 +635,13 @@ public: // Clears action triggers for given action. #if WXWIN_COMPATIBILITY_3_2 - wxDEPRECATED_MSG("use ClearActionTriggers with wxPGKeyboardActions argument") + wxDEPRECATED_MSG("use ClearActionTriggers with wxPGKeyboardAction argument") void ClearActionTriggers(int action) { - ClearActionTriggers(static_cast(action)); + ClearActionTriggers(static_cast(action)); } #endif // WXWIN_COMPATIBILITY_3_2 - void ClearActionTriggers(wxPGKeyboardActions action); + void ClearActionTriggers(wxPGKeyboardAction action); // Forces updating the value of property from the editor control. // Note that wxEVT_PG_CHANGING and wxEVT_PG_CHANGED are dispatched using @@ -1519,7 +1522,7 @@ protected: wxPGValidationInfo m_validationInfo; // Actions and keys that trigger them. - std::unordered_map> m_actionTriggers; + std::unordered_map> m_actionTriggers; // Appearance of currently active editor. wxPGCell m_editorAppearance; @@ -1775,14 +1778,14 @@ protected: unsigned int bottomItemY, const wxRect* itemsRect = nullptr ); - // Translate wxKeyEvent to wxPGKeyboardActions::XXX - std::pair KeyEventToActions(const wxKeyEvent& event) const; + // Translate wxKeyEvent to wxPGKeyboardAction::XXX + std::pair KeyEventToActions(const wxKeyEvent& event) const; #if WXWIN_COMPATIBILITY_3_2 wxDEPRECATED_MSG("use single-argument function KeyEventToActions(event)") - wxPGKeyboardActions KeyEventToActions(wxKeyEvent &event, wxPGKeyboardActions* pSecond) const; + wxPGKeyboardAction KeyEventToActions(wxKeyEvent &event, wxPGKeyboardAction* pSecond) const; #endif // WXWIN_COMPATIBILITY_3_2 - wxPGKeyboardActions KeyEventToAction(wxKeyEvent& event) const; + wxPGKeyboardAction KeyEventToAction(wxKeyEvent& event) const; void ImprovedClientToScreen( int* px, int* py ) const; @@ -1876,7 +1879,7 @@ protected: private: - bool ButtonTriggerKeyTest(wxPGKeyboardActions action, wxKeyEvent& event); + bool ButtonTriggerKeyTest(wxPGKeyboardAction action, wxKeyEvent& event); wxDECLARE_EVENT_TABLE(); }; diff --git a/interface/wx/propgrid/propgrid.h b/interface/wx/propgrid/propgrid.h index c68fda75c8..680a7e7374 100644 --- a/interface/wx/propgrid/propgrid.h +++ b/interface/wx/propgrid/propgrid.h @@ -396,7 +396,7 @@ public: @{ */ -enum class wxPGKeyboardActions +enum class wxPGKeyboardAction { Invalid, @@ -517,7 +517,7 @@ public: the next property. @code - propGrid->AddActionTrigger(wxPGKeyboardActions::NextProperty, + propGrid->AddActionTrigger(wxPGKeyboardAction::NextProperty, WXK_RETURN); propGrid->DedicateKey(WXK_RETURN); @endcode @@ -530,7 +530,7 @@ public: Which key event modifiers, in addition to keycode, are needed to trigger the action. */ - void AddActionTrigger(wxPGKeyboardActions action, int keycode, int modifiers = 0); + void AddActionTrigger(wxPGKeyboardAction action, int keycode, int modifiers = 0); /** Adds given property into selection. If ::wxPG_EX_MULTIPLE_SELECTION @@ -602,7 +602,7 @@ public: @param action Which action to clear. @ref propgrid_keyboard_actions. */ - void ClearActionTriggers(wxPGKeyboardActions action); + void ClearActionTriggers(wxPGKeyboardAction action); /** Forces updating the value of property from the editor control. diff --git a/samples/propgrid/propgrid.cpp b/samples/propgrid/propgrid.cpp index a47e2801b2..9659b12b01 100644 --- a/samples/propgrid/propgrid.cpp +++ b/samples/propgrid/propgrid.cpp @@ -2440,7 +2440,7 @@ void FormMain::OnExtendedKeyNav( wxCommandEvent& WXUNUSED(event) ) // Up, and Down keys for navigating between properties. wxPropertyGrid* propGrid = m_pPropGridManager->GetGrid(); - propGrid->AddActionTrigger(wxPGKeyboardActions::NextProperty, + propGrid->AddActionTrigger(wxPGKeyboardAction::NextProperty, WXK_RETURN); propGrid->DedicateKey(WXK_RETURN); diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index 202ee21929..5f902410b7 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -379,15 +379,15 @@ void wxPropertyGrid::Init1() m_unspecifiedAppearance.SetFgCol(*wxLIGHT_GREY); // Set default keys - AddActionTrigger(wxPGKeyboardActions::NextProperty, WXK_RIGHT); - AddActionTrigger(wxPGKeyboardActions::NextProperty, WXK_DOWN); - AddActionTrigger(wxPGKeyboardActions::PrevProperty, WXK_LEFT); - AddActionTrigger(wxPGKeyboardActions::PrevProperty, WXK_UP); - AddActionTrigger(wxPGKeyboardActions::ExpandProperty, WXK_RIGHT); - AddActionTrigger(wxPGKeyboardActions::CollapseProperty, WXK_LEFT); - AddActionTrigger(wxPGKeyboardActions::CancelEdit, WXK_ESCAPE); - AddActionTrigger(wxPGKeyboardActions::PressButton, WXK_DOWN, wxMOD_ALT); - AddActionTrigger(wxPGKeyboardActions::PressButton, WXK_F4); + AddActionTrigger(wxPGKeyboardAction::NextProperty, WXK_RIGHT); + AddActionTrigger(wxPGKeyboardAction::NextProperty, WXK_DOWN); + AddActionTrigger(wxPGKeyboardAction::PrevProperty, WXK_LEFT); + AddActionTrigger(wxPGKeyboardAction::PrevProperty, WXK_UP); + AddActionTrigger(wxPGKeyboardAction::ExpandProperty, WXK_RIGHT); + AddActionTrigger(wxPGKeyboardAction::CollapseProperty, WXK_LEFT); + AddActionTrigger(wxPGKeyboardAction::CancelEdit, WXK_ESCAPE); + AddActionTrigger(wxPGKeyboardAction::PressButton, WXK_DOWN, wxMOD_ALT); + AddActionTrigger(wxPGKeyboardAction::PressButton, WXK_F4); m_coloursCustomized = 0; @@ -5535,9 +5535,9 @@ void wxPropertyGrid::OnMouseUpChild( wxMouseEvent &event ) // wxPropertyGrid keyboard event handling // ----------------------------------------------------------------------- -std::pair wxPropertyGrid::KeyEventToActions(const wxKeyEvent& event) const +std::pair wxPropertyGrid::KeyEventToActions(const wxKeyEvent& event) const { - // Translates wxKeyEvent to wxPGKeyboardActions::XXX + // Translates wxKeyEvent to wxPGKeyboardAction::XXX int keycode = event.GetKeyCode(); int modifiers = event.GetModifiers(); @@ -5549,16 +5549,16 @@ std::pair wxPropertyGrid::KeyEventToAc auto it = m_actionTriggers.find(hashMapKey); if ( it == m_actionTriggers.end() ) - return std::make_pair(wxPGKeyboardActions::Invalid, wxPGKeyboardActions::Invalid); + return std::make_pair(wxPGKeyboardAction::Invalid, wxPGKeyboardAction::Invalid); return it->second; } #if WXWIN_COMPATIBILITY_3_2 -wxPGKeyboardActions wxPropertyGrid::KeyEventToActions(wxKeyEvent &event, wxPGKeyboardActions* pSecond) const +wxPGKeyboardAction wxPropertyGrid::KeyEventToActions(wxKeyEvent &event, wxPGKeyboardAction* pSecond) const { - // Translates wxKeyEvent to wxPGKeyboardActions::XXX - std::pair actions = KeyEventToActions(event); + // Translates wxKeyEvent to wxPGKeyboardAction::XXX + std::pair actions = KeyEventToActions(event); if ( pSecond ) { @@ -5569,18 +5569,18 @@ wxPGKeyboardActions wxPropertyGrid::KeyEventToActions(wxKeyEvent &event, wxPGKey } #endif // WXWIN_COMPATIBILITY_3_2 -wxPGKeyboardActions wxPropertyGrid::KeyEventToAction(wxKeyEvent& event) const +wxPGKeyboardAction wxPropertyGrid::KeyEventToAction(wxKeyEvent& event) const { return KeyEventToActions(event).first; } -void wxPropertyGrid::AddActionTrigger(wxPGKeyboardActions action, int keycode, int modifiers) +void wxPropertyGrid::AddActionTrigger(wxPGKeyboardAction action, int keycode, int modifiers) { wxASSERT( !(modifiers&~(0xFFFF)) ); int hashMapKey = (keycode & 0xFFFF) | ((modifiers & 0xFFFF) << 16); - std::pair curActions; + std::pair curActions; auto it = m_actionTriggers.find(hashMapKey); if ( it != m_actionTriggers.end() ) @@ -5589,20 +5589,20 @@ void wxPropertyGrid::AddActionTrigger(wxPGKeyboardActions action, int keycode, i curActions = it->second; // Can add secondary? - wxASSERT_MSG( curActions.second == wxPGKeyboardActions::Invalid, + wxASSERT_MSG( curActions.second == wxPGKeyboardAction::Invalid, "You can only add up to two separate actions per key combination." ); curActions.second = action; } else { - curActions = std::make_pair(action, wxPGKeyboardActions::Invalid); + curActions = std::make_pair(action, wxPGKeyboardAction::Invalid); } m_actionTriggers[hashMapKey] = curActions; } -void wxPropertyGrid::ClearActionTriggers(wxPGKeyboardActions action) +void wxPropertyGrid::ClearActionTriggers(wxPGKeyboardAction action) { // wxCHECK_RET(!(action & ~(0xFFFF)), wxS("You can only clear triggers for one action at a time.") @@ -5611,12 +5611,12 @@ void wxPropertyGrid::ClearActionTriggers(wxPGKeyboardActions action) { if ( it->second.second == action ) { - it->second.second = wxPGKeyboardActions::Invalid; + it->second.second = wxPGKeyboardAction::Invalid; } if ( it->second.first == action ) { - if ( it->second.second == wxPGKeyboardActions::Invalid ) + if ( it->second.second == wxPGKeyboardAction::Invalid ) { it = m_actionTriggers.erase(it); continue; @@ -5689,11 +5689,11 @@ void wxPropertyGrid::HandleKeyEvent( wxKeyEvent &event, bool fromChild ) return; } - wxPGKeyboardActions action; - wxPGKeyboardActions secondAction; + wxPGKeyboardAction action; + wxPGKeyboardAction secondAction; std::tie(action, secondAction) = KeyEventToActions(event); - if ( editorFocused && action == wxPGKeyboardActions::CancelEdit ) + if ( editorFocused && action == wxPGKeyboardAction::CancelEdit ) { // // Esc cancels any changes @@ -5737,7 +5737,7 @@ void wxPropertyGrid::HandleKeyEvent( wxKeyEvent &event, bool fromChild ) wxPGProperty* p = selected; - if ( action == wxPGKeyboardActions::Edit && !editorFocused ) + if ( action == wxPGKeyboardAction::Edit && !editorFocused ) { // Mark as handled only for editable property if ( !p->IsCategory() && p->IsEnabled() && !p->HasFlag(wxPGPropertyFlags::ReadOnly) ) @@ -5752,12 +5752,12 @@ void wxPropertyGrid::HandleKeyEvent( wxKeyEvent &event, bool fromChild ) if ( p->GetChildCount() ) { - if ( action == wxPGKeyboardActions::CollapseProperty || secondAction == wxPGKeyboardActions::CollapseProperty ) + if ( action == wxPGKeyboardAction::CollapseProperty || secondAction == wxPGKeyboardAction::CollapseProperty ) { if ( (m_windowStyle & wxPG_HIDE_MARGIN) || DoCollapse(p, true) ) wasHandled = true; } - else if ( action == wxPGKeyboardActions::ExpandProperty || secondAction == wxPGKeyboardActions::ExpandProperty ) + else if ( action == wxPGKeyboardAction::ExpandProperty || secondAction == wxPGKeyboardAction::ExpandProperty ) { if ( (m_windowStyle & wxPG_HIDE_MARGIN) || DoExpand(p, true) ) wasHandled = true; @@ -5766,11 +5766,11 @@ void wxPropertyGrid::HandleKeyEvent( wxKeyEvent &event, bool fromChild ) if ( !wasHandled ) { - if ( action == wxPGKeyboardActions::PrevProperty || secondAction == wxPGKeyboardActions::PrevProperty ) + if ( action == wxPGKeyboardAction::PrevProperty || secondAction == wxPGKeyboardAction::PrevProperty ) { selectDir = -1; } - else if ( action == wxPGKeyboardActions::NextProperty || secondAction == wxPGKeyboardActions::NextProperty ) + else if ( action == wxPGKeyboardAction::NextProperty || secondAction == wxPGKeyboardAction::NextProperty ) { selectDir = 1; } @@ -5784,7 +5784,7 @@ void wxPropertyGrid::HandleKeyEvent( wxKeyEvent &event, bool fromChild ) wxPGSelectPropertyFlags selFlags = wxPGSelectPropertyFlags::Null; int reopenLabelEditorCol = -1; - if ( action == wxPGKeyboardActions::Edit ) + if ( action == wxPGKeyboardAction::Edit ) { // Make the next editor focused as well // if we are actually going to edit the property. @@ -5802,7 +5802,7 @@ void wxPropertyGrid::HandleKeyEvent( wxKeyEvent &event, bool fromChild ) if ( reopenLabelEditorCol >= 0 ) DoBeginLabelEdit(reopenLabelEditorCol); } - else if ( action == wxPGKeyboardActions::Edit ) + else if ( action == wxPGKeyboardAction::Edit ) { // For first and last item just validate the value CommitChangesFromEditor(); @@ -5814,7 +5814,7 @@ void wxPropertyGrid::HandleKeyEvent( wxKeyEvent &event, bool fromChild ) { // If nothing was selected, select the first item now // (or navigate out of tab). - if ( action != wxPGKeyboardActions::CancelEdit && secondAction != wxPGKeyboardActions::CancelEdit ) + if ( action != wxPGKeyboardAction::CancelEdit && secondAction != wxPGKeyboardAction::CancelEdit ) { wxPGProperty* p = wxPropertyGridInterface::GetFirst(); if ( p ) DoSelectProperty(p); @@ -5848,15 +5848,15 @@ void wxPropertyGrid::OnKey( wxKeyEvent &event ) // ----------------------------------------------------------------------- -bool wxPropertyGrid::ButtonTriggerKeyTest(wxPGKeyboardActions action, wxKeyEvent& event) +bool wxPropertyGrid::ButtonTriggerKeyTest(wxPGKeyboardAction action, wxKeyEvent& event) { - if ( action == wxPGKeyboardActions::Invalid ) + if ( action == wxPGKeyboardAction::Invalid ) { action = KeyEventToActions(event).first; } // Does the keycode trigger button? - if ( action == wxPGKeyboardActions::PressButton && + if ( action == wxPGKeyboardAction::PressButton && m_wndEditor2 ) { wxCommandEvent evt(wxEVT_BUTTON, m_wndEditor2->GetId());