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

Gerbview: fix a crash when trying to edit hotkeys. Add a few missing hotkeys.

Very minor coding style issue fix in hotkey code (pl_editor and gerbview).
Fix a compil error  using c++11 option for painstaking compilers
parent 016eef39
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -128,7 +128,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
    case ID_NOCONN_BUTT:
        if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
        {
            if( false == GetScreen()->GetItem( gridPosition, 0, SCH_NO_CONNECT_T ) )
            if( GetScreen()->GetItem( gridPosition, 0, SCH_NO_CONNECT_T ) == NULL )
            {
                SCH_NO_CONNECT*  no_connect = AddNoConnect( aDC, gridPosition );
                SetRepeatItem( no_connect );
@@ -145,7 +145,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
    case ID_JUNCTION_BUTT:
        if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
        {
            if( false == GetScreen()->GetItem( gridPosition, 0, SCH_JUNCTION_T ) )
            if( GetScreen()->GetItem( gridPosition, 0, SCH_JUNCTION_T ) == NULL )
            {
                SCH_JUNCTION* junction = AddJunction( aDC, gridPosition, true );
                SetRepeatItem( junction );
+1 −1
Original line number Diff line number Diff line
@@ -140,7 +140,7 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )

    // Must be called before creating the main frame in order to
    // display the real hotkeys in menus or tool tips
    ReadHotkeyConfig( GERBVIEW_FRAME_NAME, s_Gerbview_Hokeys_Descr );
    ReadHotkeyConfig( GERBVIEW_FRAME_NAME, GerbviewHokeysDescr );

    return true;
}
+4 −4
Original line number Diff line number Diff line
@@ -55,21 +55,21 @@ void GERBVIEW_FRAME::Process_Config( wxCommandEvent& event )
    {
    // Hotkey IDs
    case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG:
        ExportHotkeyConfigToFile( s_Gerbview_Hokeys_Descr, wxT( "gerbview" ) );
        ExportHotkeyConfigToFile( GerbviewHokeysDescr, wxT( "gerbview" ) );
        break;

    case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG:
        ImportHotkeyConfigFromFile( s_Gerbview_Hokeys_Descr, wxT( "gerbview" ) );
        ImportHotkeyConfigFromFile( GerbviewHokeysDescr, wxT( "gerbview" ) );
        break;

    case ID_PREFERENCES_HOTKEY_SHOW_EDITOR:
        InstallHotkeyFrame( this, s_Gerbview_Hokeys_Descr );
        InstallHotkeyFrame( this, GerbviewHokeysDescr );
        break;

    case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST:

        // Display current hotkey list for GerbView.
        DisplayHotkeyList( this, s_Gerbview_Hokeys_Descr );
        DisplayHotkeyList( this, GerbviewHokeysDescr );
        break;

    default:
+2 −2
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ):

    m_showAxis = true;                      // true to show X and Y axis on screen
    m_showBorderAndTitleBlock   = false;    // true for reference drawings.
    m_HotkeysZoomAndGridList    = s_Gerbview_Hokeys_Descr;
    m_HotkeysZoomAndGridList    = GerbviewHokeysDescr;
    m_SelLayerBox   = NULL;
    m_DCodeSelector = NULL;
    m_displayMode   = 0;
@@ -874,7 +874,7 @@ void GERBVIEW_FRAME::UpdateStatusBar()

    case UNSCALED_UNITS:
        absformatter = wxT( "X %f  Y %f" );
        locformatter = wxT( "dx %f  dy %f  d %f" );
        locformatter = wxT( "dx %f  dy %f  dist %f" );
        break;

    case DEGREES:
+54 −28
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#include <gerbview_frame.h>
#include <class_drawpanel.h>
#include <hotkeys.h>
#include <gerbview_id.h>


/* How to add a new hotkey:
@@ -58,27 +59,31 @@

// local variables
// Hotkey list:
static EDA_HOTKEY   HkResetLocalCoord( wxT( "Reset Local Coordinates" ), HK_RESET_LOCAL_COORD, ' ' );
static EDA_HOTKEY   HkSetGridOrigin( wxT("Set Grid Origin"), HK_SET_GRID_ORIGIN, 'S' );

static EDA_HOTKEY   HkZoomAuto( wxT( "Zoom Auto" ), HK_ZOOM_AUTO, WXK_HOME );
static EDA_HOTKEY   HkZoomCenter( wxT( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4 );
static EDA_HOTKEY   HkZoomRedraw( wxT( "Zoom Redraw" ), HK_ZOOM_REDRAW, WXK_F3 );
static EDA_HOTKEY   HkZoomOut( wxT( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2 );
static EDA_HOTKEY   HkZoomIn( wxT( "Zoom In" ), HK_ZOOM_IN, WXK_F1 );
static EDA_HOTKEY   HkHelp( wxT( "Help (this window)" ), HK_HELP, '?' );
static EDA_HOTKEY   HkSwitchUnits( wxT( "Switch Units" ), HK_SWITCH_UNITS, 'U' );
static EDA_HOTKEY   HkTrackDisplayMode( wxT( "Track Display Mode" ), HK_SWITCH_GBR_ITEMS_DISPLAY_MODE, 'F' );

static EDA_HOTKEY   HkSwitch2NextCopperLayer( wxT( "Switch to Next Layer" ), HK_SWITCH_LAYER_TO_NEXT, '+' );
static EDA_HOTKEY   HkSwitch2PreviousCopperLayer( wxT( "Switch to Previous Layer" ), HK_SWITCH_LAYER_TO_PREVIOUS, '-' );
static EDA_HOTKEY   HkZoomAuto( _HKI( "Zoom Auto" ), HK_ZOOM_AUTO, WXK_HOME );
static EDA_HOTKEY   HkZoomCenter( _HKI( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4 );
static EDA_HOTKEY   HkZoomRedraw( _HKI( "Zoom Redraw" ), HK_ZOOM_REDRAW, WXK_F3 );
static EDA_HOTKEY   HkZoomOut( _HKI( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2 );
static EDA_HOTKEY   HkZoomIn( _HKI( "Zoom In" ), HK_ZOOM_IN, WXK_F1 );
static EDA_HOTKEY   HkHelp( _HKI( "Help (this window)" ), HK_HELP, '?' );
static EDA_HOTKEY   HkSwitchUnits( _HKI( "Switch Units" ), HK_SWITCH_UNITS, 'U' );
static EDA_HOTKEY   HkResetLocalCoord( _HKI( "Reset Local Coordinates" ), HK_RESET_LOCAL_COORD, ' ' );

static EDA_HOTKEY   HkLinesDisplayMode( _HKI( "Gbr Lines Display Mode" ), HK_GBR_LINES_DISPLAY_MODE, 'L' );
static EDA_HOTKEY   HkFlashedDisplayMode( _HKI( "Gbr Flashed Display Mode" ), HK_GBR_FLASHED_DISPLAY_MODE, 'F' );
static EDA_HOTKEY   HkPolygonDisplayMode( _HKI( "Gbr Polygons Display Mode" ), HK_GBR_POLYGON_DISPLAY_MODE, 'P' );
static EDA_HOTKEY   HkNegativeObjDisplayMode( _HKI( "Gbr Negative Obj Display Mode" ), HK_GBR_NEGATIVE_DISPLAY_ONOFF, 'N' );
static EDA_HOTKEY   HkDCodesDisplayMode( _HKI( "DCodes Display Mode" ), HK_GBR_DCODE_DISPLAY_ONOFF, 'D' );

static EDA_HOTKEY   HkSwitch2NextCopperLayer( _HKI( "Switch to Next Layer" ), HK_SWITCH_LAYER_TO_NEXT, '+' );
static EDA_HOTKEY   HkSwitch2PreviousCopperLayer( _HKI( "Switch to Previous Layer" ), HK_SWITCH_LAYER_TO_PREVIOUS, '-' );

// List of common hotkey descriptors
EDA_HOTKEY* s_Gerbview_Hotkey_List[] = {
EDA_HOTKEY* gerbviewHotkeyList[] = {
    &HkHelp,
    &HkZoomIn,                      &HkZoomOut,         &HkZoomRedraw,  &HkZoomCenter,
    &HkZoomAuto,    &HkSwitchUnits, &HkResetLocalCoord, &HkSetGridOrigin,
    &HkTrackDisplayMode,
    &HkZoomAuto,    &HkSwitchUnits, &HkResetLocalCoord,
    &HkLinesDisplayMode, &HkFlashedDisplayMode, &HkPolygonDisplayMode,
    &HkDCodesDisplayMode, &HkNegativeObjDisplayMode,
    &HkSwitch2NextCopperLayer,
    &HkSwitch2PreviousCopperLayer,
    NULL
@@ -87,15 +92,20 @@ EDA_HOTKEY* s_Gerbview_Hotkey_List[] = {

// list of sections and corresponding hotkey list for GerbView (used to create an hotkey
// config file)
struct EDA_HOTKEY_CONFIG s_Gerbview_Hokeys_Descr[] =
static wxString gerbviewSectionTag( wxT( "[gerbview]" ) );
static wxString gerbviewSectionTitle( _HKI( "Gerbview Hotkeys" ) );

struct EDA_HOTKEY_CONFIG GerbviewHokeysDescr[] =
{
    { &g_CommonSectionTag, s_Gerbview_Hotkey_List, NULL  },
    { &gerbviewSectionTag, gerbviewHotkeyList, &gerbviewSectionTitle  },
    { NULL,                NULL,               NULL  }
};


bool GERBVIEW_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosition, EDA_ITEM* aItem )
{
    #define CHANGE( x ) ( x ) = not (x )

    wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
    cmd.SetEventObject( this );

@@ -104,7 +114,7 @@ bool GERBVIEW_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
    if( (aHotkeyCode >= 'a') && (aHotkeyCode <= 'z') )
        aHotkeyCode += 'A' - 'a';

    EDA_HOTKEY * HK_Descr = GetDescriptorFromHotkey( aHotkeyCode, s_Gerbview_Hotkey_List );
    EDA_HOTKEY * HK_Descr = GetDescriptorFromHotkey( aHotkeyCode, gerbviewHotkeyList );

    if( HK_Descr == NULL )
        return false;
@@ -116,7 +126,7 @@ bool GERBVIEW_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
        return false;

    case HK_HELP:       // Display Current hotkey list
        DisplayHotkeyList( this, s_Gerbview_Hokeys_Descr );
        DisplayHotkeyList( this, GerbviewHokeysDescr );
        break;

    case HK_ZOOM_IN:
@@ -148,16 +158,32 @@ bool GERBVIEW_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
        GetScreen()->m_O_Curseur = GetCrossHairPosition();
        break;

    case HK_SET_GRID_ORIGIN:
        SetGridOrigin( GetCrossHairPosition() );
        break;

    case HK_SWITCH_UNITS:
        g_UserUnit = (g_UserUnit == INCHES ) ? MILLIMETRES : INCHES;
        break;

    case HK_SWITCH_GBR_ITEMS_DISPLAY_MODE:
        m_DisplayOptions.m_DisplayLinesFill = not m_DisplayOptions.m_DisplayLinesFill;
    case HK_GBR_LINES_DISPLAY_MODE:
        CHANGE(  m_DisplayOptions.m_DisplayLinesFill );
        m_canvas->Refresh();
        break;

    case HK_GBR_FLASHED_DISPLAY_MODE:
        CHANGE( m_DisplayOptions.m_DisplayFlashedItemsFill );
        m_canvas->Refresh( true );
        break;

    case HK_GBR_POLYGON_DISPLAY_MODE:
        CHANGE( m_DisplayOptions.m_DisplayPolygonsFill );
        m_canvas->Refresh();
        break;

    case HK_GBR_NEGATIVE_DISPLAY_ONOFF:
        SetElementVisibility( NEGATIVE_OBJECTS_VISIBLE, not IsElementVisible( NEGATIVE_OBJECTS_VISIBLE ) );
        m_canvas->Refresh();
        break;

    case HK_GBR_DCODE_DISPLAY_ONOFF:
        SetElementVisibility( DCODES_VISIBLE, not IsElementVisible( DCODES_VISIBLE ) );
        m_canvas->Refresh();
        break;

Loading