Commit 542b9441 authored by CHARRAS's avatar CHARRAS
Browse files

hotkeys handling finished

parent ef3d0491
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
/* XPM */
static char * editor_xpm[] = {
#ifndef XPMMAIN
extern char *editor_xpm[];

#else
char * editor_xpm[] = {
"16 16 60 1",
" 	c None",
".	c #000000",
@@ -77,3 +81,4 @@ static char * editor_xpm[] = {
" .@mnnnpprrrs.  ",
" .lqqqttssssu.  ",
"  ...........   "};
#endif
+5 −0
Original line number Diff line number Diff line
@@ -4,6 +4,11 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with 
email address.

2007-sept-19 UPDATE   Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+ all
	* hotkeys handling finished


2007-Sep-14 UPDATE   Dick Hollenbeck <dick@softplc.com>
================================================================================
+1 −0
Original line number Diff line number Diff line
@@ -250,6 +250,7 @@ unsigned ii;
	{
		m_LanguageId = m_EDA_CommonConfig->Read(wxT("Language"), wxLANGUAGE_DEFAULT);
		g_EditorName = m_EDA_CommonConfig->Read(wxT("Editor"));
		g_ConfigFileLocationChoice = m_EDA_CommonConfig->Read(HOTKEY_CFG_PATH_OPT, 0L);
	}

	if ( ! m_EDA_Config ) return;
+177 −97
Original line number Diff line number Diff line
@@ -10,6 +10,9 @@
#include "wxstruct.h"
#include "hotkeys_basic.h"
#include "macros.h"
#include "bitmaps.h"
#include "id.h"


/* Class to handle hotkey commnands. hotkeys have a default value
 *  This class allows the real key code changed by user from a key code list file
@@ -345,7 +348,7 @@ int WinEDA_BasicFrame::WriteHotkeyConfigFile( const wxString&
 * @param Filename = default full file name to create. If void, A filename will be asked
 * @param List = pointer to the current hotkey list.
 * the ouput format is: shortcut  "key"  "function"
 * lines starting by # are comments
 * lines starting with # are comments
 *
 */
{
@@ -358,7 +361,7 @@ int WinEDA_BasicFrame::WriteHotkeyConfigFile( const wxString&
        wxString Mask, Path, Ext;
        Ext  = DEFAULT_HOTKEY_FILENAME_EXT;
        Mask = wxT( "*" ) + Ext;
        Path = DEFAULT_HOTKEY_FILENAME_PATH;
        Path = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
        FullFilename = EDA_FileSelector( _( "Hotkey configuration file:" ),
                                         Path,          /* Chemin par defaut */
                                         FullFilename,  /* nom fichier par defaut */
@@ -476,7 +479,7 @@ int WinEDA_BasicFrame::ReadHotkeyConfigFile( const wxString&
        wxString Mask, Path, Ext;
        Ext  = DEFAULT_HOTKEY_FILENAME_EXT;
        Mask = wxT( "*" ) + Ext;
        Path = DEFAULT_HOTKEY_FILENAME_PATH;
        Path = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
        FullFilename = EDA_FileSelector( _( "Hotkey configuration file:" ),
                                         Path,          /* Chemin par defaut */
                                         FullFilename,  /* nom fichier par defaut */
@@ -560,3 +563,80 @@ int WinEDA_BasicFrame::ReadHotkeyConfigFile( const wxString&
    fclose( cfgfile );
    return 1;
}


/****************************************************/
wxString    ReturnHotkeyConfigFilePath( int choice )
/****************************************************/

/* return the hotkey config file path
 * @param choice : 0 = home, 1 = kicad/template
 */
{
    wxString path;

    switch( choice )
    {
    case 0:
        path = DEFAULT_HOTKEY_FILENAME_PATH_IS_HOME;
        break;

    case 1:
        path = DEFAULT_HOTKEY_FILENAME_PATH_IS_KICAD;
        break;

    default:
        break;
    }

    return path;
}


/***************************************/
void AddHotheyConfigMenu( wxMenu* menu )
/***************************************/

/* add hotkey config options to a menu
 * @parm menu : initial menu
 */
{
    wxMenuItem* item;

    if( menu == NULL )
        return;
    item = new wxMenuItem( menu, ID_PREFERENCES_CREATE_CONFIG_HOTKEYS,
                          _( "Create Hotkey config file" ),
                          _( "Create or Recreate the hotkey config file from current hotkey list" ) );
    item->SetBitmap( save_setup_xpm );
    menu->Append( item );
    item = new wxMenuItem( menu, ID_PREFERENCES_READ_CONFIG_HOTKEYS,
                          _( "Reread Hotkey config file" ),
                          _( "Reread the hotkey config file" ) );
    item->SetBitmap( reload_xpm );
    menu->Append( item );
    item = new wxMenuItem( menu, ID_PREFERENCES_EDIT_CONFIG_HOTKEYS,
                          _( "Edit Hotkey config file" ),
                          _( "Run the text editor and edit the hotkey config file" ) );
    item->SetBitmap( editor_xpm );
    menu->Append( item );

    wxMenu* submenu_hkcfg = new wxMenu();
    item = new wxMenuItem( submenu_hkcfg, ID_PREFERENCES_HOTKEY_PATH_IS_HOME,
                          _( "home directory" ),
                          _(  "Use home directory to load or store Hotkey config files" ),
						  wxITEM_CHECK );
    submenu_hkcfg->Append( item );

    item = new wxMenuItem( submenu_hkcfg, ID_PREFERENCES_HOTKEY_PATH_IS_KICAD,
                          _( "kicad/template directory" ),
                          _(  "Use kicad/templatedirectory to load or store Hotkey config files" ),
						  wxITEM_CHECK );
    submenu_hkcfg->Append( item );

	ADD_MENUITEM_WITH_HELP_AND_SUBMENU( menu, submenu_hkcfg,
                                        -1,
										_( "Hotkey config location" ),
                                        _( "Hotkey config file location selection (home directory or kicad tree)" ),
                                        right_xpm );
}
+8 −10
Original line number Diff line number Diff line
@@ -236,17 +236,17 @@ EDA_BaseStruct* WinEDA_SchematicFrame::CreateNewText( wxDC* DC, int type )


/************************************/
/*		Redraw a Texte while moving	*/
/*		Redraw a Text while moving	*/
/************************************/
static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
{
    EDA_BaseStruct* TextStruct = panel->GetScreen()->GetCurItem();

    /* effacement ancienne position */
    /* "Undraw" the current text at its old position*/
    if( erase )
        RedrawOneStruct( panel, DC, TextStruct, g_XorMode );

    /* Redessin du texte */
    /* redraw the text */
    switch( TextStruct->Type() )
    {
    case DRAW_LABEL_STRUCT_TYPE:
@@ -266,7 +266,7 @@ static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/*************************************************************/
static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC )
/*************************************************************/
/* Routine de sortie des menus de Texte */
/* Abort function for the command move text */
{
    SCH_SCREEN*     screen = (SCH_SCREEN*) Panel->m_Parent->m_CurrentScreen;
    EDA_BaseStruct* Struct = screen->GetCurItem();
@@ -275,22 +275,20 @@ static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC )
    Panel->ManageCurseur = NULL;
    Panel->ForceCloseManageCurseur = NULL;

    if( Struct == NULL )  /* Pas de trace en cours  */
    if( Struct == NULL )  /* no current item */
    {
        return;
    }

    /* ici : trace en cours */

    /* Effacement du trace en cours et suppression eventuelle de la structure */
    /* "Undraw" the text, and delete it if new (i.e. it was beiing just created)*/
    RedrawOneStruct( Panel, DC, Struct, g_XorMode );

    if( Struct->m_Flags & IS_NEW )  /* Suppression du nouveau texte en cours de placement */
    if( Struct->m_Flags & IS_NEW )
    {
        delete Struct;
        screen->SetCurItem( NULL );
    }
    else    /* Remise a jour des anciens parametres du texte */
    else    /* this was a move command on an "old" text: restore its old settings. */
    {
        switch( Struct->Type() )
        {
Loading