KiCad PCB EDA Suite
languages_menu.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
30 #include <pgm_base.h>
31 #include <id.h>
32 #include <menus_helpers.h>
33 #include <tool/tool_interactive.h>
34 #include <tool/action_menu.h>
35 #include <tool/conditional_menu.h>
36 #include <bitmaps.h>
37 #include <pgm_base.h>
38 
46 void AddMenuLanguageList( ACTION_MENU* aMasterMenu, TOOL_INTERACTIVE* aControlTool )
47 {
48  ACTION_MENU* langsMenu = new ACTION_MENU( false, aControlTool );
49  langsMenu->SetTitle( _( "Set Language" ) );
50  langsMenu->SetIcon( language_xpm );
51 
52  wxString tooltip;
53 
54  for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
55  {
56  wxString label;
57 
58  if( LanguagesList[ii].m_DoNotTranslate )
59  label = LanguagesList[ii].m_Lang_Label;
60  else
61  label = wxGetTranslation( LanguagesList[ii].m_Lang_Label );
62 
63  wxMenuItem* item = new wxMenuItem( langsMenu,
64  LanguagesList[ii].m_KI_Lang_Identifier, // wxMenuItem wxID
65  label,
66  tooltip,
67  wxITEM_CHECK );
68 
69  langsMenu->Append( item );
70  }
71 
72  // This must be done after the items are added
73  aMasterMenu->Add( langsMenu );
74 }
LANGUAGE_DESCR LanguagesList[]
An array containing all the languages that KiCad supports.
Definition: pgm_base.cpp:76
wxMenuItem * Add(const wxString &aLabel, int aId, const BITMAP_OPAQUE *aIcon)
Add a wxWidgets-style entry to the menu.
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:45
int m_KI_Lang_Identifier
KiCad identifier used in menu selection (See id.h)
Definition: pgm_base.h:63
void SetIcon(const BITMAP_OPAQUE *aIcon)
Assign an icon for the entry.
Definition: action_menu.cpp:71
void AddMenuLanguageList(ACTION_MENU *aMasterMenu, TOOL_INTERACTIVE *aControlTool)
Function AddMenuLanguageList creates a menu list for language choice, and add it as submenu to Master...
wxString m_Lang_Label
Labels used in menus.
Definition: pgm_base.h:66
const BITMAP_OPAQUE language_xpm[1]
Definition: language.cpp:37
void SetTitle(const wxString &aTitle) override
Set title for the menu.
Definition: action_menu.cpp:89
see class PGM_BASE
#define _(s)
Definition: 3d_actions.cpp:33