From 7940f0773cc79e4f13615eee8df27fc4ab52bd05 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 27 May 2016 16:22:11 -0400 Subject: [PATCH] Try to fix a compil issue on OSX (no viable conversion from 'const wxString' to 'const wxChar *', in colors.cpp). --- common/colors.cpp | 64 +++++++++++++++++++++-------------------- common/selcolor.cpp | 8 +++--- include/colors.h | 6 ++-- include/hotkeys_basic.h | 2 +- include/i18n_utility.h | 41 ++++++++++++++++++++++++++ 5 files changed, 82 insertions(+), 39 deletions(-) create mode 100644 include/i18n_utility.h diff --git a/common/colors.cpp b/common/colors.cpp index 4e0e44188c..0cc6042542 100644 --- a/common/colors.cpp +++ b/common/colors.cpp @@ -23,6 +23,7 @@ */ #include +#include /** @@ -32,38 +33,39 @@ * when displaying superimposed objects * This list must have exactly NBCOLORS items */ + const StructColors g_ColorRefs[NBCOLORS] = { - { 0, 0, 0, BLACK, _( "Black" ), DARKDARKGRAY }, - { 72, 72, 72, DARKDARKGRAY, _( "Gray 1" ), DARKGRAY }, - { 132, 132, 132, DARKGRAY, _( "Gray 2" ), LIGHTGRAY }, - { 194, 194, 194, LIGHTGRAY, _( "Gray 3" ), WHITE }, - { 255, 255, 255, WHITE, _( "White" ), WHITE }, - { 194, 255, 255, LIGHTYELLOW, _( "L.Yellow" ), WHITE }, - { 72, 0, 0, DARKBLUE, _( "Blue 1" ), BLUE }, - { 0, 72, 0, DARKGREEN, _( "Green 1" ), GREEN }, - { 72, 72, 0, DARKCYAN, _( "Cyan 1" ), CYAN }, - { 0, 0, 72, DARKRED, _( "Red 1" ), RED }, - { 72, 0, 72, DARKMAGENTA, _( "Magenta 1" ), MAGENTA }, - { 0, 72, 72, DARKBROWN, _( "Brown 1" ), BROWN }, - { 132, 0, 0, BLUE, _( "Blue 2" ), LIGHTBLUE }, - { 0, 132, 0, GREEN, _( "Green 2" ), LIGHTGREEN }, - { 132, 132, 0, CYAN, _( "Cyan 2" ), LIGHTCYAN }, - { 0, 0, 132, RED, _( "Red 2" ), LIGHTRED }, - { 132, 0, 132, MAGENTA, _( "Magenta 2" ), LIGHTMAGENTA }, - { 0, 132, 132, BROWN, _( "Brown 2" ), YELLOW }, - { 194, 0, 0, LIGHTBLUE, _( "Blue 3" ), PUREBLUE, }, - { 0, 194, 0, LIGHTGREEN, _( "Green 3" ), PUREGREEN }, - { 194, 194, 0, LIGHTCYAN, _( "Cyan 3" ), PURECYAN }, - { 0, 0, 194, LIGHTRED, _( "Red 3" ), PURERED }, - { 194, 0, 194, LIGHTMAGENTA, _( "Magenta 3" ), PUREMAGENTA }, - { 0, 194, 194, YELLOW, _( "Yellow 3" ), PUREYELLOW }, - { 255, 0, 0, PUREBLUE, _( "Blue 4" ), WHITE }, - { 0, 255, 0, PUREGREEN, _( "Green 4" ), WHITE }, - { 255, 255, 0, PURECYAN, _( "Cyan 4" ), WHITE }, - { 0, 0, 255, PURERED, _( "Red 4" ), WHITE }, - { 255, 0, 255, PUREMAGENTA, _( "Magenta 4" ), WHITE }, - { 0, 255, 255, PUREYELLOW, _( "Yellow 4" ), WHITE }, + { 0, 0, 0, BLACK, _HKI( "Black" ), DARKDARKGRAY }, + { 72, 72, 72, DARKDARKGRAY, _HKI( "Gray 1" ), DARKGRAY }, + { 132, 132, 132, DARKGRAY, _HKI( "Gray 2" ), LIGHTGRAY }, + { 194, 194, 194, LIGHTGRAY, _HKI( "Gray 3" ), WHITE }, + { 255, 255, 255, WHITE, _HKI( "White" ), WHITE }, + { 194, 255, 255, LIGHTYELLOW, _HKI( "L.Yellow" ), WHITE }, + { 72, 0, 0, DARKBLUE, _HKI( "Blue 1" ), BLUE }, + { 0, 72, 0, DARKGREEN, _HKI( "Green 1" ), GREEN }, + { 72, 72, 0, DARKCYAN, _HKI( "Cyan 1" ), CYAN }, + { 0, 0, 72, DARKRED, _HKI( "Red 1" ), RED }, + { 72, 0, 72, DARKMAGENTA, _HKI( "Magenta 1" ), MAGENTA }, + { 0, 72, 72, DARKBROWN, _HKI( "Brown 1" ), BROWN }, + { 132, 0, 0, BLUE, _HKI( "Blue 2" ), LIGHTBLUE }, + { 0, 132, 0, GREEN, _HKI( "Green 2" ), LIGHTGREEN }, + { 132, 132, 0, CYAN, _HKI( "Cyan 2" ), LIGHTCYAN }, + { 0, 0, 132, RED, _HKI( "Red 2" ), LIGHTRED }, + { 132, 0, 132, MAGENTA, _HKI( "Magenta 2" ), LIGHTMAGENTA }, + { 0, 132, 132, BROWN, _HKI( "Brown 2" ), YELLOW }, + { 194, 0, 0, LIGHTBLUE, _HKI( "Blue 3" ), PUREBLUE, }, + { 0, 194, 0, LIGHTGREEN, _HKI( "Green 3" ), PUREGREEN }, + { 194, 194, 0, LIGHTCYAN, _HKI( "Cyan 3" ), PURECYAN }, + { 0, 0, 194, LIGHTRED, _HKI( "Red 3" ), PURERED }, + { 194, 0, 194, LIGHTMAGENTA, _HKI( "Magenta 3" ), PUREMAGENTA }, + { 0, 194, 194, YELLOW, _HKI( "Yellow 3" ), PUREYELLOW }, + { 255, 0, 0, PUREBLUE, _HKI( "Blue 4" ), WHITE }, + { 0, 255, 0, PUREGREEN, _HKI( "Green 4" ), WHITE }, + { 255, 255, 0, PURECYAN, _HKI( "Cyan 4" ), WHITE }, + { 0, 0, 255, PURERED, _HKI( "Red 4" ), WHITE }, + { 255, 0, 255, PUREMAGENTA, _HKI( "Magenta 4" ), WHITE }, + { 0, 255, 255, PUREYELLOW, _HKI( "Yellow 4" ), WHITE }, }; @@ -72,7 +74,7 @@ EDA_COLOR_T ColorByName( const wxString& aName ) // look for a match in the palette itself for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; trying = NextColor(trying) ) { - if( 0 == aName.CmpNoCase( g_ColorRefs[trying].m_Name ) ) + if( 0 == aName.CmpNoCase( ColorGetName( trying ) ) ) return trying; } diff --git a/common/selcolor.cpp b/common/selcolor.cpp index f24ad1baae..f3eb039c32 100644 --- a/common/selcolor.cpp +++ b/common/selcolor.cpp @@ -144,7 +144,6 @@ void WinEDA_SelColorFrame::Init_Dialog( int aOldColor ) wxBoxSizer* MainBoxSizer = NULL; wxFlexGridSizer* FlexColumnBoxSizer = NULL; wxBitmapButton* BitmapButton = NULL; - wxStaticText* Label = NULL; wxStaticLine* Line = NULL; wxStdDialogButtonSizer* StdDialogButtonSizer = NULL; wxButton* Button = NULL; @@ -215,9 +214,10 @@ void WinEDA_SelColorFrame::Init_Dialog( int aOldColor ) BitmapButton->SetFocus(); } - Label = new wxStaticText( this, -1, ColorGetName( buttcolor ), - wxDefaultPosition, wxDefaultSize, 0 ); - FlexColumnBoxSizer->Add( Label, 1, + wxStaticText* label = new wxStaticText( this, -1, + wxGetTranslation( ColorGetName( buttcolor ) ), + wxDefaultPosition, wxDefaultSize, 0 ); + FlexColumnBoxSizer->Add( label, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); } diff --git a/include/colors.h b/include/colors.h index 733932aba1..6b58bb7c98 100644 --- a/include/colors.h +++ b/include/colors.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2007-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2014 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 1992-2014 KiCad Developers, see AUTHORS.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 @@ -137,7 +137,7 @@ struct StructColors unsigned char m_Red; EDA_COLOR_T m_Numcolor; - const wxChar* m_Name; + const wxChar* m_ColorName; EDA_COLOR_T m_LightColor; }; @@ -177,7 +177,7 @@ inline const wxChar *ColorGetName( EDA_COLOR_T aColor ) { EDA_COLOR_T base = ColorGetBase( aColor ); wxASSERT( base > UNSPECIFIED_COLOR && base < NBCOLORS ); - return g_ColorRefs[base].m_Name; + return g_ColorRefs[base].m_ColorName; } inline void ColorSetBrush( wxBrush *aBrush, EDA_COLOR_T aColor ) diff --git a/include/hotkeys_basic.h b/include/hotkeys_basic.h index a2dc77302d..a402f5a5ed 100644 --- a/include/hotkeys_basic.h +++ b/include/hotkeys_basic.h @@ -37,7 +37,7 @@ // The translated string is used only when displaying the help window. // Therefore translation tools have to use the "_" and the "_HKI" prefix to extract // strings to translate -#define _HKI( x ) wxT( x ) +#include // _HKI definition class EDA_BASE_FRAME; diff --git a/include/i18n_utility.h b/include/i18n_utility.h new file mode 100644 index 0000000000..2da1fd0b07 --- /dev/null +++ b/include/i18n_utility.h @@ -0,0 +1,41 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2004-2016 KiCad Developers, see AUTHORS.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 i18n_utility.h + * @brief Some functions to handle hotkeys in KiCad + */ + +#ifndef I18N_UTILITY_H +#define I18N_UTILITY_H + +// A define to allow translation of strings which must be stored in English (for instance +// because they are used both as keywords and as messages in dialogs +// We do not want to use the _( x ) usual macro from wxWidgets, which calls wxGetTranslation(), +// because the English string is used in key file configuration +// The translated string is used only when displaying the help window. +// Therefore translation tools have to use the "_" and the "_HKI" prefix to extract +// strings to translate +#define _HKI( x ) wxT( x ) + +#endif // I18N_UTILITY_H