Eeschema options+hotkeys fixes
Fix wxTreeListCtrl column sizing Minor: fix signed/unsigned comparison Remove unnecessary m_parent direct access
This commit is contained in:
parent
5173699eec
commit
db178dcdaf
|
@ -27,6 +27,7 @@
|
||||||
#include <pgm_base.h>
|
#include <pgm_base.h>
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <confirm.h>
|
#include <confirm.h>
|
||||||
|
#include <wx/dataview.h>
|
||||||
|
|
||||||
#include <dialog_hotkeys_editor.h>
|
#include <dialog_hotkeys_editor.h>
|
||||||
|
|
||||||
|
@ -52,9 +53,8 @@ HOTKEY_LIST_CTRL::HOTKEY_LIST_CTRL( wxWindow *aParent, const HOTKEYS_SECTIONS& a
|
||||||
AppendColumn( _( "Command" ) );
|
AppendColumn( _( "Command" ) );
|
||||||
AppendColumn( _( "Hotkey" ) );
|
AppendColumn( _( "Hotkey" ) );
|
||||||
|
|
||||||
SetColumnWidth( 1, 100 );
|
|
||||||
|
|
||||||
Bind( wxEVT_CHAR, &HOTKEY_LIST_CTRL::OnChar, this );
|
Bind( wxEVT_CHAR, &HOTKEY_LIST_CTRL::OnChar, this );
|
||||||
|
Bind( wxEVT_SIZE, &HOTKEY_LIST_CTRL::OnSize, this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,9 +70,34 @@ HOTKEYS_SECTIONS HOTKEY_LIST_CTRL::Sections( EDA_HOTKEY_CONFIG* aHotkeys )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void HOTKEY_LIST_CTRL::OnSize( wxSizeEvent& aEvent )
|
||||||
|
{
|
||||||
|
// Handle this manually - wxTreeListCtrl screws up the width of the first column
|
||||||
|
wxDataViewCtrl* view = GetDataView();
|
||||||
|
|
||||||
|
if( !view )
|
||||||
|
return;
|
||||||
|
|
||||||
|
const wxRect rect = GetClientRect();
|
||||||
|
view->SetSize( rect );
|
||||||
|
|
||||||
|
#ifdef wxHAS_GENERIC_DATAVIEWCTRL
|
||||||
|
{
|
||||||
|
wxWindow* const view = GetView();
|
||||||
|
view->Refresh();
|
||||||
|
view->Update();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SetColumnWidth( 1, 100 );
|
||||||
|
SetColumnWidth( 0, rect.width - 120 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void HOTKEY_LIST_CTRL::DeselectRow( int aRow )
|
void HOTKEY_LIST_CTRL::DeselectRow( int aRow )
|
||||||
{
|
{
|
||||||
wxASSERT( aRow >= 0 && aRow < (int)m_items.size() );
|
wxASSERT( aRow >= 0 );
|
||||||
|
wxASSERT( (size_t)( aRow ) < m_items.size() );
|
||||||
Unselect( m_items[aRow] );
|
Unselect( m_items[aRow] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,7 +302,7 @@ bool HOTKEY_LIST_CTRL::ResolveKeyConflicts( long aKey, const wxString& aSectionT
|
||||||
KeyNameFromKeyCode( aKey ), GetChars( info ),
|
KeyNameFromKeyCode( aKey ), GetChars( info ),
|
||||||
*(conflictingSection->m_Title) );
|
*(conflictingSection->m_Title) );
|
||||||
|
|
||||||
wxMessageDialog dlg( m_parent, msg, _( "Confirm change" ), wxYES_NO | wxNO_DEFAULT );
|
wxMessageDialog dlg( GetParent(), msg, _( "Confirm change" ), wxYES_NO | wxNO_DEFAULT );
|
||||||
|
|
||||||
if( dlg.ShowModal() == wxID_YES )
|
if( dlg.ShowModal() == wxID_YES )
|
||||||
{
|
{
|
||||||
|
@ -358,7 +383,6 @@ void InstallHotkeyFrame( EDA_BASE_FRAME* aParent, EDA_HOTKEY_CONFIG* aHotkeys )
|
||||||
HOTKEYS_EDITOR_DIALOG::HOTKEYS_EDITOR_DIALOG( EDA_BASE_FRAME* aParent,
|
HOTKEYS_EDITOR_DIALOG::HOTKEYS_EDITOR_DIALOG( EDA_BASE_FRAME* aParent,
|
||||||
EDA_HOTKEY_CONFIG* aHotkeys ) :
|
EDA_HOTKEY_CONFIG* aHotkeys ) :
|
||||||
HOTKEYS_EDITOR_DIALOG_BASE( aParent ),
|
HOTKEYS_EDITOR_DIALOG_BASE( aParent ),
|
||||||
m_parent( aParent ),
|
|
||||||
m_hotkeys( aHotkeys )
|
m_hotkeys( aHotkeys )
|
||||||
{
|
{
|
||||||
m_hotkeyListCtrl = new HOTKEY_LIST_CTRL( this, HOTKEY_LIST_CTRL::Sections( aHotkeys ) );
|
m_hotkeyListCtrl = new HOTKEY_LIST_CTRL( this, HOTKEY_LIST_CTRL::Sections( aHotkeys ) );
|
||||||
|
@ -391,7 +415,7 @@ bool HOTKEYS_EDITOR_DIALOG::TransferDataFromWindow()
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// save the hotkeys
|
// save the hotkeys
|
||||||
m_parent->WriteHotkeyConfig( m_hotkeys );
|
GetParent()->WriteHotkeyConfig( m_hotkeys );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ enum IMP_EXP_MENU_IDS
|
||||||
ID_EXPORT_HOTKEYS
|
ID_EXPORT_HOTKEYS
|
||||||
};
|
};
|
||||||
|
|
||||||
DIALOG_EESCHEMA_OPTIONS::DIALOG_EESCHEMA_OPTIONS( wxWindow* parent ) :
|
DIALOG_EESCHEMA_OPTIONS::DIALOG_EESCHEMA_OPTIONS( SCH_EDIT_FRAME* parent ) :
|
||||||
DIALOG_EESCHEMA_OPTIONS_BASE( parent )
|
DIALOG_EESCHEMA_OPTIONS_BASE( parent )
|
||||||
{
|
{
|
||||||
m_choiceUnits->SetFocus();
|
m_choiceUnits->SetFocus();
|
||||||
|
@ -80,6 +80,12 @@ DIALOG_EESCHEMA_OPTIONS::DIALOG_EESCHEMA_OPTIONS( wxWindow* parent ) :
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SCH_EDIT_FRAME* DIALOG_EESCHEMA_OPTIONS::GetParent()
|
||||||
|
{
|
||||||
|
return static_cast<SCH_EDIT_FRAME*>( DIALOG_EESCHEMA_OPTIONS_BASE::GetParent() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void DIALOG_EESCHEMA_OPTIONS::OnImpExpClick( wxCommandEvent& aEvent )
|
void DIALOG_EESCHEMA_OPTIONS::OnImpExpClick( wxCommandEvent& aEvent )
|
||||||
{
|
{
|
||||||
wxMenu menu;
|
wxMenu menu;
|
||||||
|
@ -103,19 +109,19 @@ void DIALOG_EESCHEMA_OPTIONS::OnMenu( wxCommandEvent& aEvent )
|
||||||
{
|
{
|
||||||
case ID_IMPORT_PREFS:
|
case ID_IMPORT_PREFS:
|
||||||
aEvent.SetId( ID_CONFIG_READ );
|
aEvent.SetId( ID_CONFIG_READ );
|
||||||
static_cast<SCH_EDIT_FRAME*>( m_parent )->Process_Config( aEvent );
|
GetParent()->Process_Config( aEvent );
|
||||||
break;
|
break;
|
||||||
case ID_EXPORT_PREFS:
|
case ID_EXPORT_PREFS:
|
||||||
aEvent.SetId( ID_CONFIG_SAVE );
|
aEvent.SetId( ID_CONFIG_SAVE );
|
||||||
static_cast<SCH_EDIT_FRAME*>( m_parent )->Process_Config( aEvent );
|
GetParent()->Process_Config( aEvent );
|
||||||
break;
|
break;
|
||||||
case ID_IMPORT_HOTKEYS:
|
case ID_IMPORT_HOTKEYS:
|
||||||
aEvent.SetId( ID_PREFERENCES_HOTKEY_IMPORT_CONFIG );
|
aEvent.SetId( ID_PREFERENCES_HOTKEY_IMPORT_CONFIG );
|
||||||
static_cast<SCH_EDIT_FRAME*>( m_parent )->Process_Config( aEvent );
|
GetParent()->Process_Config( aEvent );
|
||||||
break;
|
break;
|
||||||
case ID_EXPORT_HOTKEYS:
|
case ID_EXPORT_HOTKEYS:
|
||||||
aEvent.SetId( ID_PREFERENCES_HOTKEY_EXPORT_CONFIG );
|
aEvent.SetId( ID_PREFERENCES_HOTKEY_EXPORT_CONFIG );
|
||||||
static_cast<SCH_EDIT_FRAME*>( m_parent )->Process_Config( aEvent );
|
GetParent()->Process_Config( aEvent );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG("Unexpected menu ID");
|
wxFAIL_MSG("Unexpected menu ID");
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include <template_fieldnames.h>
|
#include <template_fieldnames.h>
|
||||||
|
|
||||||
class HOTKEY_LIST_CTRL;
|
class HOTKEY_LIST_CTRL;
|
||||||
|
class SCH_EDIT_FRAME;
|
||||||
|
|
||||||
class DIALOG_EESCHEMA_OPTIONS : public DIALOG_EESCHEMA_OPTIONS_BASE
|
class DIALOG_EESCHEMA_OPTIONS : public DIALOG_EESCHEMA_OPTIONS_BASE
|
||||||
{
|
{
|
||||||
|
@ -96,7 +97,9 @@ public:
|
||||||
*
|
*
|
||||||
* @param parent The dialog's parent
|
* @param parent The dialog's parent
|
||||||
*/
|
*/
|
||||||
DIALOG_EESCHEMA_OPTIONS( wxWindow* parent );
|
DIALOG_EESCHEMA_OPTIONS( SCH_EDIT_FRAME* parent );
|
||||||
|
|
||||||
|
virtual SCH_EDIT_FRAME* GetParent();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetUnitsSelection
|
* Function GetUnitsSelection
|
||||||
|
|
|
@ -173,6 +173,12 @@ protected:
|
||||||
* @param aEvent is the key press event, the keycode is retrieved from it
|
* @param aEvent is the key press event, the keycode is retrieved from it
|
||||||
*/
|
*/
|
||||||
void OnChar( wxKeyEvent& aEvent );
|
void OnChar( wxKeyEvent& aEvent );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function OnSize
|
||||||
|
* Handle resizing of the control. Overrides the buggy wxTreeListCtrl::OnSize.
|
||||||
|
*/
|
||||||
|
void OnSize( wxSizeEvent& aEvent );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -184,7 +190,6 @@ protected:
|
||||||
class HOTKEYS_EDITOR_DIALOG : public HOTKEYS_EDITOR_DIALOG_BASE
|
class HOTKEYS_EDITOR_DIALOG : public HOTKEYS_EDITOR_DIALOG_BASE
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
EDA_BASE_FRAME* m_parent;
|
|
||||||
struct EDA_HOTKEY_CONFIG* m_hotkeys;
|
struct EDA_HOTKEY_CONFIG* m_hotkeys;
|
||||||
|
|
||||||
HOTKEY_LIST_CTRL* m_hotkeyListCtrl;
|
HOTKEY_LIST_CTRL* m_hotkeyListCtrl;
|
||||||
|
@ -192,6 +197,11 @@ protected:
|
||||||
bool TransferDataToWindow();
|
bool TransferDataToWindow();
|
||||||
bool TransferDataFromWindow();
|
bool TransferDataFromWindow();
|
||||||
|
|
||||||
|
virtual EDA_BASE_FRAME* GetParent()
|
||||||
|
{
|
||||||
|
return static_cast<EDA_BASE_FRAME*>( HOTKEYS_EDITOR_DIALOG_BASE::GetParent() );
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HOTKEYS_EDITOR_DIALOG( EDA_BASE_FRAME* aParent, EDA_HOTKEY_CONFIG* aHotkeys );
|
HOTKEYS_EDITOR_DIALOG( EDA_BASE_FRAME* aParent, EDA_HOTKEY_CONFIG* aHotkeys );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue