Do not attempt to change colours of properties which are not present on the current page (in propgrid sample).

Test executed from 'Category Specific Colours' menu is designed to work only for specific category properties which are present only on 'Standard Items' page.
Display a message if current page is not this one and therefore test cannot be executed properly. Also make menu item non-checkable if it is accessed from improper page.
This commit is contained in:
Artur Wieczorek 2015-08-27 19:05:15 +02:00
parent f3d8f6cadc
commit 0870f213df
2 changed files with 24 additions and 0 deletions

View File

@ -558,6 +558,8 @@ wxBEGIN_EVENT_TABLE(FormMain, wxFrame)
EVT_MENU( ID_RUNMINIMAL, FormMain::OnRunMinimalClick )
EVT_UPDATE_UI( ID_CATCOLOURS, FormMain::OnCatColoursUpdateUI )
EVT_CONTEXT_MENU( FormMain::OnContextMenu )
EVT_BUTTON(ID_SHOWPOPUP, FormMain::OnShowPopup)
wxEND_EVENT_TABLE()
@ -2789,9 +2791,30 @@ void FormMain::OnColourScheme( wxCommandEvent& event )
// -----------------------------------------------------------------------
void FormMain::OnCatColoursUpdateUI(wxUpdateUIEvent& WXUNUSED(event))
{
// Prevent menu item from being checked
// if it is selected from imroper page.
const wxPropertyGrid* pg = m_pPropGridManager->GetGrid();
m_itemCatColours->SetCheckable(
pg->GetPropertyByName("Appearance") &&
pg->GetPropertyByName("PositionCategory") &&
pg->GetPropertyByName("Environment") &&
pg->GetPropertyByName("More Examples") );
}
void FormMain::OnCatColours( wxCommandEvent& event )
{
wxPropertyGrid* pg = m_pPropGridManager->GetGrid();
if ( !pg->GetPropertyByName("Appearance") ||
!pg->GetPropertyByName("PositionCategory") ||
!pg->GetPropertyByName("Environment") ||
!pg->GetPropertyByName("More Examples") )
{
wxMessageBox("First switch to 'Standard Items' page!");
return;
}
m_pPropGridManager->Freeze();
if ( event.IsChecked() )

View File

@ -195,6 +195,7 @@ public:
void OnShowHeader( wxCommandEvent& event );
#endif
void OnDumpList( wxCommandEvent& event );
void OnCatColoursUpdateUI( wxUpdateUIEvent& event );
void OnCatColours( wxCommandEvent& event );
void OnSetColumns( wxCommandEvent& event );
void OnMisc( wxCommandEvent& event );