Commit 4a7dc4ad authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

Add menu item function fixes and other minor improvements.

* Rename all ADD_MENUITEM_* functions to AddMenuItem and move them to
  wxstruct.h since they are used by the Kicad main frame classes.
* Move SET_BITMAP and SETBITMAPS definitions to wxstruct.h.
* Fix a bug in SET_BITMAPS that prevented enabling menu item images on
  OSX.
* Rename MsgItem to EDA_MSG_ITEM.
* Remove redundant includes from modified files.
* Doxygen and coding style policy fixes.
parent fd486a11
Loading
Loading
Loading
Loading
+17 −19
Original line number Diff line number Diff line
@@ -3,8 +3,6 @@
/********************/

#include "fctsys.h"
#include "macros.h"
#include "bitmaps.h"

#include "3d_viewer.h"

@@ -136,30 +134,30 @@ void EDA_3D_FRAME::ReCreateMenuBar()
    wxMenu* referencesMenu = new wxMenu;
    menuBar->Append( referencesMenu, _( "&Preferences" ) );

    ADD_MENUITEM( referencesMenu, ID_MENU3D_BGCOLOR_SELECTION,
    AddMenuItem( referencesMenu, ID_MENU3D_BGCOLOR_SELECTION,
                 _( "Choose background color" ), KiBitmap( palette_xpm ) );

    ADD_MENUITEM( referencesMenu, ID_MENU3D_AXIS_ONOFF,
    AddMenuItem( referencesMenu, ID_MENU3D_AXIS_ONOFF,
                 _( "3D Axis On/Off" ), KiBitmap( axis3d_front_xpm ) );

    if( full_options )
    {
        ADD_MENUITEM( referencesMenu, ID_MENU3D_MODULE_ONOFF,
        AddMenuItem( referencesMenu, ID_MENU3D_MODULE_ONOFF,
                     _( "3D Footprints Shapes On/Off" ), KiBitmap( shape_3d_xpm ) );

        ADD_MENUITEM( referencesMenu, ID_MENU3D_ZONE_ONOFF,
        AddMenuItem( referencesMenu, ID_MENU3D_ZONE_ONOFF,
                     _( "Zone Filling On/Off" ), KiBitmap( add_zone_xpm ) );

        ADD_MENUITEM( referencesMenu, ID_MENU3D_COMMENTS_ONOFF,
        AddMenuItem( referencesMenu, ID_MENU3D_COMMENTS_ONOFF,
                     _( "Comments Layer On/Off" ), KiBitmap( edit_sheet_xpm ) );

        ADD_MENUITEM( referencesMenu, ID_MENU3D_DRAWINGS_ONOFF,
        AddMenuItem( referencesMenu, ID_MENU3D_DRAWINGS_ONOFF,
                     _( "Drawings Layer On/Off" ), KiBitmap( add_polygon_xpm ) );

        ADD_MENUITEM( referencesMenu, ID_MENU3D_ECO1_ONOFF,
        AddMenuItem( referencesMenu, ID_MENU3D_ECO1_ONOFF,
                     _( "Eco1 Layer On/Off" ), KiBitmap( tools_xpm ) );

        ADD_MENUITEM( referencesMenu, ID_MENU3D_ECO2_ONOFF,
        AddMenuItem( referencesMenu, ID_MENU3D_ECO2_ONOFF,
                     _( "Eco2 Layer On/Off" ), KiBitmap( tools_xpm ) );
    }

+5 −6
Original line number Diff line number Diff line
@@ -12,14 +12,13 @@
#include "build_version.h"
#include "fctsys.h"
#include "appl_wxstruct.h"
#include "common.h"
#include "online_help.h"
#include "id.h"
#include "confirm.h"
#include "eda_doc.h"
#include "wxstruct.h"
#include "macros.h"
#include "bitmaps.h"


/*
 * Class constructor for EDA_BASE_FRAME general options
@@ -364,7 +363,7 @@ void EDA_BASE_FRAME::AddHelpVersionInfoMenuEntry( wxMenu* aMenu )
    wxASSERT( aMenu != NULL );

    // Copy version string to clipboard for bug report purposes.
    ADD_MENUITEM_WITH_HELP( aMenu, ID_HELP_COPY_VERSION_STRING,
    AddMenuItem( aMenu, ID_HELP_COPY_VERSION_STRING,
                 _( "Copy &Version Information" ),
                 _( "Copy the version string to clipboard to send with bug reports" ),
                 KiBitmap( copy_button_xpm ) );
+12 −19
Original line number Diff line number Diff line
/***************/
/* edaappl.cpp */
/***************/

/***
 * @file edaapl.cpp
 *
@@ -21,15 +17,14 @@
#include <wx/tokenzr.h>

#include "appl_wxstruct.h"
#include "common.h"
#include "wxstruct.h"
#include "macros.h"
#include "param_config.h"
#include "worksheet.h"
#include "id.h"
#include "build_version.h"
#include "hotkeys_basic.h"
#include "macros.h"
#include "online_help.h"
#include "bitmaps.h"
#include "gestfich.h"


@@ -242,15 +237,12 @@ static struct LANGUAGE_DESCR s_Language_List[] =
};


/**
 * WinEDA_App Constructor
 */
WinEDA_App::WinEDA_App()
{
    m_Checker     = NULL;
    m_HtmlCtrl    = NULL;
    m_EDA_Config  = NULL;
    m_Env_Defined = FALSE;
    m_Env_Defined = false;
    m_LanguageId  = wxLANGUAGE_DEFAULT;
    m_PdfBrowserIsDefault = true;
    m_Locale = NULL;
@@ -259,9 +251,6 @@ WinEDA_App::WinEDA_App()
}


/**
 * WinEDA_App Destructor
 */
WinEDA_App::~WinEDA_App()
{
    SaveSettings();
@@ -269,11 +258,15 @@ WinEDA_App::~WinEDA_App()
    /* delete user datas */
    if( m_ProjectConfig )
        delete m_ProjectConfig;

    if( m_EDA_CommonConfig )
        delete m_EDA_CommonConfig;

    delete m_EDA_Config;

    if( m_Checker )
        delete m_Checker;

    delete m_Locale;
}

@@ -848,7 +841,7 @@ void WinEDA_App::AddMenuLanguageList( wxMenu* MasterMenu )
        menu->Append( item );
    }

    ADD_MENUITEM_WITH_HELP_AND_SUBMENU( MasterMenu, menu,
    AddMenuItem( MasterMenu, menu,
                 ID_LANGUAGE_CHOICE,
                 _( "Language" ),
                 _( "Select application language (only for testing!)" ),
+46 −30
Original line number Diff line number Diff line
@@ -7,15 +7,13 @@

#include "fctsys.h"
#include "appl_wxstruct.h"
#include "common.h"
#include "hotkeys_basic.h"
#include "macros.h"
#include "bitmaps.h"
#include "id.h"
#include "confirm.h"
#include "kicad_string.h"
#include "gestfich.h"
#include "wxstruct.h"
#include "macros.h"
#include "dialog_hotkeys_editor.h"

#include <wx/apptrait.h>
@@ -133,8 +131,10 @@ wxString ReturnKeyNameFromKeyCode( int aKeycode, bool* aIsFound )

    if( (aKeycode & GR_KB_CTRL) != 0 )
        modifier << MODIFIER_CTRL;

    if( (aKeycode & GR_KB_ALT) != 0 )
        modifier << MODIFIER_ALT;

    if( (aKeycode & GR_KB_SHIFT) != 0 )
        modifier << MODIFIER_SHIFT;

@@ -165,6 +165,7 @@ wxString ReturnKeyNameFromKeyCode( int aKeycode, bool* aIsFound )

    if( aIsFound )
        *aIsFound = found;

    fullkeyname = modifier + keyname;
    return fullkeyname;
}
@@ -195,6 +196,7 @@ wxString AddHotkeyName( const wxString& aText, Ki_HotkeyInfo** aList,
        else
            msg << wxT( " <" ) << keyname << wxT( ">" );
    }

    return msg;
}

@@ -223,12 +225,14 @@ wxString AddHotkeyName( const wxString& aText,
        {
            List    = aDescList->m_HK_InfoList;
            keyname = ReturnKeyNameFromCommandId( List, aCommandId );

            if( !keyname.IsEmpty() )
            {
                if( aIsShortCut )
                    msg << wxT( "\t" ) << keyname;
                else
                    msg << wxT( " <" ) << keyname << wxT( ">" );

                break;
            }
        }
@@ -252,6 +256,7 @@ wxString ReturnKeyNameFromCommandId( Ki_HotkeyInfo** aList, int aCommandId )
    for( ; *aList != NULL; aList++ )
    {
        Ki_HotkeyInfo* hk_decr = *aList;

        if( hk_decr->m_Idcommand == aCommandId )
        {
            keyname = ReturnKeyNameFromKeyCode( hk_decr->m_KeyCode );
@@ -285,7 +290,6 @@ int ReturnKeyCodeFromKeyName( const wxString& keyname )
            modifier |= GR_KB_CTRL;
            key.Remove( 0, 5 );
        }

        else if( key.StartsWith( MODIFIER_ALT ) )
        {
            modifier |= GR_KB_ALT;
@@ -297,8 +301,10 @@ int ReturnKeyCodeFromKeyName( const wxString& keyname )
            key.Remove( 0, 6 );
        }
        else
        {
            break;
        }
    }

    if( (key.length() == 1) && (key[0] > ' ') && (key[0] < 0x7F) )
    {
@@ -338,6 +344,7 @@ void DisplayHotkeyList( EDA_DRAW_FRAME* aFrame,
    for( ; aDescList->m_HK_InfoList != NULL; aDescList++ )
    {
        List = aDescList->m_HK_InfoList;

        for( ; *List != NULL; List++ )
        {
            Ki_HotkeyInfo* hk_decr = *List;
@@ -392,6 +399,7 @@ int EDA_BASE_FRAME::WriteHotkeyConfig( struct Ki_HotkeyInfoSectionDescriptor* aD

    /* Print the current hotkey list */
    Ki_HotkeyInfo** List;

    for( ; aDescList->m_HK_InfoList != NULL; aDescList++ )
    {
        if( aDescList->m_Comment )
@@ -400,10 +408,12 @@ int EDA_BASE_FRAME::WriteHotkeyConfig( struct Ki_HotkeyInfoSectionDescriptor* aD
            msg += wxString( aDescList->m_Comment );
            msg += wxT( "\n" );
        }

        msg += *aDescList->m_SectionTag;
        msg += wxT( "\n" );

        List = aDescList->m_HK_InfoList;

        for( ; *List != NULL; List++ )
        {
            Ki_HotkeyInfo* hk_decr = *List;
@@ -421,8 +431,11 @@ int EDA_BASE_FRAME::WriteHotkeyConfig( struct Ki_HotkeyInfoSectionDescriptor* aD
    if( aFullFileName )
    {
        FILE* file = wxFopen( *aFullFileName, wxT( "wt" ) );

        if( file )
        {
            fputs( TO_UTF8( msg ), file );
        }
        else
        {
            msg.Printf( wxT( "Unable to write file %s" ), GetChars( *aFullFileName ) );
@@ -504,8 +517,7 @@ int EDA_BASE_FRAME::ReadHotkeyConfig( struct Ki_HotkeyInfoSectionDescriptor* aDe
 * lines starting by # are ignored (comments)
 * lines like [xxx] are tags (example: [common] or [libedit] which identify sections
 */
void ParseHotkeyConfig(
    const wxString&                        data,
void ParseHotkeyConfig( const wxString&                        data,
                        struct Ki_HotkeyInfoSectionDescriptor* aDescList )
{
    /* Read the config */
@@ -525,6 +537,7 @@ void ParseHotkeyConfig(
        {
            CurrentHotkeyList = 0;
            Ki_HotkeyInfoSectionDescriptor* DList = aDescList;

            for( ; DList->m_HK_InfoList; DList++ )
            {
                if( *DList->m_SectionTag == line_type )
@@ -536,10 +549,13 @@ void ParseHotkeyConfig(

            continue;
        }

        if( line_type == wxT( "$Endlist" ) )
            break;

        if( line_type != wxT( "shortcut" ) )
            continue;

        if( CurrentHotkeyList == NULL )
            continue;

@@ -559,6 +575,7 @@ void ParseHotkeyConfig(
            if( hk_decr->m_InfoMsg == fctname )
            {
                int code = ReturnKeyCodeFromKeyName( keyname );

                if( code )
                    hk_decr->m_KeyCode = code;

@@ -635,14 +652,14 @@ void AddHotkeyConfigMenu( wxMenu* aMenu )
    wxMenu*     HotkeySubmenu = new wxMenu();

    /* List existing hotkey menu*/
    ADD_MENUITEM_WITH_HELP( HotkeySubmenu,
    AddMenuItem( HotkeySubmenu,
                 ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST,
                 _( "List Current Keys" ),
                 _( "Displays the current hotkeys list and corresponding commands" ),
                 KiBitmap( info_xpm ) );

    /* Call hotkeys editor*/
    ADD_MENUITEM_WITH_HELP( HotkeySubmenu, ID_PREFERENCES_HOTKEY_SHOW_EDITOR,
    AddMenuItem( HotkeySubmenu, ID_PREFERENCES_HOTKEY_SHOW_EDITOR,
                 _( "Edit Hotkeys" ),
                 _( "Call the hotkeys editor" ),
                 KiBitmap( editor_xpm ) );
@@ -650,21 +667,20 @@ void AddHotkeyConfigMenu( wxMenu* aMenu )
    HotkeySubmenu->AppendSeparator();

    /* create hotkey file to export current hotkeys config */
    ADD_MENUITEM_WITH_HELP( HotkeySubmenu, ID_PREFERENCES_HOTKEY_EXPORT_CONFIG,
    AddMenuItem( HotkeySubmenu, ID_PREFERENCES_HOTKEY_EXPORT_CONFIG,
                 _( "Export Hotkeys Config" ),
                 _( "Create a hotkey configuration file to export the current hotkey config" ),
                 KiBitmap( save_setup_xpm ) );

    /* Reload hotkey file */
    ADD_MENUITEM_WITH_HELP( HotkeySubmenu, ID_PREFERENCES_HOTKEY_IMPORT_CONFIG,
    AddMenuItem( HotkeySubmenu, ID_PREFERENCES_HOTKEY_IMPORT_CONFIG,
                 _( "Import Hotkeys Config" ),
                 _( "Load an existing hotkey configuration file" ),
                 KiBitmap( reload_xpm ) );

    /* Append HotkeySubmenu to menu */
    ADD_MENUITEM_WITH_HELP_AND_SUBMENU( aMenu, HotkeySubmenu,
    AddMenuItem( aMenu, HotkeySubmenu,
                 ID_PREFERENCES_HOTKEY_SUBMENU, _( "Hotkeys" ),
                 _( "Hotkeys configuration and preferences" ),
                 KiBitmap( hotkeys_xpm ) );
}
+4 −3
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ void EDA_MSG_PANEL::AppendMessage( const wxString& textUpper,
    text = ( textUpper.Len() > textLower.Len() ) ? textUpper : textLower;
    text.Append( ' ', pad );

    MsgItem item;
    EDA_MSG_ITEM item;

    /* Don't put the first message a window client position 0.  Offset by
     * one 'W' character width. */
@@ -133,7 +133,7 @@ void EDA_MSG_PANEL::SetMessage( int aXPosition, const wxString& aUpperText,
    else
        pos.x = m_last_x;

    MsgItem item;
    EDA_MSG_ITEM item;

    item.m_X = pos.x;

@@ -174,7 +174,7 @@ void EDA_MSG_PANEL::SetMessage( int aXPosition, const wxString& aUpperText,
}


void EDA_MSG_PANEL::showItem( wxDC& dc, const MsgItem& aItem )
void EDA_MSG_PANEL::showItem( wxDC& dc, const EDA_MSG_ITEM& aItem )
{
    int color = aItem.m_Color;

@@ -205,6 +205,7 @@ void EDA_MSG_PANEL::EraseMsgBox()
   Refresh();
}


void EDA_MSG_PANEL::erase( wxDC* DC )
{
    wxPen   pen;
Loading