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

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
Loading
Loading
Loading
Loading
+9 −13
Original line number Diff line number Diff line
@@ -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;
+4 −0
Original line number Diff line number Diff line
@@ -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;

+3 −3
Original line number Diff line number Diff line
@@ -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 );

+169 −3
Original line number Diff line number Diff line
/*
 * 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:
@@ -63,15 +158,43 @@ public:
                         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:
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -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, ' ' );
Loading