Commit f5eae506 authored by CHARRAS's avatar CHARRAS
Browse files

more work on hotkeys. many features are ok.

parent 90e28dd1
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -4,6 +4,15 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with 
email address.

2007-aug-30 UPDATE   Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+ eeschema & pcbnew
	more about programmable hotkeys.
	Most existing hotkeys are programmable and displayed in popup menus or tools
	Work still in progress but most features are ok.
	some features are not fixed (mainly the configuration files path, which is
	currently the home directory under unix systems and kicad/template under windows))


2007-Aug-29 UPDATE   Dick Hollenbeck <dick@softplc.com>
================================================================================
+420 −327
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@
#include "macros.h"

/* Class to handle hotkey commnands. hotkeys have a default value
This class allows (for the future..) the real key code changed by user(from a key code list file, TODO)
 *  This class allows (for the future..) the real key code changed by user(from a key code list file, TODO)
 */

Ki_HotkeyInfo::Ki_HotkeyInfo( const wxChar* infomsg, int idcommand, int keycode )
@@ -21,14 +21,17 @@ Ki_HotkeyInfo::Ki_HotkeyInfo(const wxChar * infomsg, int idcommand, int keycode)
    m_Idcommand = idcommand;    // internal id for the corresponding command (see hotkey_id_commnand list)
}


/* class to handle the printable name and the keycode
 */
struct hotkey_name_descr {
struct hotkey_name_descr
{
    wxChar* m_Name;
    int     m_KeyCode;
};

struct hotkey_name_descr s_Notkey_Name_List[] = {
struct hotkey_name_descr s_Hotkey_Name_List[] =
{
    { wxT( "F1" ),        WXK_F1           },
    { wxT( "F2" ),        WXK_F2           },
    { wxT( "F3" ),        WXK_F3           },
@@ -55,8 +58,20 @@ struct hotkey_name_descr s_Notkey_Name_List[] = {
    { wxT( "+" ),         WXK_ADD          },
    { wxT( "-" ),         WXK_SUBTRACT     },

    { wxT( "Up" ),        WXK_UP           },
    { wxT( "Down" ),      WXK_DOWN         },
    { wxT( "Left" ),      WXK_LEFT         },
    { wxT( "Right" ),     WXK_RIGHT        },

    { wxT( "space" ),     ' '              },
    { wxT( "?" ),         '?'              },
    { wxT( "!" ),         '!'              },
    { wxT( ":" ),         ':'              },
    { wxT( "," ),         ','              },
    { wxT( "*" ),         '*'              },
    { wxT( "+" ),         '+'              },
    { wxT( "-" ),         '-'              },
    { wxT( "\%" ),         '%'              },
    { wxT( "A" ),         'A'              },
    { wxT( "B" ),         'B'              },
    { wxT( "C" ),         'C'              },
@@ -118,6 +133,7 @@ struct hotkey_name_descr s_Notkey_Name_List[] = {
/****************************************************/
wxString ReturnKeyNameFromKeyCode( int keycode )
/****************************************************/

/*
 * return the key name from the key code
 * Only some wxWidgets key values are handled for function key
@@ -128,21 +144,24 @@ wxString ReturnKeyNameFromKeyCode(int keycode)
    wxString keyname, modifier, fullkeyname;
    int      ii;

	if ( (keycode & GR_KB_CTRL) != 0 ) modifier << wxT("Ctrl ");
	if ( (keycode & GR_KB_ALT) != 0 ) modifier << wxT("Alt ");
	if ( (keycode & GR_KB_SHIFT) != 0 ) modifier << wxT("Shift ");
    if( (keycode & GR_KB_CTRL) != 0 )
        modifier << wxT( "Ctrl " );
    if( (keycode & GR_KB_ALT) != 0 )
        modifier << wxT( "Alt " );
    if( (keycode & GR_KB_SHIFT) != 0 )
        modifier << wxT( "Shift " );

    keycode &= ~(GR_KB_CTRL | GR_KB_ALT | GR_KB_SHIFT);
    for( ii = 0; ; ii++ )
    {
		if ( s_Notkey_Name_List[ii].m_KeyCode == 0 )
        if( s_Hotkey_Name_List[ii].m_KeyCode == 0 )
        {
            keyname = wxT( "<unknown>" );
            break;
        }
		if ( s_Notkey_Name_List[ii].m_KeyCode == keycode)
        if( s_Hotkey_Name_List[ii].m_KeyCode == keycode )
        {
			keyname = s_Notkey_Name_List[ii].m_Name;
            keyname = s_Hotkey_Name_List[ii].m_Name;
            break;
        }
    }
@@ -151,13 +170,62 @@ int ii;
    return fullkeyname;
}


/**********************************************************************************/
wxString AddHotkeyName( const wxString& text, Ki_HotkeyInfo** List, int CommandId )
/**********************************************************************************/

/*
 * Add the key name from the Command id value ( m_Idcommand member value)
 * @param List = pointer to a Ki_HotkeyInfo list of commands
 * @param CommandId = Command Id value
 * @return text (key name) in a wxString if found or text without modification
 */
{
    wxString msg     = text;
    wxString keyname = ReturnKeyNameFromCommandId( List, CommandId );

    if( !keyname.IsEmpty() )
        msg << wxT( " (" ) << keyname << wxT( ")" );
    return msg;
}


/***********************************************************************/
wxString ReturnKeyNameFromCommandId( Ki_HotkeyInfo** List, int CommandId )
/***********************************************************************/

/*
 * return the key name from the Command id value ( m_Idcommand member value)
 * @param List = pointer to a Ki_HotkeyInfo list of commands
 * @param CommandId = Command Id value
 * @return the key name in a wxString
 */
{
    wxString keyname;

    for( ; *List != NULL; List++ )
    {
        Ki_HotkeyInfo* hk_decr = *List;
        if( hk_decr->m_Idcommand == CommandId )
        {
            keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode );
            break;
        }
    }

    return keyname;
}


/************************************************************/
static int ReturnKeyCodeFromKeyName( const wxString& keyname )
/************************************************************/

/*
 * return the key code from its key name
 * Only some wxWidgets key values are handled for function key
	* @param keyname = wxString key name to find in s_Notkey_Name_List[]
 * @param keyname = wxString key name to find in s_Hotkey_Name_List[]
 * @return the key code
 */
{
@@ -165,10 +233,11 @@ int ii, keycode = 0;

    for( ii = 0; ; ii++ )
    {
		if ( s_Notkey_Name_List[ii].m_KeyCode == 0 ) break;
		if ( s_Notkey_Name_List[ii].m_Name == keyname)
        if( s_Hotkey_Name_List[ii].m_KeyCode == 0 )  // End of list reached
            break;
        if( keyname.CmpNoCase( s_Hotkey_Name_List[ii].m_Name ) == 0 )
        {
			keycode = s_Notkey_Name_List[ii].m_KeyCode;
            keycode = s_Hotkey_Name_List[ii].m_KeyCode;
            break;
        }
    }
@@ -176,9 +245,11 @@ int ii, keycode = 0;
    return keycode;
}


/****************************************************************************/
void DisplayHotkeyList( WinEDA_DrawFrame* frame, Ki_HotkeyInfo** List )
/*****************************************************************************/

/*
 * Displays the current hotkey list
 * @param frame = current open frame
@@ -189,6 +260,7 @@ void DisplayHotkeyList(WinEDA_DrawFrame * frame, Ki_HotkeyInfo ** List)
    wxString keyname;

    wxString msg = _( "Current hotkey list:\n\n" );

    for( ; *List != NULL; List++ )
    {
        Ki_HotkeyInfo* hk_decr = *List;
@@ -196,12 +268,15 @@ wxString keyname;
        keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode );
        msg += keyname + wxT( ":    " ) + hk_decr->m_InfoMsg + wxT( "\n" );
    }

    DisplayInfo( frame, msg );
}


/******************************************************************/
int GetCommandCodeFromHotkey( int key, Ki_HotkeyInfo** List )
/******************************************************************/

/*
 * Return an id identifier fron a key code for OnHotKey() function
 * @param key = key code (ascii value, or wxWidgets value for function keys
@@ -212,16 +287,19 @@ int GetCommandCodeFromHotkey(int key, Ki_HotkeyInfo ** List)
    for( ; *List != NULL; List++ )
    {
        Ki_HotkeyInfo* hk_decr = *List;
		if ( hk_decr->m_KeyCode == key ) return hk_decr->m_Idcommand;
        if( hk_decr->m_KeyCode == key )
            return hk_decr->m_Idcommand;
    }

    return 0;
}


/*************************************************************************/
int WinEDA_BasicFrame::WriteHotkeyConfigFile( const wxString& Filename,
                                              Ki_HotkeyInfo** List, bool verbose )
/*************************************************************************/

/*
 * Create a configuration file (*.key) from the current hotkey list
 * @param Filename = default full file name to create. If void, A filename will be asked
@@ -234,6 +312,7 @@ int WinEDA_BasicFrame::WriteHotkeyConfigFile(const wxString & Filename,
    wxString FullFilename = Filename;
    FILE*    cfgfile;
    wxString msg;

    if( FullFilename.IsEmpty() || verbose )
    {
        wxString Mask, Path, Ext;
@@ -250,7 +329,8 @@ int WinEDA_BasicFrame::WriteHotkeyConfigFile(const wxString & Filename,
                                         TRUE
                                         );
    }
	if ( FullFilename.IsEmpty() ) return 0;
    if( FullFilename.IsEmpty() )
        return 0;

    cfgfile = wxFopen( FullFilename, wxT( "wt" ) );

@@ -276,10 +356,13 @@ wxString keyname, infokey;
    msg.Empty();
    for( int ii = 0; ; ii++ )
    {
		if ( s_Notkey_Name_List[ii].m_KeyCode == 0 ) break;;
		if ( msg.IsEmpty() ) msg = wxT("# ");
		else msg +=  wxT(", ");
		msg += s_Notkey_Name_List[ii].m_Name;
        if( s_Hotkey_Name_List[ii].m_KeyCode == 0 )
            break;;
        if( msg.IsEmpty() )
            msg = wxT( "# " );
        else
            msg += wxT( ", " );
        msg += s_Hotkey_Name_List[ii].m_Name;
        if( msg.Len() > 60 )
        {
            msg += wxT( "\n" );
@@ -287,8 +370,10 @@ wxString keyname, infokey;
            msg.Empty();
        }
    }

    /* print the last line */
	if ( ! msg.IsEmpty() ) msg += wxT("\n");
    if( !msg.IsEmpty() )
        msg += wxT( "\n" );
    msg += wxT( "#\n#\n" );
    fprintf( cfgfile, CONV_TO_UTF8( msg ) );

@@ -304,6 +389,7 @@ wxString keyname, infokey;
        msg += keyname + wxT( ":    " ) + infokey + wxT( "\n" );
        fprintf( cfgfile, CONV_TO_UTF8( msg ) );
    }

    msg = wxT( "$Endlist\n" );
    fprintf( cfgfile, CONV_TO_UTF8( msg ) );
    fclose( cfgfile );
@@ -315,6 +401,7 @@ wxString keyname, infokey;
int WinEDA_BasicFrame::ReadHotkeyConfigFile( const wxString& Filename,
                                             Ki_HotkeyInfo** CurrentHotkeyList, bool verbose )
/********************************************************************************************/

/*
 * Read a configuration file (<file>.key) and fill the current hotkey list with hotkeys
 * @param Filename = default full file name to create. If void, A filename will be asked
@@ -327,6 +414,7 @@ int WinEDA_BasicFrame::ReadHotkeyConfigFile(const wxString & Filename,
    wxString FullFilename = Filename;
    FILE*    cfgfile;
    wxString msg;

    if( FullFilename.IsEmpty() || verbose )
    {
        wxString Mask, Path, Ext;
@@ -342,7 +430,8 @@ int WinEDA_BasicFrame::ReadHotkeyConfigFile(const wxString & Filename,
                                         wxFD_OPEN,
                                         TRUE
                                         );
		if ( FullFilename.IsEmpty() ) return 0;
        if( FullFilename.IsEmpty() )
            return 0;
    }

    cfgfile = wxFopen( FullFilename, wxT( "rt" ) );
@@ -366,8 +455,10 @@ int WinEDA_BasicFrame::ReadHotkeyConfigFile(const wxString & Filename,
        char* line_type, * keyname, * fctname;
        line_type = strtok( Line, " \t\n\r" );
        msg = CONV_FROM_UTF8( line_type );
		if( msg != wxT("shortcut") ) continue;
		if( msg == wxT("$Endlist") ) break;
        if( msg != wxT( "shortcut" ) )
            continue;
        if( msg == wxT( "$Endlist" ) )
            break;

        /* Get the key name */
        strtok( NULL, "\"\n\r" );
@@ -384,11 +475,13 @@ int WinEDA_BasicFrame::ReadHotkeyConfigFile(const wxString & Filename,
            {
                msg = CONV_FROM_UTF8( keyname );
                int code = ReturnKeyCodeFromKeyName( msg );
				if ( code ) hk_decr->m_KeyCode = code;
                if( code )
                    hk_decr->m_KeyCode = code;
                break;
            }
        }
    }

