Commit 9414bf67 authored by CHARRAS's avatar CHARRAS
Browse files

more work on hotkeys

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


2007-aug-20 UPDATE   Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+ eeschema & pcbnew
	modify hotkeys.cpp code (large modifications).
	Added: common code in hotkeys_basic.cpp (in common) and hotkeys_basic.h (in include)
	In the future, i hope hotkeys will be programmed by a config file

+ pcbnew
	filename drc_dialog.prj changed to dialog_drc.prj
		(according to the fulename dialog_drc.cpp and dialog_drc.h created by dialogblock from the .prj)



2007-Aug-19 UPDATE   Dick Hollenbeck <dick@softplc.com>
2007-Aug-19 UPDATE   Dick Hollenbeck <dick@softplc.com>
================================================================================
================================================================================
+3 −5
Original line number Original line Diff line number Diff line
@@ -29,15 +29,13 @@ wxString HOSTNAME( wxT( "localhost" ) );


// buffers for read and write data in socket connections
// buffers for read and write data in socket connections
#define IPC_BUF_SIZE 4096
#define IPC_BUF_SIZE 4096
char      client_ipc_buffer[IPC_BUF_SIZE];
static char      client_ipc_buffer[IPC_BUF_SIZE];
char      server_ipc_buffer[IPC_BUF_SIZE];
static char      server_ipc_buffer[IPC_BUF_SIZE];


wxServer* server;
static wxServer* server;


void      (*RemoteFct)(const char* cmd);
void      (*RemoteFct)(const char* cmd);


char      buffcar[1024];

void SetupServerFunction( void (*remotefct)(const char* remotecmd) )
void SetupServerFunction( void (*remotefct)(const char* remotecmd) )
{
{
    RemoteFct = remotefct;
    RemoteFct = remotefct;
+152 −0
Original line number Original line Diff line number Diff line
	/*********************/
	/* hotkeys_basic.cpp */
	/*********************/

/* Some functions to handle hotkeys in kicad
*/
#include "fctsys.h"
#include "common.h"
#include "hotkeys_basic.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)
*/

Ki_HotkeyInfo::Ki_HotkeyInfo(const wxChar * infomsg, int idcommand, int keycode)
{
	m_KeyCode = keycode;		// Key code (ascii value for ascii keys or wxWidgets code for function key
	m_InfoMsg = infomsg;		// info message.
	m_Idcommand = idcommand;	// internal id for the corresponding command (see hotkey_id_commnand list)
}

/****************************************************/
wxString ReturnKeyNameFromKeyCode(int keycode)
/****************************************************/
/*
	* return the key name from the key code
	* Only some wxWidgets key values are handled for function key
	* @param key = key code (ascii value, or wxWidgets value for function keys)
	* @return the key name in a wxString
*/
{
wxString keyname, modifier, fullkeyname;
	
	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 ");

	switch ( keycode)
	{
		default:
			keycode &= ~(GR_KB_CTRL|GR_KB_ALT|GR_KB_SHIFT);
			keyname.Printf(wxT("%c"), keycode);
			break;
		
		case WXK_ESCAPE:
			keyname = wxT("Esc");
			break;

		case WXK_F1:
		case WXK_F2:
		case WXK_F3:
		case WXK_F4:
		case WXK_F5:
		case WXK_F6:
		case WXK_F7:
		case WXK_F8:
		case WXK_F9:
		case WXK_F10:
		case WXK_F11:
		case WXK_F12:
			keyname.Printf(wxT("F%d"), keycode - WXK_F1 + 1);
			break;
			
		case ' ':
			keyname = wxT("space");
			break;

		case '\t':
			keyname = wxT("Tab");
			break;

		case WXK_DELETE:
			keyname = wxT("Delete");
			break;

		case WXK_BACK:
			keyname = wxT("Backspace");
			break;

		case WXK_INSERT:
			keyname = wxT("Insert");
			break;

		case WXK_END:
			keyname = wxT("End");
			break;
		
		case WXK_PAGEUP:
			keyname = wxT("Page Up");
			break;
		
		case WXK_PAGEDOWN:
			keyname = wxT("Page Down");
			break;
		
		case WXK_ADD:
			keyname = wxT("+");
			break;
		
		case WXK_SUBTRACT:
			keyname = wxT("-");
			break;
		
		}
	
	fullkeyname = modifier + keyname;
	return fullkeyname;
}

/****************************************************************************/
void DisplayHotkeyList(WinEDA_DrawFrame * frame, Ki_HotkeyInfo ** List)
/*****************************************************************************/
/*
	* Displays the current hotkey list
	* @param frame = current open frame
	* @param List = pointer to a Ki_HotkeyInfo list of commands
	* @return none
*/
{
wxString keyname;
	
	wxString msg = _("Current hotkey list:\n\n");
	for ( ; * List != NULL; List++ )
	{
		Ki_HotkeyInfo * hk_decr = * List;
		if ( hk_decr->m_InfoMsg.IsEmpty() ) break;
		msg += _("key ");
		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
	* @param List = pointer to a Ki_HotkeyInfo list of commands
	* @return the corresponding function identifier from the Ki_HotkeyInfo  List
*/
{
	for ( ; * List != NULL; List++ )
	{
		Ki_HotkeyInfo * hk_decr = * List;
		if ( hk_decr->m_KeyCode == key ) return hk_decr->m_Idcommand;
	}
	
	return 0;
}
+3 −0
Original line number Original line Diff line number Diff line
@@ -12,6 +12,7 @@ OBJECTS= \
		common_plot_functions.o\
		common_plot_functions.o\
		common_plotPS_functions.o\
		common_plotPS_functions.o\
		common_plotHPGL_functions.o\
		common_plotHPGL_functions.o\
		hotkeys_basic.o\
		drawtxt.o \
		drawtxt.o \
		wxwineda.o \
		wxwineda.o \
		string.o \
		string.o \
@@ -43,6 +44,8 @@ gr_basic.o: gr_basic.cpp ../include/gr_basic.h $(DEPEND)


confirm.o: confirm.cpp $(COMMON)
confirm.o: confirm.cpp $(COMMON)


hotkeys_basic.o: hotkeys_basic.cpp ../include/hotkeys_basic.h $(COMMON)

worksheet.o: worksheet.cpp ../include/worksheet.h $(COMMON)
worksheet.o: worksheet.cpp ../include/worksheet.h $(COMMON)


selcolor.o: selcolor.cpp ../include/colors.h $(COMMON)
selcolor.o: selcolor.cpp ../include/colors.h $(COMMON)
+9 −9
Original line number Original line Diff line number Diff line
@@ -3,8 +3,8 @@
/****************************************************************/
/****************************************************************/


/*
/*
 *  Search a text (text, value, reference) withing e composent or
 *  Search a text (text, value, reference) within a component or
 *  search a composant in libraries, a marker ...,
 *  search a component in libraries, a marker ...,
 *  in current sheet or whole the project
 *  in current sheet or whole the project
 */
 */
#include "fctsys.h"
#include "fctsys.h"
@@ -40,7 +40,7 @@ void InstallFindFrame( WinEDA_SchematicFrame* parent, wxPoint& pos )
void WinEDA_FindFrame::FindMarker( wxCommandEvent& event )
void WinEDA_FindFrame::FindMarker( wxCommandEvent& event )
/**************************************************************/
/**************************************************************/


/*  Search de markers in whole the hierarchy.
/*  Search markers in whole hierarchy.
 *  Mouse cursor is put on the marker
 *  Mouse cursor is put on the marker
 *  search the first marker, or next marker
 *  search the first marker, or next marker
 */
 */
@@ -144,7 +144,7 @@ EDA_BaseStruct* WinEDA_SchematicFrame::FindMarker( int SearchType )
        curpos.x -= m_CurrentScreen->m_StartVisu.x;
        curpos.x -= m_CurrentScreen->m_StartVisu.x;
        curpos.y -= m_CurrentScreen->m_StartVisu.y;
        curpos.y -= m_CurrentScreen->m_StartVisu.y;


        /* Il y a peut-etre necessite de recadrer le dessin: */
		// reposition the window if the chosen marker is off screen. 
        if( (curpos.x <= 0) || (curpos.x >= size.x - 1)
        if( (curpos.x <= 0) || (curpos.x >= size.x - 1)
           || (curpos.y <= 0) || (curpos.y >= size.y) || force_recadre )
           || (curpos.y <= 0) || (curpos.y >= size.y) || force_recadre )
        {
        {
@@ -289,9 +289,9 @@ EDA_BaseStruct* WinEDA_SchematicFrame::FindSchematicItem(
                break;
                break;
            }
            }


            if( NotFound == FALSE )         /* Element trouve */
            if( NotFound == FALSE )         /* Item found ! */
            {
            {
                if( FirstScreen == NULL )   /* 1er element trouve */
                if( FirstScreen == NULL )   /* First Item found */
                {
                {
                    FirstScreen = Screen; 
                    FirstScreen = Screen; 
                    firstpos    = pos;
                    firstpos    = pos;
@@ -340,9 +340,9 @@ EDA_BaseStruct* WinEDA_SchematicFrame::FindSchematicItem(
            force_recadre   = TRUE;
            force_recadre   = TRUE;
        }
        }


        /* Si la struct localisee est du type DRAW_LIB_ITEM_STRUCT_TYPE,
        /* If the struct found is a DRAW_LIB_ITEM_STRUCT_TYPE type,
         *  Les coordonnes sont a recalculer en fonction de la matrice
         *  coordinates must be computed according to its orientation matrix
         *  d'orientation */
         */
        if( Struct->m_StructType == DRAW_LIB_ITEM_STRUCT_TYPE )
        if( Struct->m_StructType == DRAW_LIB_ITEM_STRUCT_TYPE )
        {
        {
            EDA_SchComponentStruct* pSch =  (EDA_SchComponentStruct*) Struct;
            EDA_SchComponentStruct* pSch =  (EDA_SchComponentStruct*) Struct;
Loading