Cleanup some dead code, and add a potentially needed fix for non-Mac.

(The Mac bug is fixed in 4e5b1da81fce7cd9ffedaec878ed07bfcfff4fe2 in
our wxWidgets fork.)
This commit is contained in:
Jeff Young 2023-02-24 12:43:41 +00:00
parent 8059edff0e
commit 200a06a677
4 changed files with 34 additions and 12 deletions

View File

@ -74,26 +74,19 @@ DIALOG_SIM_MODEL<T_symbol, T_field>::DIALOG_SIM_MODEL( wxWindow* aParent, T_symb
return StrNumCmp( lhs->GetNumber(), rhs->GetNumber(), true ) < 0;
} );
m_typeChoice->Clear();
m_scintillaTricks = new SCINTILLA_TRICKS( m_codePreview, wxT( "{}" ), false );
m_paramGridMgr->Bind( wxEVT_PG_SELECTED, &DIALOG_SIM_MODEL::onParamGridSelectionChange, this );
m_paramGrid->SetValidationFailureBehavior( wxPG_VFB_STAY_IN_PROPERTY
| wxPG_VFB_BEEP
| wxPG_VFB_MARK_CELL );
wxPropertyGrid* grid = m_paramGrid->GetGrid();
//grid->SetCellBackgroundColour( grid->GetPropertyDefaultCell().GetBgCol() );
//grid->SetCellTextColour( grid->GetPropertyDefaultCell().GetFgCol();
// In wx 3.0 the color will be wrong sometimes.
grid->SetCellDisabledTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
grid->Bind( wxEVT_SET_FOCUS, &DIALOG_SIM_MODEL::onParamGridSetFocus, this );
grid->Bind( wxEVT_UPDATE_UI, &DIALOG_SIM_MODEL::onUpdateUI, this );
grid->AddActionTrigger( wxPG_ACTION_EDIT, WXK_RETURN );
grid->DedicateKey( WXK_RETURN );
@ -1369,6 +1362,7 @@ void DIALOG_SIM_MODEL<T_symbol, T_field>::onParamGridSelectionChange( wxProperty
}
wxWindow* editorControl = grid->GetEditorControl();
if( !editorControl )
{
m_prevParamGridSelection = grid->GetSelection();
@ -1381,6 +1375,35 @@ void DIALOG_SIM_MODEL<T_symbol, T_field>::onParamGridSelectionChange( wxProperty
}
template <typename T_symbol, typename T_field>
void DIALOG_SIM_MODEL<T_symbol, T_field>::onUpdateUI( wxUpdateUIEvent& aEvent )
{
// This is currently patched in wxPropertyGrid::ScrollWindow() in the Mac wxWidgets fork.
// However, we may need this version if it turns out to be an issue on other platforms and
// we can't get it upstreamed.
#if 0
// It's a shame to do this on the UpdateUI event, but neither the wxPropertyGridManager,
// wxPropertyGridPage, wxPropertyGrid, nor the wxPropertyGrid's GetCanvas() window appear
// to get scroll events.
wxPropertyGrid* grid = m_paramGrid->GetGrid();
wxTextCtrl* ctrl = grid->GetEditorTextCtrl();
if( ctrl )
{
wxRect ctrlRect = ctrl->GetScreenRect();
wxRect gridRect = grid->GetScreenRect();
if( ctrlRect.GetTop() < gridRect.GetTop() || ctrlRect.GetBottom() > gridRect.GetBottom() )
{
grid->CommitChangesFromEditor();
grid->ClearSelection();
}
}
#endif
}
template <typename T_symbol, typename T_field>
void DIALOG_SIM_MODEL<T_symbol, T_field>::adjustParamGridColumns( int aWidth, bool aForce )
{

View File

@ -111,6 +111,7 @@ private:
void onParamGridSetFocus( wxFocusEvent& aEvent );
void onParamGridSelectionChange( wxPropertyGridEvent& aEvent );
void onUpdateUI( wxUpdateUIEvent& aEvent );
void adjustParamGridColumns( int aWidth, bool aForce );

View File

@ -80,8 +80,7 @@ SIM_STRING_PROPERTY::SIM_STRING_PROPERTY( const wxString& aLabel, const wxString
SIM_VALUE_GRAMMAR::NOTATION aNotation ) :
wxStringProperty( aLabel, aName ),
SIM_PROPERTY( aModel, aParamIndex ),
m_valueType( aValueType ),
m_notation( aNotation )
m_valueType( aValueType )
{
SetValueFromString( GetParam().value );
}

View File

@ -98,8 +98,7 @@ protected:
bool allowEval() const;
protected:
SIM_VALUE::TYPE m_valueType;
SIM_VALUE_GRAMMAR::NOTATION m_notation;
SIM_VALUE::TYPE m_valueType;
};