    fclose( cfgfile );
    return 1;
}
+3 −7
Original line number Diff line number Diff line
@@ -294,6 +294,9 @@ void WinEDA_DrawFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels

    switch( g_KeyPressed )
    {
    case 0:
        break;

    case EDA_PANNING_UP_KEY:
        OnZoom( ID_ZOOM_PANNING_UP );
        curpos = m_CurrentScreen->m_Curseur;
@@ -315,23 +318,16 @@ void WinEDA_DrawFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels
        break;

	case EDA_ZOOM_IN_FROM_MOUSE:
    case WXK_F1:
        OnZoom( ID_ZOOM_PLUS_KEY );
        curpos = m_CurrentScreen->m_Curseur;
        break;

	case EDA_ZOOM_OUT_FROM_MOUSE:
    case WXK_F2:
        OnZoom( ID_ZOOM_MOINS_KEY );
        curpos = m_CurrentScreen->m_Curseur;
        break;

    case WXK_F3:
        OnZoom( ID_ZOOM_REDRAW_KEY );
        break;

	case EDA_ZOOM_CENTER_FROM_MOUSE:
    case WXK_F4:
        OnZoom( ID_ZOOM_CENTER_KEY );
        curpos = m_CurrentScreen->m_Curseur;
        break;
+69 −65
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ IMPLEMENT_APP(WinEDA_App)
bool WinEDA_App::OnInit( void )
{
    wxString FFileName;

    EDA_Appl = this;

    g_DebugLevel = 0;   // Debug level */
@@ -57,17 +58,22 @@ wxString FFileName;
            return false;
    }

	if(argc > 1 ) FFileName = argv[1];
    if( argc > 1 )
        FFileName = argv[1];

    CreateScreens();

    /* init EESCHEMA */
    GetSettings();                                  // read current setup
    SeedLayers();
    Read_Hotkey_Config( SchematicFrame, false );    /* Must be called before creating the main frame
                                                     *  in order to display the real hotkeys in menus
                                                     *  or tool tips */

    // Create main frame (schematic frame) :
    SchematicFrame = new WinEDA_SchematicFrame( NULL, this,
					 wxT("EESchema"), wxPoint(0,0), wxSize(600,400) );
                                               wxT( "EESchema" ),
                                               wxPoint( 0, 0 ), wxSize( 600, 400 ) );

    SetTopWindow( SchematicFrame );
    SchematicFrame->Show( TRUE );
@@ -80,7 +86,6 @@ wxString FFileName;
    }

    SchematicFrame->Zoom_Automatique( TRUE );
	Read_Hotkey_Config(SchematicFrame, false);

    /* Load file specified in the command line. */
    if( !FFileName.IsEmpty() )
@@ -91,7 +96,6 @@ wxString FFileName;
            if( SchematicFrame->LoadOneEEProject( FFileName, FALSE ) <= 0 )
                SchematicFrame->DrawPanel->Refresh( TRUE ); // File not found or error
    }

    else
    {
        Read_Config( wxEmptyString, TRUE ); // Read config file ici si pas de fichier a charger
@@ -106,8 +110,9 @@ wxString FFileName;
/******************************/
static void CreateScreens( void )
/******************************/

/*
 Fonction d'init des crans utiliss dans EESchema:
 *  Fonction d'init des crans utiliss dans EESchema:
 */
{
    /* creation des ecrans Sch , Lib  */
@@ -123,4 +128,3 @@ static void CreateScreens(void)
    ScreenLib->SetZoom( 4 );
    ScreenLib->m_UndoRedoCountMax = 10;
}
+335 −283
Original line number Diff line number Diff line
@@ -13,42 +13,45 @@

#include "id.h"

#include "hotkeys_basic.h"
#include "hotkeys.h"

#include "protos.h"

enum hotkey_id_commnand {
	HK_NOT_FOUND = 0,
	HK_RESET_LOCAL_COORD,
	HK_HELP,
	HK_ZOOM_IN,
	HK_ZOOM_OUT,
	HK_ZOOM_REDRAW,
	HK_ZOOM_CENTER,
	HK_NEXT_SEARCH,
	HK_DELETE,
	HK_REPEAT_LAST,
	HK_MOVEBLOCK_TO_DRAGBLOCK,
	HK_ROTATE_COMPONENT,
	HK_MIRROR_X_COMPONENT,
	HK_MIRROR_Y_COMPONENT,
	HK_ORIENT_NORMAL_COMPONENT,
	HK_MOVE_COMPONENT,
	HK_ADD_NEW_COMPONENT,
	HK_BEGIN_WIRE
};
/* How to add a new hotkey:
 *  add a new id in the enum hotkey_id_commnand like MY_NEW_ID_FUNCTION (see hotkeys.h).
 *  add a new Ki_HotkeyInfo entry like:
 *  static Ki_HotkeyInfo HkMyNewEntry(wxT("Command Label"), MY_NEW_ID_FUNCTION, default key value);
 *      "Command Label" is the name used in hotkey list display, and the identifier in the hotkey list file
 *      MY_NEW_ID_FUNCTION is an equivalent id function used in the switch in OnHotKey() function.
 *      default key value is the default hotkey for this command. Can be overrided by the user hotkey list file
 *  add the HkMyNewEntry pointer in the s_Schematic_Hotkey_List list ( or/and the s_LibEdit_Hotkey_List list)
 *  Add the new code in the switch in OnHotKey() function.
 *  when the variable PopupOn is true, an item is currently edited.
 *  This can be usefull if the new function cannot be executed while an item is currently being edited
 *  ( For example, one cannot start a new wire when a component is moving.)
 *
 *  Note: If an hotkey is a special key be sure the corresponding wxWidget keycode (WXK_XXXX)
 *  is handled in the hotkey_name_descr s_Hotkey_Name_List list (see hotkeys_basic.cpp)
 *  and see this list for some ascii keys (space ...)
 */


/* local variables */
/* Hotkey list: */
static Ki_HotkeyInfo    HkBeginWire( wxT( "begin Wire" ), HK_BEGIN_WIRE, 'W' );
static Ki_HotkeyInfo    HkAddComponent( wxT( "Add Component" ), HK_ADD_NEW_COMPONENT, 'A' );
static Ki_HotkeyInfo HkMirrorYComponent(wxT("Mirror Y Component"), HK_MIRROR_Y_COMPONENT, 'Y');
static Ki_HotkeyInfo HkMirrorXComponent(wxT("Mirror X Component"), HK_MIRROR_X_COMPONENT, 'X');
static Ki_HotkeyInfo HkOrientNormalComponent(wxT("Orient Normal Component"), HK_ORIENT_NORMAL_COMPONENT, 'N');
static Ki_HotkeyInfo    HkMirrorYComponent( wxT(
                                                "Mirror Y Component" ), HK_MIRROR_Y_COMPONENT, 'Y' );
static Ki_HotkeyInfo    HkMirrorXComponent( wxT(
                                                "Mirror X Component" ), HK_MIRROR_X_COMPONENT, 'X' );
static Ki_HotkeyInfo    HkOrientNormalComponent( wxT(
                                                     "Orient Normal Component" ),
                                                 HK_ORIENT_NORMAL_COMPONENT, 'N' );
static Ki_HotkeyInfo    HkRotateComponent( wxT( "Rotate Component" ), HK_ROTATE_COMPONENT, 'R' );
static Ki_HotkeyInfo    HkMoveComponent( wxT( "Move Component" ), HK_MOVE_COMPONENT, 'M' );
static Ki_HotkeyInfo HkMove2Drag(wxT("Switch move block to drag block"), HK_MOVEBLOCK_TO_DRAGBLOCK, '\t');
static Ki_HotkeyInfo    HkMove2Drag( wxT(
                                         "Switch move block to drag block" ),
                                     HK_MOVEBLOCK_TO_DRAGBLOCK, '\t' );
static Ki_HotkeyInfo    HkInsert( wxT( "Repeat Last Item" ), HK_REPEAT_LAST, WXK_INSERT );
static Ki_HotkeyInfo    HkDelete( wxT( "Delete Item" ), HK_DELETE, WXK_DELETE );
static Ki_HotkeyInfo    HkResetLocalCoord( wxT( "Reset local coord." ), HK_RESET_LOCAL_COORD, ' ' );
@@ -88,26 +91,30 @@ Ki_HotkeyInfo *s_LibEdit_Hotkey_List[] =
void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
                                      EDA_BaseStruct* DrawStruct )
/***********************************************************/

/* Hot keys. Some commands are relatives to the item under the mouse cursor
	Commands are case insensitive
	Zoom commands are not managed here
 *  Commands are case insensitive
 */
{
bool PopupOn = m_CurrentScreen->GetCurItem()  &&
			m_CurrentScreen->GetCurItem()->m_Flags;
    bool PopupOn = m_CurrentScreen->GetCurItem()
                   && m_CurrentScreen->GetCurItem()->m_Flags;
    bool RefreshToolBar = FALSE; // We must refresh tool bar when the undo/redo tool state is modified

	if ( hotkey == 0 ) return;
    if( hotkey == 0 )
        return;

    wxPoint MousePos = m_CurrentScreen->m_MousePosition;

    // Remap the control key Ctrl A (0x01) to GR_KB_CTRL + 'A' (easier to handle...)
	if ( (hotkey & GR_KB_CTRL) != 0 ) hotkey += 'A' - 1;
    if( (hotkey & GR_KB_CTRL) != 0 )
        hotkey += 'A' - 1;
    /* Convert lower to upper case (the usual toupper function has problem with non ascii codes like function keys */
	if( (hotkey >= 'a') && (hotkey <= 'z') ) hotkey += 'A' - 'a';
    if( (hotkey >= 'a') && (hotkey <= 'z') )
        hotkey += 'A' - 'a';

    // Search command from key :
    int CommandCode = GetCommandCodeFromHotkey( hotkey, s_Schematic_Hotkey_List );

    switch( CommandCode )
    {
    default:
@@ -124,9 +131,19 @@ wxPoint MousePos = m_CurrentScreen->m_MousePosition;
        break;

    case HK_ZOOM_IN:
        OnZoom( ID_ZOOM_PLUS_KEY );
        break;

    case HK_ZOOM_OUT:
        OnZoom( ID_ZOOM_MOINS_KEY );
        break;

    case HK_ZOOM_REDRAW:
        OnZoom( ID_ZOOM_REDRAW_KEY );
        break;

    case HK_ZOOM_CENTER:
        OnZoom( ID_ZOOM_CENTER_KEY );
        break;

    case HK_MOVEBLOCK_TO_DRAGBLOCK:        // Switch to drag mode, when block moving
@@ -134,7 +151,8 @@ wxPoint MousePos = m_CurrentScreen->m_MousePosition;
        break;

    case HK_DELETE:
			if ( PopupOn ) break;
        if( PopupOn )
            break;
        RefreshToolBar = LocateAndDeleteItem( this, DC );
        m_CurrentScreen->SetModify();
        m_CurrentScreen->SetCurItem( NULL );
@@ -146,18 +164,24 @@ wxPoint MousePos = m_CurrentScreen->m_MousePosition;
        {
            RepeatDrawItem( DC );
        }
			else wxBell();
        else
            wxBell();
        break;

    case HK_NEXT_SEARCH:
			if ( g_LastSearchIsMarker ) WinEDA_SchematicFrame::FindMarker(1);
			else FindSchematicItem(wxEmptyString, 2);
        if( g_LastSearchIsMarker )
            WinEDA_SchematicFrame::FindMarker( 1 );
        else
            FindSchematicItem( wxEmptyString, 2 );
        break;

    case HK_ADD_NEW_COMPONENT:      // Add component
			if ( DrawStruct && DrawStruct->m_Flags ) break;
        if( DrawStruct && DrawStruct->m_Flags )
            break;

        // switch to m_ID_current_state = ID_COMPONENT_BUTT;
            if ( m_ID_current_state != ID_COMPONENT_BUTT ) SetToolID( ID_COMPONENT_BUTT, wxCURSOR_PENCIL, _("Add Component"));
        if( m_ID_current_state != ID_COMPONENT_BUTT )
            SetToolID( ID_COMPONENT_BUTT, wxCURSOR_PENCIL, _( "Add Component" ) );
        OnLeftClick( DC, MousePos );
        break;

@@ -169,13 +193,17 @@ wxPoint MousePos = m_CurrentScreen->m_MousePosition;
                if( DrawStruct->m_StructType == DRAW_SEGMENT_STRUCT_TYPE )
                {
                    EDA_DrawLineStruct* segment = (EDA_DrawLineStruct*) DrawStruct;
						if ( segment->m_Layer != LAYER_WIRE ) break;
                    if( segment->m_Layer != LAYER_WIRE )
                        break;
                }
					else break;
                else
                    break;
            }
        }

        // switch to m_ID_current_state = ID_WIRE_BUTT;
            if ( m_ID_current_state != ID_WIRE_BUTT ) SetToolID( ID_WIRE_BUTT, wxCURSOR_PENCIL, _("Add Wire"));
        if( m_ID_current_state != ID_WIRE_BUTT )
            SetToolID( ID_WIRE_BUTT, wxCURSOR_PENCIL, _( "Add Wire" ) );
        OnLeftClick( DC, MousePos );
        break;

