more work on hotkeys

This commit is contained in:
CHARRAS 2007-08-20 10:55:09 +00:00
parent 040e2cbf6b
commit 9414bf676b
16 changed files with 1761 additions and 1646 deletions

View File

@ -4,6 +4,17 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
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>
================================================================================

View File

@ -29,15 +29,13 @@ wxString HOSTNAME( wxT( "localhost" ) );
// buffers for read and write data in socket connections
#define IPC_BUF_SIZE 4096
char client_ipc_buffer[IPC_BUF_SIZE];
char server_ipc_buffer[IPC_BUF_SIZE];
static char client_ipc_buffer[IPC_BUF_SIZE];
static char server_ipc_buffer[IPC_BUF_SIZE];
wxServer* server;
static wxServer* server;
void (*RemoteFct)(const char* cmd);
char buffcar[1024];
void SetupServerFunction( void (*remotefct)(const char* remotecmd) )
{
RemoteFct = remotefct;

152
common/hotkeys_basic.cpp Normal file
View File

@ -0,0 +1,152 @@
/*********************/
/* 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;
}

View File

@ -12,6 +12,7 @@ OBJECTS= \
common_plot_functions.o\
common_plotPS_functions.o\
common_plotHPGL_functions.o\
hotkeys_basic.o\
drawtxt.o \
wxwineda.o \
string.o \
@ -43,6 +44,8 @@ gr_basic.o: gr_basic.cpp ../include/gr_basic.h $(DEPEND)
confirm.o: confirm.cpp $(COMMON)
hotkeys_basic.o: hotkeys_basic.cpp ../include/hotkeys_basic.h $(COMMON)
worksheet.o: worksheet.cpp ../include/worksheet.h $(COMMON)
selcolor.o: selcolor.cpp ../include/colors.h $(COMMON)

View File

@ -3,8 +3,8 @@
/****************************************************************/
/*
* Search a text (text, value, reference) withing e composent or
* search a composant in libraries, a marker ...,
* Search a text (text, value, reference) within a component or
* search a component in libraries, a marker ...,
* in current sheet or whole the project
*/
#include "fctsys.h"
@ -40,7 +40,7 @@ void InstallFindFrame( WinEDA_SchematicFrame* parent, wxPoint& pos )
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
* 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.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)
|| (curpos.y <= 0) || (curpos.y >= size.y) || force_recadre )
{
@ -289,9 +289,9 @@ EDA_BaseStruct* WinEDA_SchematicFrame::FindSchematicItem(
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;
firstpos = pos;
@ -340,9 +340,9 @@ EDA_BaseStruct* WinEDA_SchematicFrame::FindSchematicItem(
force_recadre = TRUE;
}
/* Si la struct localisee est du type DRAW_LIB_ITEM_STRUCT_TYPE,
* Les coordonnes sont a recalculer en fonction de la matrice
* d'orientation */
/* If the struct found is a DRAW_LIB_ITEM_STRUCT_TYPE type,
* coordinates must be computed according to its orientation matrix
*/
if( Struct->m_StructType == DRAW_LIB_ITEM_STRUCT_TYPE )
{
EDA_SchComponentStruct* pSch = (EDA_SchComponentStruct*) Struct;

View File

@ -1,6 +1,6 @@
/***************/
/* hotkeys.cpp */
/***************/
/***************/
/* hotkeys.cpp */
/***************/
#include "fctsys.h"
@ -13,477 +13,314 @@
#include "id.h"
#include "hotkeys_basic.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
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
};
/* 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)
*/
class Ki_HotkeyInfo
{
public:
int m_KeyCode; // Key code (ascii value for ascii keys or wxWidgets code for function key
wxString m_InfoMsg; // info message.
hotkey_id_commnand m_Idcommand; // internal id for the corresponding command (see hotkey_id_commnand list)
public:
Ki_HotkeyInfo( const wxChar* infomsg, hotkey_id_commnand idcommand, int keycode );
};
Ki_HotkeyInfo::Ki_HotkeyInfo( const wxChar* infomsg, hotkey_id_commnand 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)
}
/* 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 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 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, ' ' );
static Ki_HotkeyInfo HkNextSearch( wxT( "Next Search" ), HK_NEXT_SEARCH, WXK_F5 );
static Ki_HotkeyInfo HkZoomCenter( wxT( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4 );
static Ki_HotkeyInfo HkZoomRedraw( wxT( "Zoom Redraw" ), HK_ZOOM_REDRAW, WXK_F3 );
static Ki_HotkeyInfo HkZoomOut( wxT( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2 );
static Ki_HotkeyInfo HkZoomIn( wxT( "Zoom In" ), HK_ZOOM_IN, WXK_F1 );
static Ki_HotkeyInfo HkHelp( wxT( "Help: this message" ), HK_HELP, '?' );
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 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 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, ' ');
static Ki_HotkeyInfo HkNextSearch(wxT("Next Search"), HK_NEXT_SEARCH, WXK_F5);
static Ki_HotkeyInfo HkZoomCenter(wxT("Zoom Center"), HK_ZOOM_CENTER, WXK_F4);
static Ki_HotkeyInfo HkZoomRedraw(wxT("Zoom Redraw"), HK_ZOOM_REDRAW, WXK_F3);
static Ki_HotkeyInfo HkZoomOut(wxT("Zoom Out"), HK_ZOOM_OUT, WXK_F2);
static Ki_HotkeyInfo HkZoomIn(wxT("Zoom In"), HK_ZOOM_IN, WXK_F1);
static Ki_HotkeyInfo HkHelp(wxT("Help: this message"), HK_HELP, '?');
// List of hotkey descriptors for schematic
static Ki_HotkeyInfo* s_Schematic_Hotkey_List[] = {
&HkHelp,
&HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter,
&HkNextSearch, &HkResetLocalCoord,
&HkDelete, &HkInsert, &HkMove2Drag,
&HkMoveComponent, &HkAddComponent,
&HkRotateComponent, &HkMirrorXComponent, &HkMirrorYComponent, &HkOrientNormalComponent,
&HkBeginWire,
NULL
static Ki_HotkeyInfo *s_Schematic_Hotkey_List[] = {
&HkHelp,
&HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter,
&HkNextSearch, &HkResetLocalCoord,
&HkDelete, &HkInsert, &HkMove2Drag,
&HkMoveComponent, &HkAddComponent,
&HkRotateComponent, &HkMirrorXComponent, &HkMirrorYComponent, & HkOrientNormalComponent,
&HkBeginWire,
NULL
};
// Library editor:
static Ki_HotkeyInfo HkInsertPin( wxT( "Repeat Pin" ), HK_REPEAT_LAST, WXK_INSERT );
static Ki_HotkeyInfo HkInsertPin(wxT("Repeat Pin"), HK_REPEAT_LAST, WXK_INSERT);
// List of hotkey descriptors for libray editor
static Ki_HotkeyInfo* s_LibEdit_Hotkey_List[] =
static Ki_HotkeyInfo *s_LibEdit_Hotkey_List[] =
{
&HkHelp,
&HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter,
&HkResetLocalCoord,
&HkInsertPin,
NULL
&HkHelp,
&HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter,
&HkResetLocalCoord,
&HkInsertPin,
NULL
};
/****************************************************/
static 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 wxString
*/
{
wxString keyname, modifier, fullkeyname;
if( keycode & GR_KB_CTRL )
modifier << wxT( "Ctrl " );
if( keycode & GR_KB_ALT )
modifier << wxT( "Alt " );
if( keycode & GR_KB_SHIFT )
modifier << wxT( "Shift " );
keycode &= ~(GR_KB_CTRL | GR_KB_ALT | GR_KB_SHIFT);
switch( keycode )
{
default:
keyname.Printf( wxT( "%c" ), keycode );
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_INSERT:
keyname = wxT( "Insert" );
break;
}
fullkeyname = modifier + keyname;
return keyname;
}
/****************************************************************************/
static 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 );
}
/******************************************************************/
static 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 HK_NOT_FOUND;
}
/***********************************************************/
void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
EDA_BaseStruct* DrawStruct )
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
Zoom commands are not managed here
*/
{
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
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;
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;
/* 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';
// Search command from key :
int CommandCode = GetCommandCodeFromHotkey(hotkey, s_Schematic_Hotkey_List);
switch( CommandCode )
{
default:
case HK_NOT_FOUND:
return;
break;
case HK_HELP: // Display Current hotkey list
DisplayHotkeyList(this, s_Schematic_Hotkey_List);
break;
/* 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';
case HK_ZOOM_IN:
case HK_ZOOM_OUT:
case HK_ZOOM_REDRAW:
case HK_ZOOM_CENTER:
case HK_RESET_LOCAL_COORD:
break;
// Search commnd from key :
switch( GetCommandCodeFromHotkey( hotkey, s_Schematic_Hotkey_List ) )
{
default:
case HK_NOT_FOUND:
return;
break;
case HK_MOVEBLOCK_TO_DRAGBLOCK: // Switch to drag mode, when block moving
HandleBlockEndByPopUp(BLOCK_DRAG, DC);
break;
case HK_HELP: // Display Current hotkey list
DisplayHotkeyList( this, s_Schematic_Hotkey_List );
break;
case HK_DELETE:
if ( PopupOn ) break;
RefreshToolBar = LocateAndDeleteItem(this, DC);
m_CurrentScreen->SetModify();
m_CurrentScreen->SetCurItem( NULL);
TestDanglingEnds(m_CurrentScreen->EEDrawList, DC);
break;
case HK_ZOOM_IN:
case HK_ZOOM_OUT:
case HK_ZOOM_REDRAW:
case HK_ZOOM_CENTER:
case HK_RESET_LOCAL_COORD:
break;
case HK_REPEAT_LAST:
if ( g_ItemToRepeat && (g_ItemToRepeat->m_Flags == 0) )
{
RepeatDrawItem(DC);
}
else wxBell();
break;
case HK_MOVEBLOCK_TO_DRAGBLOCK: // Switch to drag mode, when block moving
HandleBlockEndByPopUp( BLOCK_DRAG, DC );
break;
case HK_NEXT_SEARCH :
if ( g_LastSearchIsMarker ) WinEDA_SchematicFrame::FindMarker(1);
else FindSchematicItem(wxEmptyString, 2);
break;
case HK_DELETE:
if( PopupOn )
break;
RefreshToolBar = LocateAndDeleteItem( this, DC );
m_CurrentScreen->SetModify();
m_CurrentScreen->SetCurItem( NULL );
TestDanglingEnds( m_CurrentScreen->EEDrawList, DC );
break;
case HK_ADD_NEW_COMPONENT: // Add component
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"));
OnLeftClick(DC, MousePos);
break;
case HK_REPEAT_LAST:
if( g_ItemToRepeat && (g_ItemToRepeat->m_Flags == 0) )
{
RepeatDrawItem( DC );
}
else
wxBell();
break;
case HK_NEXT_SEARCH:
if( g_LastSearchIsMarker )
WinEDA_SchematicFrame::FindMarker( 1 );
else
FindSchematicItem( wxEmptyString, 2 );
break;
case HK_ADD_NEW_COMPONENT: // Add component
if( DrawStruct && DrawStruct->m_Flags )
case HK_BEGIN_WIRE: // Add wire
if ( DrawStruct ) // An item is selected. If edited and not a wire, a new command is not possible
{
if ( DrawStruct->m_Flags ) // Item selected and edition in progress
{
if (DrawStruct->m_StructType == DRAW_SEGMENT_STRUCT_TYPE )
{
EDA_DrawLineStruct * segment = (EDA_DrawLineStruct *)DrawStruct;
if ( segment->m_Layer != LAYER_WIRE ) 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"));
OnLeftClick(DC, MousePos);
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" ) );
OnLeftClick( DC, MousePos );
break;
case HK_ROTATE_COMPONENT: // Component Rotation
if ( DrawStruct == NULL )
{
DrawStruct = PickStruct( GetScreen()->m_Curseur,
GetScreen()->EEDrawList, LIBITEM|TEXTITEM|LABELITEM );
if ( DrawStruct == NULL ) break;
if ( DrawStruct->m_StructType == DRAW_LIB_ITEM_STRUCT_TYPE )
DrawStruct = LocateSmallestComponent( GetScreen() );
if ( DrawStruct == NULL ) break;
}
switch (DrawStruct->m_StructType)
{
case DRAW_LIB_ITEM_STRUCT_TYPE:
if ( DrawStruct->m_Flags == 0 )
{
SaveCopyInUndoList(DrawStruct, IS_CHANGED);
RefreshToolBar = TRUE;
}
CmpRotationMiroir(
(EDA_SchComponentStruct *) DrawStruct, DC, CMP_ROTATE_COUNTERCLOCKWISE );
break;
case HK_BEGIN_WIRE: // Add wire
if( DrawStruct ) // An item is selected. If edited and not a wire, a new command is not possible
{
if( DrawStruct->m_Flags ) // Item selected and edition in progress
{
if( DrawStruct->m_StructType == DRAW_SEGMENT_STRUCT_TYPE )
{
EDA_DrawLineStruct* segment = (EDA_DrawLineStruct*) DrawStruct;
if( segment->m_Layer != LAYER_WIRE )
break;
}
else
break;
}
}
case DRAW_TEXT_STRUCT_TYPE:
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
if ( DrawStruct->m_Flags == 0 )
{
SaveCopyInUndoList(DrawStruct, IS_CHANGED);
RefreshToolBar = TRUE;
}
ChangeTextOrient( (DrawTextStruct*)DrawStruct, DC);
break;
}
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" ) );
OnLeftClick( DC, MousePos );
break;
case HK_MIRROR_Y_COMPONENT: // Mirror Y (Component)
if ( DrawStruct == NULL )
DrawStruct = LocateSmallestComponent( GetScreen() );
if ( DrawStruct )
{
if ( DrawStruct->m_Flags == 0 )
{
SaveCopyInUndoList(DrawStruct, IS_CHANGED);
RefreshToolBar = TRUE;
}
CmpRotationMiroir(
(EDA_SchComponentStruct *) DrawStruct, DC, CMP_MIROIR_Y );
}
break;
case HK_ROTATE_COMPONENT: // Component Rotation
if( DrawStruct == NULL )
{
DrawStruct = PickStruct( GetScreen()->m_Curseur,
GetScreen()->EEDrawList, LIBITEM | TEXTITEM | LABELITEM );
if( DrawStruct == NULL )
break;
if( DrawStruct->m_StructType == DRAW_LIB_ITEM_STRUCT_TYPE )
DrawStruct = LocateSmallestComponent( GetScreen() );
if( DrawStruct == NULL )
break;
}
case HK_MIRROR_X_COMPONENT: // Mirror X (Component)
if ( DrawStruct == NULL )
DrawStruct = LocateSmallestComponent( GetScreen() );
if ( DrawStruct )
{
if ( DrawStruct->m_Flags == 0 )
{
SaveCopyInUndoList(DrawStruct, IS_CHANGED);
RefreshToolBar = TRUE;
}
CmpRotationMiroir(
(EDA_SchComponentStruct *) DrawStruct, DC, CMP_MIROIR_X );
}
break;
switch( DrawStruct->m_StructType )
{
case DRAW_LIB_ITEM_STRUCT_TYPE:
if( DrawStruct->m_Flags == 0 )
{
SaveCopyInUndoList( DrawStruct, IS_CHANGED );
RefreshToolBar = TRUE;
}
case HK_ORIENT_NORMAL_COMPONENT: // Orient 0, no mirror (Component)
if ( DrawStruct == NULL )
DrawStruct = LocateSmallestComponent( GetScreen() );
if ( DrawStruct )
{
if ( DrawStruct->m_Flags == 0 )
{
SaveCopyInUndoList(DrawStruct, IS_CHANGED);
RefreshToolBar = TRUE;
}
CmpRotationMiroir(
(EDA_SchComponentStruct *) DrawStruct, DC, CMP_NORMAL );
TestDanglingEnds(m_CurrentScreen->EEDrawList, DC);
}
break;
CmpRotationMiroir(
(EDA_SchComponentStruct*) DrawStruct, DC, CMP_ROTATE_COUNTERCLOCKWISE );
break;
case DRAW_TEXT_STRUCT_TYPE:
case DRAW_LABEL_STRUCT_TYPE:
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
if( DrawStruct->m_Flags == 0 )
{
SaveCopyInUndoList( DrawStruct, IS_CHANGED );
RefreshToolBar = TRUE;
}
ChangeTextOrient( (DrawTextStruct*) DrawStruct, DC );
break;
}
break;
case HK_MIRROR_Y_COMPONENT: // Mirror Y (Component)
if( DrawStruct == NULL )
DrawStruct = LocateSmallestComponent( GetScreen() );
if( DrawStruct )
{
if( DrawStruct->m_Flags == 0 )
{
SaveCopyInUndoList( DrawStruct, IS_CHANGED );
RefreshToolBar = TRUE;
}
CmpRotationMiroir(
(EDA_SchComponentStruct*) DrawStruct, DC, CMP_MIROIR_Y );
}
break;
case HK_MIRROR_X_COMPONENT: // Mirror X (Component)
if( DrawStruct == NULL )
DrawStruct = LocateSmallestComponent( GetScreen() );
if( DrawStruct )
{
if( DrawStruct->m_Flags == 0 )
{
SaveCopyInUndoList( DrawStruct, IS_CHANGED );
RefreshToolBar = TRUE;
}
CmpRotationMiroir(
(EDA_SchComponentStruct*) DrawStruct, DC, CMP_MIROIR_X );
}
break;
case HK_ORIENT_NORMAL_COMPONENT: // Orient 0, no mirror (Component)
if( DrawStruct == NULL )
DrawStruct = LocateSmallestComponent( GetScreen() );
if( DrawStruct )
{
if( DrawStruct->m_Flags == 0 )
{
SaveCopyInUndoList( DrawStruct, IS_CHANGED );
RefreshToolBar = TRUE;
}
CmpRotationMiroir(
(EDA_SchComponentStruct*) DrawStruct, DC, CMP_NORMAL );
TestDanglingEnds( m_CurrentScreen->EEDrawList, DC );
}
break;
case HK_MOVE_COMPONENT: // Start move Component
if( PopupOn )
break;
if( DrawStruct == NULL )
DrawStruct = LocateSmallestComponent( GetScreen() );
if( DrawStruct && (DrawStruct->m_Flags ==0) )
{
m_CurrentScreen->SetCurItem( DrawStruct );
Process_Move_Item( m_CurrentScreen->GetCurItem(), DC );
}
break;
}
if( RefreshToolBar )
SetToolbars();
case HK_MOVE_COMPONENT: // Start move Component
if ( PopupOn ) break;
if ( DrawStruct == NULL )
DrawStruct = LocateSmallestComponent( GetScreen() );
if ( DrawStruct && (DrawStruct->m_Flags ==0) )
{
m_CurrentScreen->SetCurItem(DrawStruct);
Process_Move_Item(m_CurrentScreen->GetCurItem(), DC);
}
break;
}
if ( RefreshToolBar ) SetToolbars();
}
/***********************************************************/
void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey,
EDA_BaseStruct* DrawStruct )
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
Zoom commands are not managed here
*/
{
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;
bool RefreshToolBar = FALSE; // We must refresh tool bar when the undo/redo tool state is modified
wxPoint MousePos = m_CurrentScreen->m_MousePosition;
if( hotkey == 0 )
return;
/* 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';
int CommandCode = GetCommandCodeFromHotkey(hotkey, s_LibEdit_Hotkey_List);
switch( CommandCode )
{
default:
case HK_NOT_FOUND:
return;
break;
case HK_HELP: // Display Current hotkey list
DisplayHotkeyList(this, s_LibEdit_Hotkey_List);
break;
wxPoint MousePos = m_CurrentScreen->m_MousePosition;
case HK_ZOOM_IN:
case HK_ZOOM_OUT:
case HK_ZOOM_REDRAW:
case HK_ZOOM_CENTER:
case HK_RESET_LOCAL_COORD:
break;
/* 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';
case HK_REPEAT_LAST:
if ( LibItemToRepeat && (LibItemToRepeat->m_Flags == 0) &&
(LibItemToRepeat->m_StructType == COMPONENT_PIN_DRAW_TYPE) )
{
RepeatPinItem(DC, (LibDrawPin*) LibItemToRepeat);
}
else wxBell();
break;
}
switch( GetCommandCodeFromHotkey( hotkey, s_LibEdit_Hotkey_List ) )
{
default:
case HK_NOT_FOUND:
return;
break;
case HK_HELP: // Display Current hotkey list
DisplayHotkeyList( this, s_LibEdit_Hotkey_List );
break;
case HK_ZOOM_IN:
case HK_ZOOM_OUT:
case HK_ZOOM_REDRAW:
case HK_ZOOM_CENTER:
case HK_RESET_LOCAL_COORD:
break;
case HK_REPEAT_LAST:
if( LibItemToRepeat && (LibItemToRepeat->m_Flags == 0)
&& (LibItemToRepeat->m_StructType == COMPONENT_PIN_DRAW_TYPE) )
{
RepeatPinItem( DC, (LibDrawPin*) LibItemToRepeat );
}
else
wxBell();
break;
}
if( RefreshToolBar )
SetToolbars();
if ( RefreshToolBar ) SetToolbars();
}

View File

@ -5,7 +5,7 @@
COMMON_GLOBL wxString g_BuildVersion
#ifdef EDA_BASE
(wxT("(2007-08-09)"))
(wxT("(2007-08-19)"))
#endif
;

33
include/hotkeys_basic.h Normal file
View File

@ -0,0 +1,33 @@
/*******************/
/* hotkeys_basic.h */
/*******************/
/* Some functions to handle hotkeys in kicad
*/
#ifndef HOTKEYS_BASIC_H
#define 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)
*/
class Ki_HotkeyInfo
{
public:
int m_KeyCode; // Key code (ascii value for ascii keys or wxWidgets code for function key
wxString m_InfoMsg; // info message.
int m_Idcommand; // internal id for the corresponding command (see hotkey_id_commnand list)
public:
Ki_HotkeyInfo(const wxChar * infomsg, int idcommand, int keycode);
};
/* Functions:
*/
wxString ReturnKeyNameFromKeyCode(int keycode);
void DisplayHotkeyList(WinEDA_DrawFrame * frame, Ki_HotkeyInfo ** List);
int GetCommandCodeFromHotkey(int key, Ki_HotkeyInfo ** List);
#endif // HOTKEYS_BASIC_H

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -91,14 +91,13 @@ void RemoteCommand( const char* cmdline )
if( pad )
netcode = pad->m_NetCode;
if( netcode > 0 )
if( netcode > 0 ) /* hightlighted the net selected net*/
{
/* effacement surbrillance ancienne */
if( g_HightLigt_Status )
if( g_HightLigt_Status ) /* erase the old hightlighted net */
frame->Hight_Light( &dc );
g_HightLigth_NetCode = netcode;
frame->Hight_Light( &dc );
frame->Hight_Light( &dc ); /* hightlighted the new one */
frame->DrawPanel->CursorOff( &dc );
frame->GetScreen()->m_Curseur = pad->m_Pos;
@ -231,22 +230,6 @@ void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
SwitchLayer( DC, CUIVRE_N );
break;
case 'F' | GR_KB_CTRL:
case 'f' | GR_KB_CTRL:
DisplayOpt.DisplayPcbTrackFill ^= 1; DisplayOpt.DisplayPcbTrackFill &= 1;
GetScreen()->SetRefreshReq();
break;
case ' ': /* Mise a jour de l'origine des coord relatives */
GetScreen()->m_O_Curseur = GetScreen()->m_Curseur;
break;
case 'U' | GR_KB_CTRL:
case 'u' | GR_KB_CTRL:
g_UnitMetric = (g_UnitMetric == INCHES ) ? MILLIMETRE : INCHES;
break;
case EDA_PANNING_UP_KEY:
OnZoom( ID_ZOOM_PANNING_UP );
curpos = m_CurrentScreen->m_Curseur;
@ -401,6 +384,11 @@ void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
}
}
if( hotkey )
{
OnHotKey( DC, hotkey, NULL );
}
if( GetScreen()->IsRefreshReq() )
{
RedrawActiveWindow( DC, TRUE );
@ -408,9 +396,4 @@ void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
SetToolbars();
Affiche_Status_Box(); /* Affichage des coord curseur */
if( hotkey )
{
OnHotKey( DC, hotkey, NULL );
}
}

View File

@ -128,7 +128,7 @@ void WinEDA_DrcFrame::CreateControls()
SetFont(*g_DialogFont);
////@begin WinEDA_DrcFrame content construction
// Generated by DialogBlocks, 02/08/2007 10:11:17 (unregistered)
// Generated by DialogBlocks, 20/08/2007 08:58:05 (unregistered)
WinEDA_DrcFrame* itemDialog1 = this;

View File

@ -52,8 +52,7 @@ class wxBoxSizer;
#define ID_BUTTON_BROWSE_RPT_FILE 10011
#define ID_TEXTCTRL_GET_RPT_FILENAME 10010
#define ID_TEXTCTRL 10001
// #define SYMBOL_WINEDA_DRCFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX
#define SYMBOL_WINEDA_DRCFRAME_STYLE wxCAPTION|wxSYSTEM_MENU|wxCLOSE_BOX
#define SYMBOL_WINEDA_DRCFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX
#define SYMBOL_WINEDA_DRCFRAME_TITLE _("DRC Control")
#define SYMBOL_WINEDA_DRCFRAME_IDNAME ID_DIALOG
#define SYMBOL_WINEDA_DRCFRAME_SIZE wxSize(400, 300)

View File

@ -158,7 +158,7 @@ int WinEDA_PcbFrame::LoadOnePcbFile( const wxString& FullFileName, wxDC* DC, boo
{
msg = wxT( "*" ) + PcbExtBuffer;
wxString FileName =
EDA_FileSelector( _( "Board files:" ),
EDA_FileSelector( _( "Load board files:" ),
wxEmptyString, /* Chemin par defaut */
GetScreen()->m_FileName, /* nom fichier par defaut */
PcbExtBuffer, /* extension par defaut */
@ -260,7 +260,7 @@ bool WinEDA_PcbFrame::SavePcbFile( const wxString& FileName )
if( FileName == wxEmptyString )
{
msg = wxT( "*" ) + PcbExtBuffer;
FullFileName = EDA_FileSelector( _( "Board files:" ),
FullFileName = EDA_FileSelector( _( "Save board files:" ),
wxEmptyString, /* Chemin par defaut */
GetScreen()->m_FileName, /* nom fichier par defaut */
PcbExtBuffer, /* extension par defaut */

View File

@ -9,29 +9,92 @@
#include "common.h"
#include "pcbnew.h"
#include "id.h"
#include "hotkeys_basic.h"
#include "protos.h"
/* Routines locales */
/* variables externes */
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_DELETE,
HK_BACK_SPACE,
HK_ROTATE_FOOTPRINT,
HK_MOVE_FOOTPRINT,
HK_DRAG_FOOTPRINT,
HK_FLIP_FOOTPRINT,
HK_LOCK_UNLOCK_FOOTPRINT,
HK_ADD_VIA, HK_END_TRACK,
HK_SAVE_BOARD, HK_LOAD_BOARD,
HK_SWITCH_UNITS, HK_SWITCH_TRACK_DISPLAY_MODE,
HK_FIND_ITEM
};
/* local variables */
/* Hotkey list: */
static Ki_HotkeyInfo HkSavefile(wxT("Save board"), HK_SAVE_BOARD, 'S' + GR_KB_CTRL);
static Ki_HotkeyInfo HkLoadfile(wxT("Load board"), HK_LOAD_BOARD, 'L' + GR_KB_CTRL);
static Ki_HotkeyInfo HkFindItem(wxT("Find Item"), HK_FIND_ITEM, 'F' + GR_KB_CTRL);
static Ki_HotkeyInfo HkBackspace(wxT("Delete track segment"), HK_BACK_SPACE, WXK_BACK);
static Ki_HotkeyInfo HkAddVia(wxT("Add Via"), HK_ADD_VIA, 'V');
static Ki_HotkeyInfo HkEndTrack(wxT("End Track"), HK_END_TRACK, WXK_END);
static Ki_HotkeyInfo HkFlipFootprint(wxT("Flip Footprint"), HK_FLIP_FOOTPRINT, 'F');
static Ki_HotkeyInfo HkRotateFootprint(wxT("Rotate Footprint"), HK_ROTATE_FOOTPRINT, 'R');
static Ki_HotkeyInfo HkMoveFootprint(wxT("Move Footprint"), HK_MOVE_FOOTPRINT, 'M');
static Ki_HotkeyInfo HkDragFootprint(wxT("Drag Footprint"), HK_DRAG_FOOTPRINT, 'G');
static Ki_HotkeyInfo HkLock_Unlock_Footprint(wxT("Lock/Unlock Footprint"), HK_LOCK_UNLOCK_FOOTPRINT, 'L');
static Ki_HotkeyInfo HkDelete(wxT("Delete Track or Footprint"), HK_DELETE, WXK_DELETE);
static Ki_HotkeyInfo HkResetLocalCoord(wxT("Reset local coord."), HK_RESET_LOCAL_COORD, ' ');
static Ki_HotkeyInfo HkZoomCenter(wxT("Zoom Center"), HK_ZOOM_CENTER, WXK_F4);
static Ki_HotkeyInfo HkZoomRedraw(wxT("Zoom Redraw"), HK_ZOOM_REDRAW, WXK_F3);
static Ki_HotkeyInfo HkZoomOut(wxT("Zoom Out"), HK_ZOOM_OUT, WXK_F2);
static Ki_HotkeyInfo HkZoomIn(wxT("Zoom In"), HK_ZOOM_IN, WXK_F1);
static Ki_HotkeyInfo HkHelp(wxT("Help: this message"), HK_HELP, '?');
static Ki_HotkeyInfo HkSwitchUnits(wxT("Switch Units"), HK_SWITCH_UNITS, 'U');
static Ki_HotkeyInfo HkTrackDisplayMode(wxT("Track Display Mode"), HK_SWITCH_TRACK_DISPLAY_MODE, 'F');
// List of hotkey descriptors for pcbnew
static Ki_HotkeyInfo *s_board_edit_Hotkey_List[] = {
&HkHelp,
&HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter,
&HkResetLocalCoord, &HkSwitchUnits, &HkTrackDisplayMode,
&HkDelete, &HkBackspace,
&HkAddVia, &HkEndTrack,
&HkMoveFootprint, &HkFlipFootprint,
&HkRotateFootprint, &HkDragFootprint,
&HkLock_Unlock_Footprint,
&HkSavefile, &HkLoadfile, &HkFindItem,
NULL
};
static Ki_HotkeyInfo *s_module_edit_Hotkey_List[] = {
&HkHelp,
&HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter,
&HkSwitchUnits, &HkResetLocalCoord,
&HkDelete, &HkBackspace,
NULL
};
/***********************************************************/
void WinEDA_PcbFrame::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
*/
/* Gestion des commandes rapides (Raccourcis claviers) concernant l'element
* sous le courseur souris
* Les majuscules/minuscules sont indifferenciees
* touche DELETE: Effacement (Module ou piste selon commande en cours)
* touche V: Place via en cours de trace de piste
* touche R: Rotation module
* touche S: Change couche module (Composant <-> Cuivre)
* touche M: Start Move module
* touche G: Start Drag module
*/
{
bool PopupOn = GetScreen()->GetCurItem()
&& GetScreen()->GetCurItem()->m_Flags;
@ -41,194 +104,216 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
if( hotkey == 0 )
return;
// code Ctrl A = 1, Ctr B = 2 ..., remapped, (more easy to understand in switch)
if( hotkey & GR_KB_CTRL )
hotkey += 'A' - 1;
MODULE* module = NULL;
if( hotkey <= 0xFF )
hotkey = toupper( hotkey );
switch( hotkey )
// Remap the control key Ctrl A (0x01) to GR_KB_CTRL + 'A' (easier to handle...)
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';
int CommandCode = GetCommandCodeFromHotkey(hotkey, s_board_edit_Hotkey_List);
switch( CommandCode )
{
case WXK_DELETE:
case WXK_NUMPAD_DELETE:
OnHotkeyDeleteItem( DC, DrawStruct );
break;
default:
case HK_NOT_FOUND:
return;
break;
case HK_HELP: // Display Current hotkey list
DisplayHotkeyList(this, s_board_edit_Hotkey_List);
break;
case WXK_BACK:
if( m_ID_current_state == ID_TRACK_BUTT && GetScreen()->m_Active_Layer <= CMP_N )
{
bool ItemFree = (GetScreen()->GetCurItem() == NULL )
|| (GetScreen()->GetCurItem()->m_Flags == 0);
if( ItemFree )
{
// no track is currently being edited - select a segment and remove it.
DrawStruct = PcbGeneralLocateAndDisplay();
case HK_ZOOM_IN:
case HK_ZOOM_OUT:
case HK_ZOOM_REDRAW:
case HK_ZOOM_CENTER:
break;
// don't let backspace delete modules!!
if( DrawStruct && (DrawStruct->m_StructType == TYPETRACK
|| DrawStruct->m_StructType == TYPEVIA) )
Delete_Segment( DC, (TRACK*) DrawStruct );
GetScreen()->SetModify();
}
else if( GetScreen()->GetCurItem()->m_StructType == TYPETRACK )
{
// then an element is being edited - remove the last segment.
GetScreen()->SetCurItem(
Delete_Segment( DC, (TRACK*) GetScreen()->GetCurItem() ) );
GetScreen()->SetModify();
}
}
break;
case HK_RESET_LOCAL_COORD: /*Reset the relative coord */
GetScreen()->m_O_Curseur = GetScreen()->m_Curseur;
break;
case WXK_END:
DrawPanel->MouseToCursorSchema();
End_Route( (TRACK*) (GetScreen()->GetCurItem()), DC );
break;
case 'F' + GR_KB_CTRL:
{
wxCommandEvent evt;
evt.SetId( ID_FIND_ITEMS );
Process_Special_Functions( evt );
}
break;
case HK_SWITCH_UNITS:
g_UnitMetric = (g_UnitMetric == INCHES ) ? MILLIMETRE : INCHES;
break;
case 'O' + GR_KB_CTRL:
{
// try not to duplicate save, load code etc.
wxCommandEvent evt;
evt.SetId( ID_LOAD_FILE );
Files_io( evt );
}
break;
case HK_SWITCH_TRACK_DISPLAY_MODE:
DisplayOpt.DisplayPcbTrackFill ^= 1; DisplayOpt.DisplayPcbTrackFill &= 1;
GetScreen()->SetRefreshReq();
break;
case 'S' + GR_KB_CTRL:
{
// try not to duplicate save, load code etc.
wxCommandEvent evt;
evt.SetId( ID_SAVE_BOARD );
Files_io( evt );
}
break;
case HK_DELETE:
OnHotkeyDeleteItem( DC, DrawStruct );
break;
case 'V': // Switch to alternate layer and Place a via if a track is in progress
if( m_ID_current_state != ID_TRACK_BUTT )
return;
if( ItemFree )
{
Other_Layer_Route( NULL, DC );
break;
}
if( GetScreen()->GetCurItem()->m_StructType != TYPETRACK )
return;
if( (GetScreen()->GetCurItem()->m_Flags & IS_NEW) == 0 )
return;
Other_Layer_Route( (TRACK*) GetScreen()->GetCurItem(), DC );
if( DisplayOpt.ContrastModeDisplay )
GetScreen()->SetRefreshReq();
break;
case HK_BACK_SPACE:
if( m_ID_current_state == ID_TRACK_BUTT && GetScreen()->m_Active_Layer <= CMP_N )
{
bool ItemFree = (GetScreen()->GetCurItem() == NULL )
|| (GetScreen()->GetCurItem()->m_Flags == 0);
if( ItemFree )
{
// no track is currently being edited - select a segment and remove it.
DrawStruct = PcbGeneralLocateAndDisplay();
// Footprint edition:
case 'L': // toggle module "MODULE_is_LOCKED" status:
// get any module, locked or not locked and toggle its locked status
if( ItemFree )
module = Locate_Prefered_Module( m_Pcb, CURSEUR_OFF_GRILLE | VISIBLE_ONLY );
else if( GetScreen()->GetCurItem()->m_StructType == TYPEMODULE )
module = (MODULE*) GetScreen()->GetCurItem();
if( module )
{
GetScreen()->SetCurItem( module );
module->SetLocked( !module->IsLocked() );
module->Display_Infos( this );
}
break;
// don't let backspace delete modules!!
if( DrawStruct && (DrawStruct->m_StructType == TYPETRACK
|| DrawStruct->m_StructType == TYPEVIA) )
Delete_Segment( DC, (TRACK*) DrawStruct );
GetScreen()->SetModify();
}
else if( GetScreen()->GetCurItem()->m_StructType == TYPETRACK )
{
// then an element is being edited - remove the last segment.
GetScreen()->SetCurItem(Delete_Segment( DC, (TRACK*) GetScreen()->GetCurItem() ) );
GetScreen()->SetModify();
}
}
break;
case 'G': // Start move (and drag) module
case 'M': // Start move module
if( PopupOn )
break;
case HK_END_TRACK:
DrawPanel->MouseToCursorSchema();
End_Route( (TRACK*) (GetScreen()->GetCurItem()), DC );
break;
case 'R': // Rotation
case 'S': // move to other side
if( ItemFree )
{
module = Locate_Prefered_Module( m_Pcb,
CURSEUR_OFF_GRILLE | IGNORE_LOCKED | VISIBLE_ONLY
#if defined (USE_MATCH_LAYER)
| MATCH_LAYER
#endif
);
if( module == NULL ) // no footprint found
{
module = Locate_Prefered_Module( m_Pcb, CURSEUR_OFF_GRILLE );
if( module )
{
// a footprint is found, but locked or on an other layer
if( module->IsLocked() )
{
wxString msg;
msg.Printf( _("Footprint %s found, but locked"),
module->m_Reference->m_Text.GetData() );
DisplayInfo( this, msg );
}
module = NULL;
}
}
}
else if( GetScreen()->GetCurItem()->m_StructType == TYPEMODULE )
{
module = (MODULE*) GetScreen()->GetCurItem();
case HK_FIND_ITEM:
{
wxCommandEvent evt;
evt.SetId( ID_FIND_ITEMS );
Process_Special_Functions( evt );
}
break;
// @todo: might need to add a layer check in if() below
if( (GetScreen()->GetCurItem()->m_Flags == 0)
&& module->IsLocked() )
module = NULL; // do not move, rotate ... it.
}
if( module == NULL )
break;
case HK_LOAD_BOARD:
{
// try not to duplicate save, load code etc.
wxCommandEvent evt;
evt.SetId( ID_LOAD_FILE );
Files_io( evt );
}
break;
/* I'd like to make sending to EESCHEMA edge triggered, but the
simple mouse click on a module when the arrow icon is in play
does not set m_CurrentItem at this time, nor does a mouse click
when the local ratsnest icon is in play set m_CurrentItem, and these
actions also call SendMessageToEESCHEMA().
if( GetScreen()->GetCurItem() != module )
*/
{
// Send the module via socket to EESCHEMA's search facility.
SendMessageToEESCHEMA( module );
GetScreen()->SetCurItem( module );
}
case HK_SAVE_BOARD:
{
// try not to duplicate save, load code etc.
wxCommandEvent evt;
evt.SetId( ID_SAVE_BOARD );
Files_io( evt );
}
break;
switch( hotkey )
{
case 'R': // Rotation
Rotate_Module( DC, module, 900, TRUE );
break;
case HK_ADD_VIA: // Switch to alternate layer and Place a via if a track is in progress
if( m_ID_current_state != ID_TRACK_BUTT )
return;
if( ItemFree )
{
Other_Layer_Route( NULL, DC );
break;
}
if( GetScreen()->GetCurItem()->m_StructType != TYPETRACK )
return;
if( (GetScreen()->GetCurItem()->m_Flags & IS_NEW) == 0 )
return;
Other_Layer_Route( (TRACK*) GetScreen()->GetCurItem(), DC );
if( DisplayOpt.ContrastModeDisplay )
GetScreen()->SetRefreshReq();
break;
case 'S': // move to other side
Change_Side_Module( module, DC );
break;
// Footprint edition:
case HK_LOCK_UNLOCK_FOOTPRINT: // toggle module "MODULE_is_LOCKED" status:
// get any module, locked or not locked and toggle its locked status
if( ItemFree )
module = Locate_Prefered_Module( m_Pcb, CURSEUR_OFF_GRILLE | VISIBLE_ONLY );
else if( GetScreen()->GetCurItem()->m_StructType == TYPEMODULE )
module = (MODULE*) GetScreen()->GetCurItem();
if( module )
{
GetScreen()->SetCurItem(module);
module->SetLocked( !module->IsLocked() );
module->Display_Infos( this );
}
break;
case 'G': // Start move (and drag) module
g_Drag_Pistes_On = TRUE;
case HK_DRAG_FOOTPRINT: // Start move (and drag) module
case HK_MOVE_FOOTPRINT: // Start move module
if( PopupOn )
break;
// fall through
case HK_ROTATE_FOOTPRINT: // Rotation
case HK_FLIP_FOOTPRINT: // move to other side
if( ItemFree )
{
module = Locate_Prefered_Module( m_Pcb,
CURSEUR_OFF_GRILLE | IGNORE_LOCKED | VISIBLE_ONLY
#if defined (USE_MATCH_LAYER)
| MATCH_LAYER
#endif
);
if( module == NULL ) // no footprint found
{
module = Locate_Prefered_Module( m_Pcb, CURSEUR_OFF_GRILLE );
if( module )
{
// a footprint is found, but locked or on an other layer
if( module->IsLocked() )
{
wxString msg;
msg.Printf( _("Footprint %s found, but locked"),
module->m_Reference->m_Text.GetData() );
DisplayInfo( this, msg );
}
module = NULL;
}
}
}
else if( GetScreen()->GetCurItem()->m_StructType == TYPEMODULE )
{
module = (MODULE*) GetScreen()->GetCurItem();
case 'M': // Start move module
StartMove_Module( module, DC );
break;
}
// @todo: might need to add a layer check in if() below
if( (GetScreen()->GetCurItem()->m_Flags == 0)
&& module->IsLocked() )
module = NULL; // do not move, rotate ... it.
}
if( module == NULL )
break;
module->Display_Infos( this );
/* I'd like to make sending to EESCHEMA edge triggered, but the
simple mouse click on a module when the arrow icon is in play
does not set GetCurItem() at this time, nor does a mouse click
when the local ratsnest icon is in play set GetCurItem(), and these
actions also call SendMessageToEESCHEMA().
if( GetScreen()->GetCurItem() != module )
*/
{
// Send the module via socket to EESCHEMA's search facility.
SendMessageToEESCHEMA( module );
GetScreen()->SetCurItem(module);
}
break;
switch( CommandCode )
{
case HK_ROTATE_FOOTPRINT: // Rotation
Rotate_Module( DC, module, 900, TRUE );
break;
case HK_FLIP_FOOTPRINT: // move to other side
Change_Side_Module( module, DC );
break;
case HK_DRAG_FOOTPRINT: // Start move (and drag) module
g_Drag_Pistes_On = TRUE;
// fall through
case HK_MOVE_FOOTPRINT: // Start move module
StartMove_Module( module, DC );
break;
}
module->Display_Infos( this );
break;
}
}
@ -243,41 +328,38 @@ void WinEDA_ModuleEditFrame::OnHotKey( wxDC* DC, int hotkey,
* Les majuscules/minuscules sont indifferenciees
*/
{
bool PopupOn = GetScreen()->GetCurItem()
&& GetScreen()->GetCurItem()->m_Flags;
if( hotkey == 0 )
return;
switch( hotkey )
/* 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';
int CommandCode = GetCommandCodeFromHotkey(hotkey, s_module_edit_Hotkey_List);
switch( CommandCode )
{
case WXK_DELETE:
case WXK_NUMPAD_DELETE:
if( PopupOn )
break;
break;
default:
case HK_NOT_FOUND:
return;
break;
case HK_HELP: // Display Current hotkey list
DisplayHotkeyList(this, s_module_edit_Hotkey_List);
break;
case 'r': // Rotation
case 'R':
break;
case HK_RESET_LOCAL_COORD: /*Reset the relative coord */
GetScreen()->m_O_Curseur = GetScreen()->m_Curseur;
break;
case 'y': // Mirror Y (drawlibpart)
case 'Y':
break;
case 'x': // Mirror X (drawlibpart)
case 'X':
break;
case HK_SWITCH_UNITS:
g_UnitMetric = (g_UnitMetric == INCHES ) ? MILLIMETRE : INCHES;
break;
case 'n':
case 'N': // Orient 0, no mirror (drawlibpart)
break;
case 'm':
case 'M': // Start move drawlibpart
if( PopupOn )
break;
break;
case HK_ZOOM_IN:
case HK_ZOOM_OUT:
case HK_ZOOM_REDRAW:
case HK_ZOOM_CENTER:
break;
}
}
@ -312,7 +394,7 @@ bool WinEDA_PcbFrame::OnHotkeyDeleteItem( wxDC* DC, EDA_BaseStruct* DrawStruct )
else if( GetScreen()->GetCurItem()->m_StructType == TYPETRACK )
{
GetScreen()->SetCurItem(
Delete_Segment( DC, (TRACK*) GetScreen()->GetCurItem() ));
Delete_Segment( DC, (TRACK*) GetScreen()->GetCurItem() ) );
GetScreen()->SetModify();
return TRUE;
}
@ -337,6 +419,6 @@ bool WinEDA_PcbFrame::OnHotkeyDeleteItem( wxDC* DC, EDA_BaseStruct* DrawStruct )
}
GetScreen()->SetModify();
GetScreen()->SetCurItem( NULL );
GetScreen()->SetCurItem(NULL);
return TRUE;
}