2007-08-30 08:15:05 +00:00
|
|
|
/*******************/
|
|
|
|
/* hotkeys_basic.h */
|
|
|
|
/*******************/
|
2007-08-20 11:33:45 +00:00
|
|
|
|
|
|
|
/* Some functions to handle hotkeys in kicad
|
2007-08-30 08:15:05 +00:00
|
|
|
*/
|
2007-08-20 11:33:45 +00:00
|
|
|
|
|
|
|
#ifndef HOTKEYS_BASIC_H
|
|
|
|
#define HOTKEYS_BASIC_H
|
|
|
|
|
2009-06-19 20:13:22 +00:00
|
|
|
#define DEFAULT_HOTKEY_FILENAME_EXT wxT( "key" )
|
2007-08-21 19:37:31 +00:00
|
|
|
|
|
|
|
|
2007-08-20 11:33:45 +00:00
|
|
|
/* Class to handle hotkey commnands. hotkeys have a default value
|
2007-09-19 15:29:50 +00:00
|
|
|
* This class allows the real key code changed by user(from a key code list file)
|
2007-08-30 08:15:05 +00:00
|
|
|
*/
|
2007-08-20 11:33:45 +00:00
|
|
|
class Ki_HotkeyInfo
|
|
|
|
{
|
|
|
|
public:
|
2007-08-30 08:15:05 +00:00
|
|
|
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)
|
2007-09-22 14:31:20 +00:00
|
|
|
int m_IdMenuEvent; // id to call the corresponding event (if any) (see id.h)
|
2007-08-20 11:33:45 +00:00
|
|
|
|
|
|
|
public:
|
2007-09-22 14:31:20 +00:00
|
|
|
Ki_HotkeyInfo( const wxChar* infomsg, int idcommand, int keycode, int idmenuevent = 0 );
|
2010-08-28 18:02:24 +00:00
|
|
|
Ki_HotkeyInfo( const Ki_HotkeyInfo* base);
|
2007-08-20 11:33:45 +00:00
|
|
|
};
|
|
|
|
|
2007-09-19 15:29:50 +00:00
|
|
|
/* handle a Section name and the corresponding list of hotkeys (Ki_HotkeyInfo list)
|
|
|
|
* hotkeys are grouped by section.
|
|
|
|
* a section is a list of hotkey infos ( a Ki_HotkeyInfo list).
|
|
|
|
* A full list of hoteys can used one or many sections
|
|
|
|
* for instance:
|
|
|
|
* the schematic editor uses a common section (zoom hotkeys list ..) and a specific section
|
|
|
|
* the library editor uses the same common section and a specific section
|
2009-01-22 18:45:33 +00:00
|
|
|
* this feature avoid duplications and made hotkey file config easier to understand and edit
|
2007-09-19 15:29:50 +00:00
|
|
|
*/
|
2007-09-06 11:52:26 +00:00
|
|
|
struct Ki_HotkeyInfoSectionDescriptor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxString* m_SectionTag; // The section name
|
2007-09-19 15:29:50 +00:00
|
|
|
Ki_HotkeyInfo** m_HK_InfoList; // List of Ki_HotkeyInfo pointers
|
2010-08-28 18:02:24 +00:00
|
|
|
const wchar_t* m_Comment; // comment: will be printed in the config file
|
2007-09-19 15:29:50 +00:00
|
|
|
// Info usage only
|
2007-09-06 11:52:26 +00:00
|
|
|
};
|
|
|
|
|
2007-09-19 15:29:50 +00:00
|
|
|
/* Identifiers (tags) in key code configuration file (or section names)
|
2007-09-06 11:52:26 +00:00
|
|
|
* .m_SectionTag member of a Ki_HotkeyInfoSectionDescriptor
|
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
extern wxString g_CommonSectionTag;
|
|
|
|
extern wxString g_SchematicSectionTag;
|
|
|
|
extern wxString g_LibEditSectionTag;
|
|
|
|
extern wxString g_BoardEditorSectionTag;
|
|
|
|
extern wxString g_ModuleEditSectionTag;
|
|
|
|
|
2007-09-19 15:29:50 +00:00
|
|
|
|
2007-08-20 11:33:45 +00:00
|
|
|
/* Functions:
|
2007-08-30 08:15:05 +00:00
|
|
|
*/
|
2007-09-22 14:31:20 +00:00
|
|
|
void AddHotkeyConfigMenu( wxMenu* menu );
|
2011-01-21 19:30:59 +00:00
|
|
|
void HandleHotkeyConfigMenuSelection( EDA_DRAW_FRAME* frame, int id );
|
2010-02-16 10:42:57 +00:00
|
|
|
|
2010-11-12 16:59:16 +00:00
|
|
|
/**
|
|
|
|
* Function ReturnKeyNameFromKeyCode
|
2010-02-16 10:42:57 +00:00
|
|
|
* return the key name from the key code
|
|
|
|
* Only some wxWidgets key values are handled for function key ( see
|
|
|
|
* s_Hotkey_Name_List[] )
|
|
|
|
* @param aKeycode = key code (ascii value, or wxWidgets value for function keys)
|
2010-08-28 18:02:24 +00:00
|
|
|
* @param aIsFound = a pointer to a bool to return true if found, or false. an be NULL default)
|
2010-02-16 10:42:57 +00:00
|
|
|
* @return the key name in a wxString
|
|
|
|
*/
|
2010-08-28 18:02:24 +00:00
|
|
|
wxString ReturnKeyNameFromKeyCode( int aKeycode, bool * aIsFound = NULL );
|
2010-02-16 10:42:57 +00:00
|
|
|
|
2010-11-12 16:59:16 +00:00
|
|
|
/**
|
|
|
|
* Function ReturnKeyNameFromCommandId
|
2010-02-16 10:42:57 +00:00
|
|
|
* return the key name from the Command id value ( m_Idcommand member value)
|
|
|
|
* @param aList = pointer to a Ki_HotkeyInfo list of commands
|
|
|
|
* @param aCommandId = Command Id value
|
|
|
|
* @return the key name in a wxString
|
|
|
|
*/
|
|
|
|
wxString ReturnKeyNameFromCommandId( Ki_HotkeyInfo** aList, int aCommandId );
|
|
|
|
|
2010-11-12 16:59:16 +00:00
|
|
|
/**
|
|
|
|
* Function ReturnKeyCodeFromKeyName
|
2010-08-29 16:36:52 +00:00
|
|
|
* 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_Hotkey_Name_List[],
|
|
|
|
* like F2 or space or an usual (ascii) char.
|
|
|
|
* @return the key code
|
|
|
|
*/
|
|
|
|
int ReturnKeyCodeFromKeyName( const wxString& keyname );
|
|
|
|
|
2010-11-12 16:59:16 +00:00
|
|
|
/**
|
|
|
|
* Function AddHotkeyName
|
2010-02-16 10:42:57 +00:00
|
|
|
* Add the key name from the Command id value ( m_Idcommand member value)
|
|
|
|
* @param aText = a wxString. returns aText + key name
|
|
|
|
* @param aList = pointer to a Ki_HotkeyInfo list of commands
|
|
|
|
* @param aCommandId = Command Id value
|
2010-12-14 15:56:30 +00:00
|
|
|
* @param aIsShortCut = true to add <tab><keyname> (active shortcuts in menus)
|
|
|
|
* = false to add <spaces><(keyname)>
|
2010-02-16 10:42:57 +00:00
|
|
|
* @return a wxString (aTest + key name) if key found or aText without modification
|
|
|
|
*/
|
|
|
|
wxString AddHotkeyName( const wxString& aText, Ki_HotkeyInfo** aList,
|
|
|
|
int aCommandId,
|
|
|
|
bool aIsShortCut = true);
|
|
|
|
|
2010-11-12 16:59:16 +00:00
|
|
|
/**
|
|
|
|
* Function AddHotkeyName
|
2010-02-16 10:42:57 +00:00
|
|
|
* Add the key name from the Command id value ( m_Idcommand member value)
|
|
|
|
* @param aText = a wxString. returns aText + key name
|
2010-12-28 11:24:42 +00:00
|
|
|
* @param aDescrList = pointer to a Ki_HotkeyInfoSectionDescriptor DescrList of commands
|
2010-02-16 10:42:57 +00:00
|
|
|
* @param aCommandId = Command Id value
|
2010-12-14 15:56:30 +00:00
|
|
|
* @param aIsShortCut = true to add <tab><keyname> (active shortcuts in menus)
|
|
|
|
* = false to add <spaces><(keyname)>
|
2010-02-16 10:42:57 +00:00
|
|
|
* @return a wxString (aTest + key name) if key found or aText without modification
|
|
|
|
*/
|
|
|
|
wxString AddHotkeyName( const wxString& aText,
|
|
|
|
struct Ki_HotkeyInfoSectionDescriptor* aDescrList,
|
|
|
|
int aCommandId,
|
|
|
|
bool aIsShortCut = true);
|
|
|
|
|
2010-11-12 16:59:16 +00:00
|
|
|
/**
|
|
|
|
* Function DisplayHotkeyList
|
2010-02-16 11:02:20 +00:00
|
|
|
* Displays the current hotkey list
|
|
|
|
* @param aFrame = current active frame
|
2010-12-14 15:56:30 +00:00
|
|
|
* @param aList = pointer to a Ki_HotkeyInfoSectionDescriptor list (Null terminated)
|
2010-02-16 11:02:20 +00:00
|
|
|
*/
|
2011-01-21 19:30:59 +00:00
|
|
|
void DisplayHotkeyList( EDA_DRAW_FRAME* aFrame,
|
2010-02-16 11:02:20 +00:00
|
|
|
struct Ki_HotkeyInfoSectionDescriptor* aList );
|
|
|
|
|
2010-11-12 16:59:16 +00:00
|
|
|
/**
|
|
|
|
* Function GetDescriptorFromHotkey
|
2010-02-16 11:02:20 +00:00
|
|
|
* Return a Ki_HotkeyInfo * pointer fron a key code for OnHotKey() function
|
|
|
|
* @param aKey = key code (ascii value, or wxWidgets value for function keys
|
|
|
|
* @param aList = pointer to a Ki_HotkeyInfo list of commands
|
|
|
|
* @return the corresponding Ki_HotkeyInfo pointer from the Ki_HotkeyInfo List
|
|
|
|
*/
|
|
|
|
Ki_HotkeyInfo* GetDescriptorFromHotkey( int aKey, Ki_HotkeyInfo** aList );
|
2007-08-20 11:33:45 +00:00
|
|
|
|
2010-12-20 17:44:25 +00:00
|
|
|
/**
|
|
|
|
* Function ReadHotkeyConfig
|
|
|
|
* Read hotkey configuration for a given app,
|
|
|
|
* possibly before the frame for that app has been created
|
|
|
|
* @param Appname = the value of the app's m_FrameName
|
|
|
|
* @param aDescList = the hotkey data
|
2010-08-28 18:02:24 +00:00
|
|
|
*/
|
|
|
|
void ReadHotkeyConfig( const wxString& Appname,
|
2010-12-20 17:44:25 +00:00
|
|
|
struct Ki_HotkeyInfoSectionDescriptor* aDescList );
|
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
void ParseHotkeyConfig( const wxString& data,
|
2010-12-20 17:44:25 +00:00
|
|
|
struct Ki_HotkeyInfoSectionDescriptor* aDescList );
|
2010-08-28 18:02:24 +00:00
|
|
|
|
2007-08-20 11:33:45 +00:00
|
|
|
|
2010-02-14 18:14:33 +00:00
|
|
|
// common hotkeys event id
|
2010-02-16 11:02:20 +00:00
|
|
|
// these hotkey ID are used in many files, so they are define here only once.
|
2010-02-14 18:14:33 +00:00
|
|
|
enum common_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_ZOOM_AUTO,
|
2010-11-12 16:59:16 +00:00
|
|
|
HK_UNDO,
|
|
|
|
HK_REDO,
|
2010-02-14 18:14:33 +00:00
|
|
|
HK_COMMON_END
|
|
|
|
};
|
|
|
|
|
2007-08-20 11:33:45 +00:00
|
|
|
#endif // HOTKEYS_BASIC_H
|