@@ -184,11 +212,14 @@ wxPoint MousePos = m_CurrentScreen->m_MousePosition;
        {
            DrawStruct = PickStruct( GetScreen()->m_Curseur,
                                     GetScreen()->EEDrawList, LIBITEM | TEXTITEM | LABELITEM );
				if ( DrawStruct == NULL ) break;
            if( DrawStruct == NULL )
                break;
            if( DrawStruct->m_StructType == DRAW_LIB_ITEM_STRUCT_TYPE )
                DrawStruct = LocateSmallestComponent( GetScreen() );
				if ( DrawStruct == NULL ) break;
            if( DrawStruct == NULL )
                break;
        }

        switch( DrawStruct->m_StructType )
        {
        case DRAW_LIB_ITEM_STRUCT_TYPE:
@@ -213,8 +244,10 @@ wxPoint MousePos = m_CurrentScreen->m_MousePosition;
            ChangeTextOrient( (DrawTextStruct*) DrawStruct, DC );
            break;

                default:;
        default:
            ;
        }

        break;

    case HK_MIRROR_Y_COMPONENT:     // Mirror Y (Component)
@@ -264,7 +297,8 @@ wxPoint MousePos = m_CurrentScreen->m_MousePosition;
        break;

    case HK_MOVE_COMPONENT:     // Start move Component
			if ( PopupOn ) break;
        if( PopupOn )
            break;
        if( DrawStruct == NULL )
            DrawStruct = LocateSmallestComponent( GetScreen() );
        if( DrawStruct && (DrawStruct->m_Flags ==0) )
