Commit 606f2e91 authored by Mark Roszko's avatar Mark Roszko

Make hotkey command titles use consistent capitalization.

Rename "Switch highcontrast" to "Toggle High Contrast".
Eliminate most of the abbreviated hotkey titles.
Doxygenize dialog_hotkeys_editor.h and add missing license block.
Display <unassigned> if key code is 0 (NULL).
parent 651a92a8
......@@ -5,7 +5,7 @@
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 1992-2010 Kicad Developers, see change_log.txt for contributors.
* Copyright (C) 1992-2014 Kicad Developers, see CHANGELOG.TXT for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
......@@ -69,6 +69,13 @@ HOTKEY_LIST_CTRL::HOTKEY_LIST_CTRL( wxWindow *aParent, struct EDA_HOTKEY_CONFIG*
void HOTKEY_LIST_CTRL::OnSize( wxSizeEvent& aEvent )
{
recalculateColumns();
aEvent.Skip();
}
void HOTKEY_LIST_CTRL::recalculateColumns()
{
float totalLength = 0;
float scale = 0;
......@@ -99,8 +106,6 @@ void HOTKEY_LIST_CTRL::OnSize( wxSizeEvent& aEvent )
SetColumnWidth( 0, int( maxInfoMsgLength*scale ) - 2 );
SetColumnWidth( 1, int( maxKeyCodeLength*scale ) );
aEvent.Skip();
}
......@@ -144,7 +149,6 @@ void HOTKEY_LIST_CTRL::OnChar( wxKeyEvent& aEvent )
DeselectRow( m_curEditingRow );
m_curEditingRow = -1;
break;
default:
if( aEvent.ControlDown() )
key |= GR_KB_CTRL;
......@@ -174,15 +178,13 @@ void HOTKEY_LIST_CTRL::OnChar( wxKeyEvent& aEvent )
if( canUpdate )
{
m_hotkeys[m_curEditingRow]->m_KeyCode = key;
recalculateColumns();
}
// Remove selection
DeselectRow( m_curEditingRow );
m_curEditingRow = -1;
}
break;
}
}
RefreshItems(0,m_hotkeys.size()-1);
......@@ -311,12 +313,6 @@ void HOTKEYS_EDITOR_DIALOG::CancelClicked( wxCommandEvent& event )
}
/**
* Function UndoClicked
* Reinit the hotkeys to the initial state (remove all pending changes
*
* @param aEvent is the button press event, unused
*/
void HOTKEYS_EDITOR_DIALOG::UndoClicked( wxCommandEvent& aEvent )
{
std::vector<HOTKEY_SECTION_PAGE*>::iterator i;
......
......@@ -167,6 +167,10 @@ wxString KeyNameFromKeyCode( int aKeycode, bool* aIsFound )
int ii;
bool found = false;
// Assume keycode of 0 is "unassigned"
if( aKeycode == 0 )
return wxT( "<unassigned>");
if( (aKeycode & GR_KB_CTRL) != 0 )
modifier << MODIFIER_CTRL;
......
......@@ -131,7 +131,7 @@ static EDA_HOTKEY HkRedo( wxT( "Redo" ), HK_REDO, GR_KB_SHIFT + GR_KB_CTRL + 'Z'
// mouse click command:
static EDA_HOTKEY HkMouseLeftClick( wxT( "Mouse Left Click" ), HK_LEFT_CLICK, WXK_RETURN, 0 );
static EDA_HOTKEY HkMouseLeftDClick( wxT( "Mouse Left DClick" ), HK_LEFT_DCLICK, WXK_END, 0 );
static EDA_HOTKEY HkMouseLeftDClick( wxT( "Mouse Left Double Click" ), HK_LEFT_DCLICK, WXK_END, 0 );
// Schematic editor
static EDA_HOTKEY HkBeginWire( wxT( "Begin Wire" ), HK_BEGIN_WIRE, 'W', ID_WIRE_BUTT );
......@@ -149,7 +149,7 @@ static EDA_HOTKEY HkAddComponent( wxT( "Add Component" ), HK_ADD_NEW_COMPONENT,
ID_SCH_PLACE_COMPONENT );
static EDA_HOTKEY HkAddPower( wxT( "Add Power" ), HK_ADD_NEW_POWER, 'P',
ID_PLACE_POWER_BUTT );
static EDA_HOTKEY HkAddNoConn( wxT( "Add NoConnected Flag" ), HK_ADD_NOCONN_FLAG, 'Q',
static EDA_HOTKEY HkAddNoConn( wxT( "Add No Connect Flag" ), HK_ADD_NOCONN_FLAG, 'Q',
ID_NOCONN_BUTT );
static EDA_HOTKEY HkAddHierSheet( wxT( "Add Sheet" ), HK_ADD_HIER_SHEET, 'S',
ID_SHEET_SYMBOL_BUTT );
......@@ -207,7 +207,7 @@ static EDA_HOTKEY HkInsertPin( wxT( "Repeat Pin" ), HK_REPEAT_LAST, WXK_INSERT )
static EDA_HOTKEY HkMoveLibItem( wxT( "Move Library Item" ), HK_LIBEDIT_MOVE_GRAPHIC_ITEM, 'M' );
// Load/save files
static EDA_HOTKEY HkSaveLib( wxT( "Save Lib" ), HK_SAVE_LIB, 'S' + GR_KB_CTRL );
static EDA_HOTKEY HkSaveLib( wxT( "Save Library" ), HK_SAVE_LIB, 'S' + GR_KB_CTRL );
static EDA_HOTKEY HkSaveSchematic( wxT( "Save Schematic" ), HK_SAVE_SCH, 'S' + GR_KB_CTRL );
static EDA_HOTKEY HkLoadSchematic( wxT( "Load Schematic" ), HK_LOAD_SCH, 'L' + GR_KB_CTRL );
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004-2014 KiCad Developers, see CHANGELOG.TXT for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file dialog_hotkeys_editor.h
*/
#ifndef __dialog_hotkeys_editor__
#define __dialog_hotkeys_editor__
......@@ -22,14 +48,40 @@
class HOTKEYS_EDITOR_DIALOG;
/**
* Class HOTKEY_LIST_CTRL
* is a class to contain the contents of a hotkey editor tab page.
*/
class HOTKEY_LIST_CTRL : public wxListCtrl
{
public:
HOTKEY_LIST_CTRL( wxWindow* aParent, struct EDA_HOTKEY_CONFIG* aSection );
~HOTKEY_LIST_CTRL() {};
/**
* Function DeselectRow
* Deselect the given row
*
* @param aRow is the row to deselect
*/
void DeselectRow( int aRow );
/**
* Function GetHotkeys
* Access to return the vector used for the list control data. This will contain the
* "live" state of the user's configuration.
*
* @return Pointer to vector of hotkey settings
*/
std::vector< EDA_HOTKEY* >& GetHotkeys() { return m_hotkeys; }
/**
* Function RestoreFrom
* Restores list control hotkey keycodes to the keycodes present in the
* given hotkey configuration array.
*
* @param aSection is a pointer to the hotkey configuration array
*/
void RestoreFrom( struct EDA_HOTKEY_CONFIG* aSection );
private:
......@@ -37,13 +89,56 @@ private:
wxString* m_sectionTag;
std::vector< EDA_HOTKEY* > m_hotkeys;
/**
* Function recalculateColumns
* Adjusts the width of grid columns in proportion of the max text length of both
*/
void recalculateColumns();
protected:
/**
* Function OnGetItemText
* Returns the requested row, column data to the list control.
*
* @param aRow is the row of the data which matches our hotkeys vector as a index
* @param aColumn is the column of the data which is either Command(0) or KeyCode(1)
*
* @return String containing the text for the specified row, column combination
*/
wxString OnGetItemText( long aRow, long aColumn ) const;
/**
* Function OnChar
* Decoded key press handler which is used to set key codes in the list control
*
* @param aEvent is the key press event, the keycode is retrieved from it
*/
void OnChar( wxKeyEvent& aEvent );
/**
* Function OnListItemSelected
* Item selection handler which is used to record what index is selected to alter
* update with the key press
*
* @param aEvent is the button press event, unused
*/
void OnListItemSelected( wxListEvent& aEvent );
/**
* Function OnSize
* Sizing update handler to recompute the column widths dynamically and maximize them.
* Due to wxWidget's broken autosizing support (it's completely inconsistent across
* platforms), we just do it based on a scale of
*
* @param aEvent is the button press event, unused
*/
void OnSize( wxSizeEvent& aEvent );
};
/**
* Class HOTKEY_SECTION_PAGE
* is a class to contain the contents of a hotkey editor tab page.
*/
class HOTKEY_SECTION_PAGE : public wxPanel
{
public:
......@@ -59,25 +154,53 @@ public:
* @param title = title (name) of the notebook page
* @param id_NetType = netlist type id
*/
HOTKEY_SECTION_PAGE( HOTKEYS_EDITOR_DIALOG* aDialog, wxNotebook* aParent,
HOTKEY_SECTION_PAGE( HOTKEYS_EDITOR_DIALOG* aDialog, wxNotebook* aParent,
const wxString& aTitle,
EDA_HOTKEY_CONFIG* aSection );
~HOTKEY_SECTION_PAGE() {};
/**
* Function Restore
* Resets the hotkeys back to their original unedited state
*/
void Restore();
/**
* Function GetHotkeys
* Accessor to retrieve hotkeys list from list control
*
* @return Pointer to vector used for list control data
*/
std::vector< EDA_HOTKEY* >& GetHotkeys() { return m_hotkeyList->GetHotkeys(); }
/**
* Function GetHotkeySection
* Accessor to retrieve hotkey configuration array assigned to a tab control page
*
* @return Pointer to hotkey configuration array
*/
EDA_HOTKEY_CONFIG* GetHotkeySection() { return m_hotkeySection; }
/**
* Function GetDialog
* Returns pointer to parent dialog window
*
* @return Pointer to parent dialog window
*/
HOTKEYS_EDITOR_DIALOG* GetDialog() { return m_dialog; }
};
/**
* Class HOTKEYS_EDITOR_DIALOG
* is the child class of HOTKEYS_EDITOR_DIALOG_BASE. This is the class
* used to create a hotkey editor.
*/
class HOTKEYS_EDITOR_DIALOG : public HOTKEYS_EDITOR_DIALOG_BASE
{
protected:
EDA_DRAW_FRAME* m_parent;
struct EDA_HOTKEY_CONFIG* m_hotkeys;
std::vector<HOTKEY_SECTION_PAGE*> m_hotkeySectionPages;
public:
......@@ -85,14 +208,57 @@ public:
~HOTKEYS_EDITOR_DIALOG() {};
/**
* Function CanSetKey
* Check if we can set a hotkey, this will prompt the user if there
* is a conflict between keys. The key code should have already been
* checked that it's not for the same entry as its currently in or else
* it'll prompt the change on itself.
* The function will do conflict detection depending on aSectionTag.
* g_CommonSectionTag means the key code must be checked with all sections.
* While other tags means the key code only must be checked with the aSectionTag
* section and g_CommonSectionTag section.
*
* @param aKey is the key code that wants to be set
* @param aSectionTag is the section tag that the key code came from
*
* @return True if the user accepted the overwrite or no conflict existed
*/
bool CanSetKey( long aKey, const wxString* aSectionTag );
private:
/**
* Function OnOKClicked
* Close the dialog and make save all changes to hotkeys
*
* @param aEvent is the button press event, unused
*/
void OnOKClicked( wxCommandEvent& aEvent );
/**
* Function CancelClicked
* Close the dialog and make no changes to hotkeys
*
* @param aEvent is the button press event, unused
*/
void CancelClicked( wxCommandEvent& aEvent );
/**
* Function UndoClicked
* Reinit the hotkeys to the initial state (removes all pending changes)
*
* @param aEvent is the button press event, unused
*/
void UndoClicked( wxCommandEvent& aEvent );
};
/**
* Function InstallHotkeyFrame
* Create a hotkey editor dialog window with the provided hotkey configuration array
*
* @param aParent is the parent window
* @param aHotkeys is the hotkey configuration array
*/
void InstallHotkeyFrame( EDA_DRAW_FRAME* aParent, EDA_HOTKEY_CONFIG* aHotkeys );
#endif
......@@ -59,7 +59,7 @@
// mouse click command:
static EDA_HOTKEY HkMouseLeftClick( wxT( "Mouse Left Click" ), HK_LEFT_CLICK, WXK_RETURN, 0 );
static EDA_HOTKEY HkMouseLeftDClick( wxT( "Mouse Left DClick" ), HK_LEFT_DCLICK, WXK_END, 0 );
static EDA_HOTKEY HkMouseLeftDClick( wxT( "Mouse Left Double Click" ), HK_LEFT_DCLICK, WXK_END, 0 );
static EDA_HOTKEY HkResetLocalCoord( wxT( "Reset Local Coordinates" ),
HK_RESET_LOCAL_COORD, ' ' );
......
......@@ -36,7 +36,7 @@
// mouse click command:
static EDA_HOTKEY HkMouseLeftClick( wxT( "Mouse Left Click" ),
HK_LEFT_CLICK, WXK_RETURN, 0 );
static EDA_HOTKEY HkMouseLeftDClick( wxT( "Mouse Left DClick" ),
static EDA_HOTKEY HkMouseLeftDClick( wxT( "Mouse Left Double Click" ),
HK_LEFT_DCLICK, WXK_END, 0 );
static EDA_HOTKEY HkSwitch2CopperLayer( wxT( "Switch to Copper (B.Cu) layer" ),
......@@ -64,21 +64,21 @@ static EDA_HOTKEY HkSwitch2PreviousCopperLayer( wxT( "Switch to Previous Layer"
HK_SWITCH_LAYER_TO_PREVIOUS, '-' );
static EDA_HOTKEY HkSaveModule( wxT( "Save Module" ), HK_SAVE_MODULE, 'S' + GR_KB_CTRL );
static EDA_HOTKEY HkSavefile( wxT( "Save board" ), HK_SAVE_BOARD, 'S' + GR_KB_CTRL );
static EDA_HOTKEY HkSavefileAs( wxT( "Save board as" ), HK_SAVE_BOARD_AS, 'S' + GR_KB_CTRL + GR_KB_SHIFT );
static EDA_HOTKEY HkLoadfile( wxT( "Load board" ), HK_LOAD_BOARD, 'L' + GR_KB_CTRL );
static EDA_HOTKEY HkSavefile( wxT( "Save Board" ), HK_SAVE_BOARD, 'S' + GR_KB_CTRL );
static EDA_HOTKEY HkSavefileAs( wxT( "Save Board As" ), HK_SAVE_BOARD_AS, 'S' + GR_KB_CTRL + GR_KB_SHIFT );
static EDA_HOTKEY HkLoadfile( wxT( "Load Board" ), HK_LOAD_BOARD, 'L' + GR_KB_CTRL );
static EDA_HOTKEY HkFindItem( wxT( "Find Item" ), HK_FIND_ITEM, 'F' + GR_KB_CTRL );
static EDA_HOTKEY HkBackspace( wxT( "Delete track segment" ), HK_BACK_SPACE, WXK_BACK );
static EDA_HOTKEY HkAddNewTrack( wxT( "Add new track" ), HK_ADD_NEW_TRACK, 'X' );
static EDA_HOTKEY HkBackspace( wxT( "Delete Track Segment" ), HK_BACK_SPACE, WXK_BACK );
static EDA_HOTKEY HkAddNewTrack( wxT( "Add New Track" ), HK_ADD_NEW_TRACK, 'X' );
static EDA_HOTKEY HkAddThroughVia( wxT( "Add Through Via" ), HK_ADD_THROUGH_VIA, 'V' );
static EDA_HOTKEY HkSelLayerAndAddThroughVia( wxT( "Sel Layer and Add Through Via" ),
static EDA_HOTKEY HkSelLayerAndAddThroughVia( wxT( "Select Layer and Add Through Via" ),
HK_SEL_LAYER_AND_ADD_THROUGH_VIA, '<' );
static EDA_HOTKEY HkAddMicroVia( wxT( "Add MicroVia" ), HK_ADD_MICROVIA, 'V' + GR_KB_CTRL );
static EDA_HOTKEY HkAddBlindBuriedVia( wxT( "Add Blind/Buried Via" ), HK_ADD_BLIND_BURIED_VIA, 'V' + GR_KB_ALT );
static EDA_HOTKEY HkSelLayerAndAddBlindBuriedVia( wxT( "Sel Layer and Add Blind/Buried Via" ),
static EDA_HOTKEY HkSelLayerAndAddBlindBuriedVia( wxT( "Select Layer and Add Blind/Buried Via" ),
HK_SEL_LAYER_AND_ADD_BLIND_BURIED_VIA, '<' + GR_KB_ALT );
static EDA_HOTKEY HkSwitchTrackPosture( wxT( "Switch Track Posture" ), HK_SWITCH_TRACK_POSTURE, '/' );
static EDA_HOTKEY HkDragTrackKeepSlope( wxT( "Drag track keep slope" ), HK_DRAG_TRACK_KEEP_SLOPE, 'D' );
static EDA_HOTKEY HkDragTrackKeepSlope( wxT( "Drag Track Keep Slope" ), HK_DRAG_TRACK_KEEP_SLOPE, 'D' );
static EDA_HOTKEY HkPlaceItem( wxT( "Place Item" ), HK_PLACE_ITEM, 'P' );
static EDA_HOTKEY HkEditBoardItem( wxT( "Edit Item" ), HK_EDIT_ITEM, 'E' );
static EDA_HOTKEY HkFlipItem( wxT( "Flip Item" ), HK_FLIP_ITEM, 'F' );
......@@ -90,16 +90,16 @@ static EDA_HOTKEY HkGetAndMoveFootprint( wxT( "Get and Move Footprint" ), HK_GET
static EDA_HOTKEY HkLock_Unlock_Footprint( wxT( "Lock/Unlock Footprint" ), HK_LOCK_UNLOCK_FOOTPRINT, 'L' );
static EDA_HOTKEY HkDelete( wxT( "Delete Track or Footprint" ), HK_DELETE, WXK_DELETE );
static EDA_HOTKEY HkResetLocalCoord( wxT( "Reset Local Coordinates" ), HK_RESET_LOCAL_COORD, ' ' );
static EDA_HOTKEY HkSwitchHighContrastMode( wxT("Switch Highcontrast mode"), HK_SWITCH_HIGHCONTRAST_MODE,'H');
static EDA_HOTKEY HkSwitchHighContrastMode( wxT( "Toggle High Contrast Mode" ), HK_SWITCH_HIGHCONTRAST_MODE,'H');
static EDA_HOTKEY HkSetGridOrigin( wxT("Set Grid Origin"), HK_SET_GRID_ORIGIN, 'S' );
static EDA_HOTKEY HkResetGridOrigin( wxT("Reset Grid Origin"), HK_RESET_GRID_ORIGIN, 'Z' );
static EDA_HOTKEY HkSetGridOrigin( wxT( "Set Grid Origin" ), HK_SET_GRID_ORIGIN, 'S' );
static EDA_HOTKEY HkResetGridOrigin( wxT( "Reset Grid Origin" ), HK_RESET_GRID_ORIGIN, 'Z' );
static EDA_HOTKEY HkCanvasDefault( wxT( "Switch to default canvas" ),
static EDA_HOTKEY HkCanvasDefault( wxT( "Switch to Default Canvas" ),
HK_CANVAS_DEFAULT, WXK_F9 );
static EDA_HOTKEY HkCanvasOpenGL( wxT( "Switch to OpenGL canvas" ),
static EDA_HOTKEY HkCanvasOpenGL( wxT( "Switch to OpenGL Canvas" ),
HK_CANVAS_OPENGL, WXK_F11 );
static EDA_HOTKEY HkCanvasCairo( wxT( "Switch to Cairo canvas" ),
static EDA_HOTKEY HkCanvasCairo( wxT( "Switch to Cairo Canvas" ),
HK_CANVAS_CAIRO, WXK_F12 );
/* Fit on Screen */
......
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