Commit 9f1f455b authored by raburton's avatar raburton

set eol-style to native for new files

parent 9414bf67
/*********************/ /*********************/
/* hotkeys_basic.cpp */ /* hotkeys_basic.cpp */
/*********************/ /*********************/
/* Some functions to handle hotkeys in kicad /* Some functions to handle hotkeys in kicad
*/ */
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
#include "hotkeys_basic.h" #include "hotkeys_basic.h"
/* Class to handle hotkey commnands. hotkeys have a default value /* 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) 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_KeyCode = keycode; // Key code (ascii value for ascii keys or wxWidgets code for function key
m_InfoMsg = infomsg; // info message. m_InfoMsg = infomsg; // info message.
m_Idcommand = idcommand; // internal id for the corresponding command (see hotkey_id_commnand list) m_Idcommand = idcommand; // internal id for the corresponding command (see hotkey_id_commnand list)
} }
/****************************************************/ /****************************************************/
wxString ReturnKeyNameFromKeyCode(int keycode) wxString ReturnKeyNameFromKeyCode(int keycode)
/****************************************************/ /****************************************************/
/* /*
* return the key name from the key code * return the key name from the key code
* Only some wxWidgets key values are handled for function key * Only some wxWidgets key values are handled for function key
* @param key = key code (ascii value, or wxWidgets value for function keys) * @param key = key code (ascii value, or wxWidgets value for function keys)
* @return the key name in a wxString * @return the key name in a wxString
*/ */
{ {
wxString keyname, modifier, fullkeyname; wxString keyname, modifier, fullkeyname;
if ( (keycode & GR_KB_CTRL) != 0 ) modifier << wxT("Ctrl "); if ( (keycode & GR_KB_CTRL) != 0 ) modifier << wxT("Ctrl ");
if ( (keycode & GR_KB_ALT) != 0 ) modifier << wxT("Alt "); if ( (keycode & GR_KB_ALT) != 0 ) modifier << wxT("Alt ");
if ( (keycode & GR_KB_SHIFT) != 0 ) modifier << wxT("Shift "); if ( (keycode & GR_KB_SHIFT) != 0 ) modifier << wxT("Shift ");
switch ( keycode) switch ( keycode)
{ {
default: default:
keycode &= ~(GR_KB_CTRL|GR_KB_ALT|GR_KB_SHIFT); keycode &= ~(GR_KB_CTRL|GR_KB_ALT|GR_KB_SHIFT);
keyname.Printf(wxT("%c"), keycode); keyname.Printf(wxT("%c"), keycode);
break; break;
case WXK_ESCAPE: case WXK_ESCAPE:
keyname = wxT("Esc"); keyname = wxT("Esc");
break; break;
case WXK_F1: case WXK_F1:
case WXK_F2: case WXK_F2:
case WXK_F3: case WXK_F3:
case WXK_F4: case WXK_F4:
case WXK_F5: case WXK_F5:
case WXK_F6: case WXK_F6:
case WXK_F7: case WXK_F7:
case WXK_F8: case WXK_F8:
case WXK_F9: case WXK_F9:
case WXK_F10: case WXK_F10:
case WXK_F11: case WXK_F11:
case WXK_F12: case WXK_F12:
keyname.Printf(wxT("F%d"), keycode - WXK_F1 + 1); keyname.Printf(wxT("F%d"), keycode - WXK_F1 + 1);
break; break;
case ' ': case ' ':
keyname = wxT("space"); keyname = wxT("space");
break; break;
case '\t': case '\t':
keyname = wxT("Tab"); keyname = wxT("Tab");
break; break;
case WXK_DELETE: case WXK_DELETE:
keyname = wxT("Delete"); keyname = wxT("Delete");
break; break;
case WXK_BACK: case WXK_BACK:
keyname = wxT("Backspace"); keyname = wxT("Backspace");
break; break;
case WXK_INSERT: case WXK_INSERT:
keyname = wxT("Insert"); keyname = wxT("Insert");
break; break;
case WXK_END: case WXK_END:
keyname = wxT("End"); keyname = wxT("End");
break; break;
case WXK_PAGEUP: case WXK_PAGEUP:
keyname = wxT("Page Up"); keyname = wxT("Page Up");
break; break;
case WXK_PAGEDOWN: case WXK_PAGEDOWN:
keyname = wxT("Page Down"); keyname = wxT("Page Down");
break; break;
case WXK_ADD: case WXK_ADD:
keyname = wxT("+"); keyname = wxT("+");
break; break;
case WXK_SUBTRACT: case WXK_SUBTRACT:
keyname = wxT("-"); keyname = wxT("-");
break; break;
} }
fullkeyname = modifier + keyname; fullkeyname = modifier + keyname;
return fullkeyname; return fullkeyname;
} }
/****************************************************************************/ /****************************************************************************/
void DisplayHotkeyList(WinEDA_DrawFrame * frame, Ki_HotkeyInfo ** List) void DisplayHotkeyList(WinEDA_DrawFrame * frame, Ki_HotkeyInfo ** List)
/*****************************************************************************/ /*****************************************************************************/
/* /*
* Displays the current hotkey list * Displays the current hotkey list
* @param frame = current open frame * @param frame = current open frame
* @param List = pointer to a Ki_HotkeyInfo list of commands * @param List = pointer to a Ki_HotkeyInfo list of commands
* @return none * @return none
*/ */
{ {
wxString keyname; wxString keyname;
wxString msg = _("Current hotkey list:\n\n"); wxString msg = _("Current hotkey list:\n\n");
for ( ; * List != NULL; List++ ) for ( ; * List != NULL; List++ )
{ {
Ki_HotkeyInfo * hk_decr = * List; Ki_HotkeyInfo * hk_decr = * List;
if ( hk_decr->m_InfoMsg.IsEmpty() ) break; if ( hk_decr->m_InfoMsg.IsEmpty() ) break;
msg += _("key "); msg += _("key ");
keyname = ReturnKeyNameFromKeyCode(hk_decr->m_KeyCode); keyname = ReturnKeyNameFromKeyCode(hk_decr->m_KeyCode);
msg += keyname + wxT(": ") + hk_decr->m_InfoMsg + wxT("\n"); msg += keyname + wxT(": ") + hk_decr->m_InfoMsg + wxT("\n");
} }
DisplayInfo(frame, msg); DisplayInfo(frame, msg);
} }
/******************************************************************/ /******************************************************************/
int GetCommandCodeFromHotkey(int key, Ki_HotkeyInfo ** List) int GetCommandCodeFromHotkey(int key, Ki_HotkeyInfo ** List)
/******************************************************************/ /******************************************************************/
/* /*
* Return an id identifier fron a key code for OnHotKey() function * Return an id identifier fron a key code for OnHotKey() function
* @param key = key code (ascii value, or wxWidgets value for function keys * @param key = key code (ascii value, or wxWidgets value for function keys
* @param List = pointer to a Ki_HotkeyInfo list of commands * @param List = pointer to a Ki_HotkeyInfo list of commands
* @return the corresponding function identifier from the Ki_HotkeyInfo List * @return the corresponding function identifier from the Ki_HotkeyInfo List
*/ */
{ {
for ( ; * List != NULL; List++ ) for ( ; * List != NULL; List++ )
{ {
Ki_HotkeyInfo * hk_decr = * 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; return 0;
} }
/*******************/ /*******************/
/* hotkeys_basic.h */ /* hotkeys_basic.h */
/*******************/ /*******************/
/* Some functions to handle hotkeys in kicad /* Some functions to handle hotkeys in kicad
*/ */
#ifndef HOTKEYS_BASIC_H #ifndef HOTKEYS_BASIC_H
#define HOTKEYS_BASIC_H #define HOTKEYS_BASIC_H
/* Class to handle hotkey commnands. hotkeys have a default value /* 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)
*/ */
class Ki_HotkeyInfo class Ki_HotkeyInfo
{ {
public: public:
int m_KeyCode; // Key code (ascii value for ascii keys or wxWidgets code for function key int m_KeyCode; // Key code (ascii value for ascii keys or wxWidgets code for function key
wxString m_InfoMsg; // info message. wxString m_InfoMsg; // info message.
int m_Idcommand; // internal id for the corresponding command (see hotkey_id_commnand list) int m_Idcommand; // internal id for the corresponding command (see hotkey_id_commnand list)
public: public:
Ki_HotkeyInfo(const wxChar * infomsg, int idcommand, int keycode); Ki_HotkeyInfo(const wxChar * infomsg, int idcommand, int keycode);
}; };
/* Functions: /* Functions:
*/ */
wxString ReturnKeyNameFromKeyCode(int keycode); wxString ReturnKeyNameFromKeyCode(int keycode);
void DisplayHotkeyList(WinEDA_DrawFrame * frame, Ki_HotkeyInfo ** List); void DisplayHotkeyList(WinEDA_DrawFrame * frame, Ki_HotkeyInfo ** List);
int GetCommandCodeFromHotkey(int key, Ki_HotkeyInfo ** List); int GetCommandCodeFromHotkey(int key, Ki_HotkeyInfo ** List);
#endif // HOTKEYS_BASIC_H #endif // HOTKEYS_BASIC_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment