Commit d5ecafd5 authored by jean-pierre charras's avatar jean-pierre charras
Browse files

Fix some minor issues in hotkey dialogs

parent 3053d45b
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -54,7 +54,7 @@ HOTKEYS_EDITOR_DIALOG::HOTKEYS_EDITOR_DIALOG( EDA_DRAW_FRAME* parent,
    m_hotkeys = hotkeys;
    m_hotkeys = hotkeys;
    m_curEditingRow = -1;
    m_curEditingRow = -1;


    m_table = new HotkeyGridTable( hotkeys );
    m_table = new HOTKEY_EDITOR_GRID_TABLE( hotkeys );
    m_hotkeyGrid->SetTable( m_table, true );
    m_hotkeyGrid->SetTable( m_table, true );


    m_hotkeyGrid->AutoSizeColumn( 0 );
    m_hotkeyGrid->AutoSizeColumn( 0 );
@@ -76,7 +76,7 @@ HOTKEYS_EDITOR_DIALOG::HOTKEYS_EDITOR_DIALOG( EDA_DRAW_FRAME* parent,
void HOTKEYS_EDITOR_DIALOG::OnOKClicked( wxCommandEvent& event )
void HOTKEYS_EDITOR_DIALOG::OnOKClicked( wxCommandEvent& event )
{
{
    /* edit the live hotkey table */
    /* edit the live hotkey table */
    HotkeyGridTable::hotkey_spec_vector& hotkey_vec = m_table->getHotkeys();
    HOTKEY_EDITOR_GRID_TABLE::hotkey_spec_vector& hotkey_vec = m_table->getHotkeys();


    EDA_HOTKEY_CONFIG*      section;
    EDA_HOTKEY_CONFIG*      section;


@@ -91,7 +91,7 @@ void HOTKEYS_EDITOR_DIALOG::OnOKClicked( wxCommandEvent& event )
            EDA_HOTKEY* info = *info_ptr;
            EDA_HOTKEY* info = *info_ptr;


            /* find the corresponding hotkey */
            /* find the corresponding hotkey */
            HotkeyGridTable::hotkey_spec_vector::iterator i;
            HOTKEY_EDITOR_GRID_TABLE::hotkey_spec_vector::iterator i;


            for( i = hotkey_vec.begin(); i != hotkey_vec.end(); ++i )
            for( i = hotkey_vec.begin(); i != hotkey_vec.end(); ++i )
            {
            {
@@ -158,7 +158,7 @@ void HOTKEYS_EDITOR_DIALOG::OnClickOnCell( wxGridEvent& event )


    int newRow = event.GetRow();
    int newRow = event.GetRow();


    if( ( event.GetCol() != 1 ) || ( m_table->isHeader( newRow ) ) )
    if( ( event.GetCol() != 1 ) || ( m_table->IsHeader( newRow ) ) )
    {
    {
        m_curEditingRow = -1;
        m_curEditingRow = -1;
    }
    }
+4 −2
Original line number Original line Diff line number Diff line
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Sep  8 2010)
// C++ code generated with wxFormBuilder (version Oct  8 2012)
// http://www.wxformbuilder.org/
// http://www.wxformbuilder.org/
//
//
// PLEASE DO "NOT" EDIT THIS FILE!
// PLEASE DO "NOT" EDIT THIS FILE!
@@ -9,7 +9,7 @@


///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////


HOTKEYS_EDITOR_DIALOG_BASE::HOTKEYS_EDITOR_DIALOG_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
HOTKEYS_EDITOR_DIALOG_BASE::HOTKEYS_EDITOR_DIALOG_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{
{
	this->SetSizeHints( wxDefaultSize, wxDefaultSize );
	this->SetSizeHints( wxDefaultSize, wxDefaultSize );
	
	
@@ -55,8 +55,10 @@ HOTKEYS_EDITOR_DIALOG_BASE::HOTKEYS_EDITOR_DIALOG_BASE( wxWindow* parent, wxWind
	m_undoButton = new wxButton( this, wxID_CANCEL, _("Undo"), wxDefaultPosition, wxDefaultSize, 0 );
	m_undoButton = new wxButton( this, wxID_CANCEL, _("Undo"), wxDefaultPosition, wxDefaultSize, 0 );
	b_buttonsSizer->Add( m_undoButton, 0, wxALL|wxEXPAND, 5 );
	b_buttonsSizer->Add( m_undoButton, 0, wxALL|wxEXPAND, 5 );
	
	
	
	bMainSizer->Add( b_buttonsSizer, 0, wxALIGN_CENTER_VERTICAL, 5 );
	bMainSizer->Add( b_buttonsSizer, 0, wxALIGN_CENTER_VERTICAL, 5 );
	
	
	
	this->SetSizer( bMainSizer );
	this->SetSizer( bMainSizer );
	this->Layout();
	this->Layout();
	
	
+376 −249

File changed.

Preview size limit exceeded, changes collapsed.

+10 −6
Original line number Original line Diff line number Diff line
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Sep  8 2010)
// C++ code generated with wxFormBuilder (version Oct  8 2012)
// http://www.wxformbuilder.org/
// http://www.wxformbuilder.org/
//
//
// PLEASE DO "NOT" EDIT THIS FILE!
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////


#ifndef __dialog_hotkeys_editor_base__
#ifndef __DIALOG_HOTKEYS_EDITOR_BASE_H__
#define __dialog_hotkeys_editor_base__
#define __DIALOG_HOTKEYS_EDITOR_BASE_H__


#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include <wx/intl.h>
class DIALOG_SHIM;


#include "dialog_shim.h"
#include <wx/colour.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/settings.h>
#include <wx/string.h>
#include <wx/string.h>
@@ -26,7 +30,7 @@
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class HOTKEYS_EDITOR_DIALOG_BASE
/// Class HOTKEYS_EDITOR_DIALOG_BASE
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
class HOTKEYS_EDITOR_DIALOG_BASE : public wxDialog 
class HOTKEYS_EDITOR_DIALOG_BASE : public DIALOG_SHIM
{
{
	private:
	private:
	
	
@@ -52,4 +56,4 @@ class HOTKEYS_EDITOR_DIALOG_BASE : public wxDialog
	
	
};
};


#endif //__dialog_hotkeys_editor_base__
#endif //__DIALOG_HOTKEYS_EDITOR_BASE_H__
+44 −44
Original line number Original line Diff line number Diff line
@@ -4,174 +4,179 @@
 *  Reads the hotkey table from its stored format into a format suitable
 *  Reads the hotkey table from its stored format into a format suitable
 *  for a wxGrid.
 *  for a wxGrid.
 */
 */
HotkeyGridTable::HotkeyGridTable( struct EDA_HOTKEY_CONFIG* origin ) :
HOTKEY_EDITOR_GRID_TABLE::HOTKEY_EDITOR_GRID_TABLE( struct EDA_HOTKEY_CONFIG* origin ) :
    wxGridTableBase(),
    wxGridTableBase(), m_hotkeys()
    m_hotkeys()
{
{
    EDA_HOTKEY_CONFIG* section;
    EDA_HOTKEY_CONFIG* section;


    for( section = origin; section->m_HK_InfoList; section++ )
    for( section = origin; section->m_HK_InfoList; section++ )
    {
    {
        hotkey_spec     spec( *section->m_SectionTag, new EDA_HOTKEY( NULL, 0, 0 ) );
        // Add a dummy hotkey_spec which is a header before each hotkey list
        hotkey_spec spec( *section->m_SectionTag, NULL );
        m_hotkeys.push_back( spec );
        m_hotkeys.push_back( spec );


        EDA_HOTKEY** info_ptr;
        EDA_HOTKEY** hotkey_descr_list;


        for( info_ptr = section->m_HK_InfoList; *info_ptr; info_ptr++ )
        // Add hotkeys descr
        for( hotkey_descr_list = section->m_HK_InfoList; *hotkey_descr_list;
             hotkey_descr_list++ )
        {
        {
            EDA_HOTKEY* info = *info_ptr;
            EDA_HOTKEY* hotkey_descr = *hotkey_descr_list;
            hotkey_spec    spec( *section->m_SectionTag, new EDA_HOTKEY( info ) );
            hotkey_spec    spec( *section->m_SectionTag, new EDA_HOTKEY( hotkey_descr ) );
            m_hotkeys.push_back( spec );
            m_hotkeys.push_back( spec );
        }
        }
    }
    }
}
}




HotkeyGridTable::hotkey_spec_vector& HotkeyGridTable::getHotkeys()
HOTKEY_EDITOR_GRID_TABLE::hotkey_spec_vector& HOTKEY_EDITOR_GRID_TABLE::getHotkeys()
{
{
    return m_hotkeys;
    return m_hotkeys;
}
}




int HotkeyGridTable::GetNumberRows()
int HOTKEY_EDITOR_GRID_TABLE::GetNumberRows()
{
{
    return m_hotkeys.size();
    return m_hotkeys.size();
}
}




int HotkeyGridTable::GetNumberCols()
int HOTKEY_EDITOR_GRID_TABLE::GetNumberCols()
{
{
    return 2;
    return 2;
}
}




bool HotkeyGridTable::IsEmptyCell( int row, int col )
bool HOTKEY_EDITOR_GRID_TABLE::IsEmptyCell( int row, int col )
{
{
    return col == 1 && m_hotkeys[row].second == 0;
    return col == 1 && m_hotkeys[row].second == NULL;
}
}




wxString HotkeyGridTable::GetValue( int row, int col )
wxString HOTKEY_EDITOR_GRID_TABLE::GetValue( int row, int col )
{
{
    EDA_HOTKEY* hotkey_descr = m_hotkeys[row].second;

    if( col == 0 )
    if( col == 0 )
    {
    {
        if( m_hotkeys[row].second == 0 )
        if( hotkey_descr == NULL )
        {
        {
            // section header
            // section header
            return m_hotkeys[row].first;
            return m_hotkeys[row].first;
        }
        }
        else
        else
        {
        {
            return m_hotkeys[row].second->m_InfoMsg;
            return hotkey_descr->m_InfoMsg;
        }
        }
    }
    }
    else
    else
    {
    {
        if( m_hotkeys[row].second == 0 )
        if( hotkey_descr == NULL )
        {
        {
            return wxString();
            // section header
            return wxEmptyString;
        }
        }
        else
        else
        {
        {
            return ReturnKeyNameFromKeyCode( m_hotkeys[row].second->m_KeyCode );
            return ReturnKeyNameFromKeyCode( hotkey_descr->m_KeyCode );
        }
        }
    }
    }
}
}




void HotkeyGridTable::SetValue( int row, int col, const wxString& value )
void HOTKEY_EDITOR_GRID_TABLE::SetValue( int row, int col, const wxString& value )
{
{
}
}




wxString HotkeyGridTable::GetTypeName( int row, int col )
wxString HOTKEY_EDITOR_GRID_TABLE::GetTypeName( int row, int col )
{
{
    return wxGRID_VALUE_STRING;
    return wxGRID_VALUE_STRING;
}
}




bool HotkeyGridTable::CanGetValueAs( int row, int col, const wxString& typeName )
bool HOTKEY_EDITOR_GRID_TABLE::CanGetValueAs( int row, int col, const wxString& typeName )
{
{
    return typeName == wxGRID_VALUE_STRING && col == 2;
    return typeName == wxGRID_VALUE_STRING && col == 2;
}
}




bool HotkeyGridTable::CanSetValueAs( int row, int col, const wxString& typeName )
bool HOTKEY_EDITOR_GRID_TABLE::CanSetValueAs( int row, int col, const wxString& typeName )
{
{
    return false;
    return false;
}
}




long HotkeyGridTable::GetValueAsLong( int row, int col )
long HOTKEY_EDITOR_GRID_TABLE::GetValueAsLong( int row, int col )
{
{
    return -1L;
    return -1L;
}
}




double HotkeyGridTable::GetValueAsDouble( int row, int col )
double HOTKEY_EDITOR_GRID_TABLE::GetValueAsDouble( int row, int col )
{
{
    return 0.0;
    return 0.0;
}
}




bool HotkeyGridTable::GetValueAsBool( int row, int col )
bool HOTKEY_EDITOR_GRID_TABLE::GetValueAsBool( int row, int col )
{
{
    return false;
    return false;
}
}




void HotkeyGridTable::SetValueAsLong( int row, int col, long value )
void HOTKEY_EDITOR_GRID_TABLE::SetValueAsLong( int row, int col, long value )
{
{
}
}




void HotkeyGridTable::SetValueAsDouble( int row, int col, double value )
void HOTKEY_EDITOR_GRID_TABLE::SetValueAsDouble( int row, int col, double value )
{
{
}
}




void HotkeyGridTable::SetValueAsBool( int row, int col, bool value )
void HOTKEY_EDITOR_GRID_TABLE::SetValueAsBool( int row, int col, bool value )
{
{
}
}




void* HotkeyGridTable::GetValueAsCustom( int row, int col )
void* HOTKEY_EDITOR_GRID_TABLE::GetValueAsCustom( int row, int col )
{
{
    return 0;
    return 0;
}
}




void HotkeyGridTable::SetValueAsCustom( int row, int col, void* value )
void HOTKEY_EDITOR_GRID_TABLE::SetValueAsCustom( int row, int col, void* value )
{
{
}
}




wxString HotkeyGridTable::GetColLabelValue( int col )
wxString HOTKEY_EDITOR_GRID_TABLE::GetColLabelValue( int col )
{
{
    return col == 0 ? _( "Command" ) : _( "Hotkey" );
    return col == 0 ? _( "Command" ) : _( "Hotkey" );
}
}




bool HotkeyGridTable::isHeader( int row )
bool HOTKEY_EDITOR_GRID_TABLE::IsHeader( int row )
{
{
    return m_hotkeys[row].second == 0;
    return m_hotkeys[row].second == NULL;
}
}




void HotkeyGridTable::SetKeyCode( int row, long key )
void HOTKEY_EDITOR_GRID_TABLE::SetKeyCode( int row, long key )
{
{
    m_hotkeys[row].second->m_KeyCode = key;
    m_hotkeys[row].second->m_KeyCode = key;
}
}




void HotkeyGridTable::RestoreFrom( struct EDA_HOTKEY_CONFIG* origin )
void HOTKEY_EDITOR_GRID_TABLE::RestoreFrom( struct EDA_HOTKEY_CONFIG* origin )
{
{
    int row = 0;
    int row = 0;
    EDA_HOTKEY_CONFIG* section;
    EDA_HOTKEY_CONFIG* section;


    for( section = origin; section->m_HK_InfoList; section++ )
    for( section = origin; section->m_HK_InfoList; section++ )
    {
    {
        ++row;
        ++row;      // Skip header
        EDA_HOTKEY** info_ptr;
        EDA_HOTKEY** info_ptr;


        for( info_ptr = section->m_HK_InfoList; *info_ptr; info_ptr++ )
        for( info_ptr = section->m_HK_InfoList; *info_ptr; info_ptr++ )
@@ -183,15 +188,10 @@ void HotkeyGridTable::RestoreFrom( struct EDA_HOTKEY_CONFIG* origin )
}
}




HotkeyGridTable::~HotkeyGridTable()
HOTKEY_EDITOR_GRID_TABLE::~HOTKEY_EDITOR_GRID_TABLE()
{
{
    hotkey_spec_vector::iterator i;
    hotkey_spec_vector::iterator i;


    for( i = m_hotkeys.begin(); i != m_hotkeys.end(); ++i )
    for( i = m_hotkeys.begin(); i != m_hotkeys.end(); ++i )
    {
        if( i->second )
        {
        delete i->second;
        delete i->second;
}
}
    }
}
Loading