@@ -275,7 +309,8 @@ wxPoint MousePos = m_CurrentScreen->m_MousePosition;
        break;
    }

	if ( RefreshToolBar ) SetToolbars();
    if( RefreshToolBar )
        SetToolbars();
}


@@ -283,20 +318,23 @@ wxPoint MousePos = m_CurrentScreen->m_MousePosition;
void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey,
                                    EDA_BaseStruct* DrawStruct )
/***********************************************************/

/* Hot keys for the component editot. Some commands are relatives to the item under the mouse cursor
	Commands are case insensitive
	Zoom commands are not managed here
 *  Commands are case insensitive
 */
{
    bool RefreshToolBar = FALSE; // We must refresh tool bar when the undo/redo tool state is modified

	if ( hotkey == 0 ) return;
    if( hotkey == 0 )
        return;

    wxPoint MousePos = m_CurrentScreen->m_MousePosition;

    /* Convert lower to upper case (the usual toupper function has problem with non ascii codes like function keys */
	if( (hotkey >= 'a') && (hotkey <= 'z') ) hotkey += 'A' - 'a';
    if( (hotkey >= 'a') && (hotkey <= 'z') )
        hotkey += 'A' - 'a';
    int CommandCode = GetCommandCodeFromHotkey( hotkey, s_LibEdit_Hotkey_List );

    switch( CommandCode )
    {
    default:
@@ -308,23 +346,37 @@ wxPoint MousePos = m_CurrentScreen->m_MousePosition;
        DisplayHotkeyList( this, s_LibEdit_Hotkey_List );
        break;

    case HK_RESET_LOCAL_COORD:         /* Reset the relative coord */
        m_CurrentScreen->m_O_Curseur = m_CurrentScreen->m_Curseur;
        break;

    case HK_ZOOM_IN:
        OnZoom( ID_ZOOM_PLUS_KEY );
        break;

    case HK_ZOOM_OUT:
        OnZoom( ID_ZOOM_MOINS_KEY );
        break;

    case HK_ZOOM_REDRAW:
        OnZoom( ID_ZOOM_REDRAW_KEY );
        break;

    case HK_ZOOM_CENTER:
		case HK_RESET_LOCAL_COORD:
        OnZoom( ID_ZOOM_CENTER_KEY );
        break;

    case HK_REPEAT_LAST:
			if ( LibItemToRepeat && (LibItemToRepeat->m_Flags == 0) &&
				 (LibItemToRepeat->m_StructType == COMPONENT_PIN_DRAW_TYPE) )
        if( LibItemToRepeat && (LibItemToRepeat->m_Flags == 0)
           && (LibItemToRepeat->m_StructType == COMPONENT_PIN_DRAW_TYPE) )
        {
            RepeatPinItem( DC, (LibDrawPin*) LibItemToRepeat );
        }
			else wxBell();
        else
            wxBell();
        break;
    }

	if ( RefreshToolBar ) SetToolbars();
    if( RefreshToolBar )
        SetToolbars();
}
Loading