Common folder housekeeping part 3.

This commit is contained in:
Wayne Stambaugh 2025-01-16 07:37:05 -05:00
parent af38f76f01
commit e09b095533
76 changed files with 621 additions and 379 deletions

View File

@ -150,16 +150,16 @@ bool isCtrlSlash( wxKeyEvent& aEvent )
// OK, now the wxWidgets hacks start. // OK, now the wxWidgets hacks start.
// (We should abandon these if https://trac.wxwidgets.org/ticket/18911 gets resolved.) // (We should abandon these if https://trac.wxwidgets.org/ticket/18911 gets resolved.)
// Many Latin America and European keyboars have have the / over the 7. We know that // Many Latin America and European keyboards have have the / over the 7. We know that
// wxWidgets messes this up and returns Shift+7 through GetUnicodeKey(). However, other // wxWidgets messes this up and returns Shift+7 through GetUnicodeKey(). However, other
// keyboards (such as France and Belgium) have 7 in the shifted position, so a Shift+7 // keyboards (such as France and Belgium) have 7 in the shifted position, so a Shift+7
// *could* be legitimate. // *could* be legitimate.
// However, we *are* checking Ctrl, so to assume any Shift+7 is a Ctrl-/ really only // However, we *are* checking Ctrl, so to assume any Shift+7 is a Ctrl-/ really only
// disallows Ctrl+Shift+7 from doing something else, which is probably OK. (This routine // disallows Ctrl+Shift+7 from doing something else, which is probably OK. (This routine
// is only used in the Scintilla editor, not in the rest of Kicad.) // is only used in the Scintilla editor, not in the rest of KiCad.)
// The other main shifted loation of / is over : (France and Belgium), so we'll sacrifice // The other main shifted location of / is over : (France and Belgium), so we'll sacrifice
// Ctrl+Shift+: too. // Ctrl+Shift+: too.
if( aEvent.ShiftDown() && ( aEvent.GetUnicodeKey() == '7' || aEvent.GetUnicodeKey() == ':' ) ) if( aEvent.ShiftDown() && ( aEvent.GetUnicodeKey() == '7' || aEvent.GetUnicodeKey() == ':' ) )
@ -576,7 +576,8 @@ void SCINTILLA_TRICKS::DoTextVarAutocomplete(
auto textVarRef = auto textVarRef =
[&]( int pos ) [&]( int pos )
{ {
return pos >= 2 && m_te->GetCharAt( pos-2 ) == '$' && m_te->GetCharAt( pos-1 ) == '{'; return pos >= 2 && m_te->GetCharAt( pos-2 ) == '$'
&& m_te->GetCharAt( pos-1 ) == '{';
}; };
// Check for cross-reference // Check for cross-reference

View File

@ -58,7 +58,8 @@ static wxString base_dir( const wxString& aRelativePath, const wxString& aBaseDi
if( !fn.IsAbsolute() && !!aBaseDir ) if( !fn.IsAbsolute() && !!aBaseDir )
{ {
wxASSERT_MSG( wxFileName( aBaseDir ).IsAbsolute(), wxT( "Must pass absolute path in aBaseDir" ) ); wxASSERT_MSG( wxFileName( aBaseDir ).IsAbsolute(),
wxT( "Must pass absolute path in aBaseDir" ) );
fn.MakeRelativeTo( aBaseDir ); fn.MakeRelativeTo( aBaseDir );
} }
@ -82,7 +83,7 @@ wxString SEARCH_STACK::FilenameWithRelativePathInSearchList(
// Search for the shortest subpath within 'this': // Search for the shortest subpath within 'this':
if( fn.MakeRelativeTo( base_dir( (*this)[kk], aBaseDir ) ) ) if( fn.MakeRelativeTo( base_dir( (*this)[kk], aBaseDir ) ) )
{ {
if( fn.GetPathWithSep().StartsWith( wxT("..") ) ) // Path outside kicad libs paths if( fn.GetPathWithSep().StartsWith( wxT("..") ) ) // Path outside KiCad libs paths
continue; continue;
if( pathlen > fn.GetPath().Len() ) // A better (shortest) subpath is found if( pathlen > fn.GetPath().Len() ) // A better (shortest) subpath is found

View File

@ -325,8 +325,10 @@ bool APP_SETTINGS_BASE::migrateWindowConfig( wxConfigBase* aCfg, const std::stri
ret &= fromLegacy<int>( aCfg, aFrame + "Pos_x", aJsonPath + ".pos_x" ); ret &= fromLegacy<int>( aCfg, aFrame + "Pos_x", aJsonPath + ".pos_x" );
ret &= fromLegacy<int>( aCfg, aFrame + "Pos_y", aJsonPath + ".pos_y" ); ret &= fromLegacy<int>( aCfg, aFrame + "Pos_y", aJsonPath + ".pos_y" );
ret &= fromLegacy<bool>( aCfg, frameGDO + "ForceDisplayCursor", cursorPath + ".always_show_cursor" ); ret &= fromLegacy<bool>( aCfg, frameGDO + "ForceDisplayCursor",
ret &= fromLegacy<bool>( aCfg, frameGDO + "CursorFullscreen", cursorPath + ".fullscreen_cursor" ); cursorPath + ".always_show_cursor" );
ret &= fromLegacy<bool>( aCfg, frameGDO + "CursorFullscreen",
cursorPath + ".fullscreen_cursor" );
ret &= fromLegacy<int>( aCfg, aFrame + "_LastGridSize", gridPath + ".last_size" ); ret &= fromLegacy<int>( aCfg, aFrame + "_LastGridSize", gridPath + ".last_size" );

View File

@ -99,6 +99,7 @@ void from_json( const nlohmann::json& j, BOM_PRESET& f )
j.at( "filter_string" ).get_to( f.filterString ); j.at( "filter_string" ).get_to( f.filterString );
j.at( "group_symbols" ).get_to( f.groupSymbols ); j.at( "group_symbols" ).get_to( f.groupSymbols );
j.at( "exclude_dnp" ).get_to( f.excludeDNP ); j.at( "exclude_dnp" ).get_to( f.excludeDNP );
// Was not present in initial BOM settings in 8.0, so default to false if not found // Was not present in initial BOM settings in 8.0, so default to false if not found
f.includeExcludedFromBOM = j.value( "include_excluded_from_bom", false ); f.includeExcludedFromBOM = j.value( "include_excluded_from_bom", false );
} }
@ -162,7 +163,8 @@ BOM_PRESET BOM_PRESET::GroupedByValue()
BOM_PRESET BOM_PRESET::GroupedByValueFootprint() BOM_PRESET BOM_PRESET::GroupedByValueFootprint()
{ {
BOM_PRESET p{ BOM_PRESET p{
_HKI( "Grouped By Value and Footprint" ), true, {}, _( "Reference" ), true, "", true, false, false _HKI( "Grouped By Value and Footprint" ), true, {}, _( "Reference" ), true, "",
true, false, false
}; };
p.fieldsOrdered = std::vector<BOM_FIELD>{ p.fieldsOrdered = std::vector<BOM_FIELD>{
@ -198,12 +200,14 @@ BOM_PRESET BOM_PRESET::Attributes()
return p; return p;
} }
std::vector<BOM_PRESET> BOM_PRESET::BuiltInPresets() std::vector<BOM_PRESET> BOM_PRESET::BuiltInPresets()
{ {
return { BOM_PRESET::DefaultEditing(), BOM_PRESET::GroupedByValue(), return { BOM_PRESET::DefaultEditing(), BOM_PRESET::GroupedByValue(),
BOM_PRESET::GroupedByValueFootprint(), BOM_PRESET::Attributes() }; BOM_PRESET::GroupedByValueFootprint(), BOM_PRESET::Attributes() };
} }
//Implementations for BOM_FMT_PRESET //Implementations for BOM_FMT_PRESET
bool BOM_FMT_PRESET::operator==( const BOM_FMT_PRESET& rhs ) const bool BOM_FMT_PRESET::operator==( const BOM_FMT_PRESET& rhs ) const
{ {
@ -256,11 +260,13 @@ BOM_FMT_PRESET BOM_FMT_PRESET::CSV()
return { _HKI( "CSV" ), true, wxS( "," ), wxT( "\"" ), wxT( "," ), wxT( "" ), false, false }; return { _HKI( "CSV" ), true, wxS( "," ), wxT( "\"" ), wxT( "," ), wxT( "" ), false, false };
} }
BOM_FMT_PRESET BOM_FMT_PRESET::TSV() BOM_FMT_PRESET BOM_FMT_PRESET::TSV()
{ {
return { _HKI( "TSV" ), true, wxS( "\t" ), wxT( "" ), wxT( "," ), wxT( "" ), false, false }; return { _HKI( "TSV" ), true, wxS( "\t" ), wxT( "" ), wxT( "," ), wxT( "" ), false, false };
} }
BOM_FMT_PRESET BOM_FMT_PRESET::Semicolons() BOM_FMT_PRESET BOM_FMT_PRESET::Semicolons()
{ {
return { return {
@ -268,11 +274,13 @@ BOM_FMT_PRESET BOM_FMT_PRESET::Semicolons()
}; };
} }
std::vector<BOM_FMT_PRESET> BOM_FMT_PRESET::BuiltInPresets() std::vector<BOM_FMT_PRESET> BOM_FMT_PRESET::BuiltInPresets()
{ {
return { BOM_FMT_PRESET::CSV(), BOM_FMT_PRESET::TSV(), BOM_FMT_PRESET::Semicolons() }; return { BOM_FMT_PRESET::CSV(), BOM_FMT_PRESET::TSV(), BOM_FMT_PRESET::Semicolons() };
} }
#if !defined( __MINGW32__ ) #if !defined( __MINGW32__ )
template class KICOMMON_API PARAM_LIST<BOM_PRESET>; template class KICOMMON_API PARAM_LIST<BOM_PRESET>;
template class KICOMMON_API PARAM_LIST<BOM_FMT_PRESET>; template class KICOMMON_API PARAM_LIST<BOM_FMT_PRESET>;

View File

@ -450,23 +450,28 @@ bool COMMON_SETTINGS::migrateSchema0to1()
} }
catch( ... ) catch( ... )
{ {
wxLogTrace( traceSettings, wxT( "COMMON_SETTINGS::Migrate 0->1: mousewheel_pan not found" ) ); wxLogTrace( traceSettings,
wxT( "COMMON_SETTINGS::Migrate 0->1: mousewheel_pan not found" ) );
} }
if( mwp ) if( mwp )
{ {
( *m_internals )[nlohmann::json::json_pointer( "/input/horizontal_pan" )] = true; ( *m_internals )[nlohmann::json::json_pointer( "/input/horizontal_pan" )] = true;
( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_pan_h" )] = WXK_SHIFT; ( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_pan_h" )] =
WXK_SHIFT;
( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_pan_v" )] = 0; ( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_pan_v" )] = 0;
( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_zoom" )] = WXK_CONTROL; ( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_zoom" )] =
WXK_CONTROL;
} }
else else
{ {
( *m_internals )[nlohmann::json::json_pointer( "/input/horizontal_pan" )] = false; ( *m_internals )[nlohmann::json::json_pointer( "/input/horizontal_pan" )] = false;
( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_pan_h" )] = WXK_CONTROL; ( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_pan_h" )] =
( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_pan_v" )] = WXK_SHIFT; WXK_CONTROL;
( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_pan_v" )] =
WXK_SHIFT;
( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_zoom" )] = 0; ( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_zoom" )] = 0;
} }
@ -483,17 +488,21 @@ bool COMMON_SETTINGS::migrateSchema1to2()
try try
{ {
prefer_selection = m_internals->at( v1_pointer ); prefer_selection = m_internals->at( v1_pointer );
m_internals->at( nlohmann::json::json_pointer( "/input"_json_pointer ) ).erase( "prefer_select_to_drag" ); m_internals->at( nlohmann::json::json_pointer( "/input"_json_pointer ) )
.erase( "prefer_select_to_drag" );
} }
catch( ... ) catch( ... )
{ {
wxLogTrace( traceSettings, wxT( "COMMON_SETTINGS::Migrate 1->2: prefer_select_to_drag not found" ) ); wxLogTrace( traceSettings,
wxT( "COMMON_SETTINGS::Migrate 1->2: prefer_select_to_drag not found" ) );
} }
if( prefer_selection ) if( prefer_selection )
( *m_internals )[nlohmann::json::json_pointer( "/input/mouse_left" )] = MOUSE_DRAG_ACTION::SELECT; ( *m_internals )[nlohmann::json::json_pointer( "/input/mouse_left" )] =
MOUSE_DRAG_ACTION::SELECT;
else else
( *m_internals )[nlohmann::json::json_pointer( "/input/mouse_left" )] = MOUSE_DRAG_ACTION::DRAG_ANY; ( *m_internals )[nlohmann::json::json_pointer( "/input/mouse_left" )] =
MOUSE_DRAG_ACTION::DRAG_ANY;
return true; return true;
} }
@ -518,11 +527,12 @@ bool COMMON_SETTINGS::migrateSchema2to3()
wxString key = path.m_Alias; wxString key = path.m_Alias;
const wxString& val = path.m_Pathvar; const wxString& val = path.m_Pathvar;
// The 3d alias config didnt use the same naming restrictions as real env variables // The 3d alias config didn't use the same naming restrictions as real env variables
// We need to sanitize them // We need to sanitize them
// upper case only // upper case only
key.MakeUpper(); key.MakeUpper();
// logically swap - with _ // logically swap - with _
key.Replace( wxS( "-" ), wxS( "_" ) ); key.Replace( wxS( "-" ), wxS( "_" ) );
@ -559,7 +569,8 @@ bool COMMON_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
{ {
wxString key, value; wxString key, value;
long index = 0; long index = 0;
nlohmann::json::json_pointer ptr = m_internals->PointerFromString( "environment.vars" ); nlohmann::json::json_pointer ptr =
m_internals->PointerFromString( "environment.vars" );
aCfg->SetPath( "EnvironmentVariables" ); aCfg->SetPath( "EnvironmentVariables" );
( *m_internals )[ptr] = nlohmann::json( {} ); ( *m_internals )[ptr] = nlohmann::json( {} );

View File

@ -599,7 +599,8 @@ std::optional<ValueType> JSON_SETTINGS::Get( const std::string& aPath ) const
// Instantiate all required templates here to allow reducing scope of json.hpp // Instantiate all required templates here to allow reducing scope of json.hpp
template KICOMMON_API std::optional<bool> JSON_SETTINGS::Get<bool>( const std::string& aPath ) const; template KICOMMON_API std::optional<bool>
JSON_SETTINGS::Get<bool>( const std::string& aPath ) const;
template KICOMMON_API std::optional<double> template KICOMMON_API std::optional<double>
JSON_SETTINGS::Get<double>( const std::string& aPath ) const; JSON_SETTINGS::Get<double>( const std::string& aPath ) const;
template KICOMMON_API std::optional<float> template KICOMMON_API std::optional<float>
@ -621,7 +622,8 @@ template KICOMMON_API std::optional<BOM_PRESET>
JSON_SETTINGS::Get<BOM_PRESET>( const std::string& aPath ) const; JSON_SETTINGS::Get<BOM_PRESET>( const std::string& aPath ) const;
template KICOMMON_API std::optional<BOM_FMT_PRESET> template KICOMMON_API std::optional<BOM_FMT_PRESET>
JSON_SETTINGS::Get<BOM_FMT_PRESET>( const std::string& aPath ) const; JSON_SETTINGS::Get<BOM_FMT_PRESET>( const std::string& aPath ) const;
template KICOMMON_API std::optional<GRID> JSON_SETTINGS::Get<GRID>( const std::string& aPath ) const; template KICOMMON_API std::optional<GRID>
JSON_SETTINGS::Get<GRID>( const std::string& aPath ) const;
template KICOMMON_API std::optional<wxPoint> template KICOMMON_API std::optional<wxPoint>
JSON_SETTINGS::Get<wxPoint>( const std::string& aPath ) const; JSON_SETTINGS::Get<wxPoint>( const std::string& aPath ) const;
template KICOMMON_API std::optional<wxSize> template KICOMMON_API std::optional<wxSize>

View File

@ -60,7 +60,8 @@ KICAD_SETTINGS::KICAD_SETTINGS() :
m_params.emplace_back( new PARAM<wxPoint>( "template.window.pos", &m_TemplateWindowPos, m_params.emplace_back( new PARAM<wxPoint>( "template.window.pos", &m_TemplateWindowPos,
wxDefaultPosition ) ); wxDefaultPosition ) );
m_params.emplace_back( new PARAM<wxSize>( "template.window.size", &m_TemplateWindowSize, wxDefaultSize ) ); m_params.emplace_back( new PARAM<wxSize>( "template.window.size", &m_TemplateWindowSize,
wxDefaultSize ) );
m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>( m_params.emplace_back( new PARAM_LAMBDA<nlohmann::json>(
"pcm.repositories", "pcm.repositories",

View File

@ -83,6 +83,7 @@ SETTINGS_MANAGER::SETTINGS_MANAGER( bool aHeadless ) :
} }
} }
SETTINGS_MANAGER::~SETTINGS_MANAGER() SETTINGS_MANAGER::~SETTINGS_MANAGER()
{ {
for( std::unique_ptr<PROJECT>& project : m_projects_list ) for( std::unique_ptr<PROJECT>& project : m_projects_list )
@ -120,7 +121,6 @@ void SETTINGS_MANAGER::Load()
{ {
// TODO(JE) We should check for dirty settings here and write them if so, because // TODO(JE) We should check for dirty settings here and write them if so, because
// Load() could be called late in the application lifecycle // Load() could be called late in the application lifecycle
std::vector<JSON_SETTINGS*> toLoad; std::vector<JSON_SETTINGS*> toLoad;
// Cache a copy of raw pointers; m_settings may be modified during the load loop // Cache a copy of raw pointers; m_settings may be modified during the load loop
@ -192,7 +192,7 @@ void SETTINGS_MANAGER::FlushAndRelease( JSON_SETTINGS* aSettings, bool aSave )
if( aSave ) if( aSave )
( *it )->SaveToFile( GetPathForSettingsFile( it->get() ) ); ( *it )->SaveToFile( GetPathForSettingsFile( it->get() ) );
JSON_SETTINGS* tmp = it->get(); // We use a temporary to surpress a Clang warning JSON_SETTINGS* tmp = it->get(); // We use a temporary to suppress a Clang warning
size_t typeHash = typeid( *tmp ).hash_code(); size_t typeHash = typeid( *tmp ).hash_code();
if( m_app_settings_cache.count( typeHash ) ) if( m_app_settings_cache.count( typeHash ) )
@ -903,8 +903,8 @@ bool SETTINGS_MANAGER::LoadProject( const wxString& aFullPath, bool aSetActive )
wxString fullPath = path.GetFullPath(); wxString fullPath = path.GetFullPath();
// If already loaded, we are all set. This might be called more than once over a project's // If already loaded, we are all set. This might be called more than once over a project's
// lifetime in case the project is first loaded by the KiCad manager and then eeschema or // lifetime in case the project is first loaded by the KiCad manager and then Eeschema or
// pcbnew try to load it again when they are launched. // Pcbnew try to load it again when they are launched.
if( m_projects.count( fullPath ) ) if( m_projects.count( fullPath ) )
return true; return true;
@ -1044,7 +1044,8 @@ bool SETTINGS_MANAGER::IsProjectOpen() const
bool SETTINGS_MANAGER::IsProjectOpenNotDummy() const bool SETTINGS_MANAGER::IsProjectOpenNotDummy() const
{ {
return m_projects.size() > 1 || ( m_projects.size() == 1 && !m_projects.begin()->second->GetProjectFullName().IsEmpty() ); return m_projects.size() > 1 || ( m_projects.size() == 1
&& !m_projects.begin()->second->GetProjectFullName().IsEmpty() );
} }
@ -1119,7 +1120,7 @@ void SETTINGS_MANAGER::SaveProjectAs( const wxString& aFullPath, PROJECT* aProje
PROJECT_FILE* project = m_project_files.at( oldName ); PROJECT_FILE* project = m_project_files.at( oldName );
// Ensure read-only flags are copied; this allows doing a "Save As" on a standalong board/sch // Ensure read-only flags are copied; this allows doing a "Save As" on a standalone board/sch
// without creating project files if the checkbox is turned off // without creating project files if the checkbox is turned off
project->SetReadOnly( aProject->IsReadOnly() ); project->SetReadOnly( aProject->IsReadOnly() );
aProject->GetLocalSettings().SetReadOnly( aProject->IsReadOnly() ); aProject->GetLocalSettings().SetReadOnly( aProject->IsReadOnly() );
@ -1254,7 +1255,8 @@ bool SETTINGS_MANAGER::BackupProject( REPORTER& aReporter, wxFileName& aTarget )
if( !aTarget.IsDirWritable() ) if( !aTarget.IsDirWritable() )
{ {
wxLogTrace( traceSettings, wxT( "Backup directory %s is not writable" ), aTarget.GetPath() ); wxLogTrace( traceSettings, wxT( "Backup directory %s is not writable" ),
aTarget.GetPath() );
return false; return false;
} }

View File

@ -71,8 +71,7 @@ KIWAY Kiway( KFCTL_STANDALONE );
// implement a PGM_BASE and a wxApp side by side: // implement a PGM_BASE and a wxApp side by side:
/** /**
* Struct PGM_SINGLE_TOP * Implement PGM_BASE with its own OnPgmInit() and OnPgmExit().
* implements PGM_BASE with its own OnPgmInit() and OnPgmExit().
*/ */
static struct PGM_SINGLE_TOP : public PGM_BASE static struct PGM_SINGLE_TOP : public PGM_BASE
{ {
@ -124,6 +123,7 @@ static struct PGM_SINGLE_TOP : public PGM_BASE
} program; } program;
// A module to allow Html module initialization/cleanup // A module to allow Html module initialization/cleanup
// When a wxHtmlWindow is used *only* in a dll/so module, the Html text is displayed // When a wxHtmlWindow is used *only* in a dll/so module, the Html text is displayed
// as plain text. // as plain text.
@ -135,11 +135,14 @@ public:
HtmlModule() { } HtmlModule() { }
virtual bool OnInit() override { AddDependency( CLASSINFO( wxHtmlWinParser ) ); return true; }; virtual bool OnInit() override { AddDependency( CLASSINFO( wxHtmlWinParser ) ); return true; };
virtual void OnExit() override {}; virtual void OnExit() override {};
private: private:
wxDECLARE_DYNAMIC_CLASS( HtmlModule ); wxDECLARE_DYNAMIC_CLASS( HtmlModule );
}; };
wxIMPLEMENT_DYNAMIC_CLASS(HtmlModule, wxModule); wxIMPLEMENT_DYNAMIC_CLASS(HtmlModule, wxModule);
#ifdef NDEBUG #ifdef NDEBUG
// Define a custom assertion handler // Define a custom assertion handler
void CustomAssertHandler( const wxString& file, void CustomAssertHandler( const wxString& file,
@ -152,9 +155,9 @@ void CustomAssertHandler(const wxString& file,
} }
#endif #endif
/** /**
* Struct APP_SINGLE_TOP * Implement a bare naked wxApp (so that we don't become dependent on
* implements a bare naked wxApp (so that we don't become dependent on
* functionality in a wxApp derivative that we cannot deliver under wxPython). * functionality in a wxApp derivative that we cannot deliver under wxPython).
*/ */
struct APP_SINGLE_TOP : public wxApp struct APP_SINGLE_TOP : public wxApp
@ -162,6 +165,7 @@ struct APP_SINGLE_TOP : public wxApp
APP_SINGLE_TOP() : wxApp() APP_SINGLE_TOP() : wxApp()
{ {
SetPgm( &program ); SetPgm( &program );
// Init the environment each platform wants // Init the environment each platform wants
KIPLATFORM::ENV::Init(); KIPLATFORM::ENV::Init();
} }
@ -254,7 +258,8 @@ struct APP_SINGLE_TOP : public wxApp
if( dlgs.back() == dialog ) if( dlgs.back() == dialog )
dlgs.pop_back(); dlgs.pop_back();
// If an out-of-order, remove all dialogs added after the closed one // If an out-of-order, remove all dialogs added after the closed one
else if( auto it = std::find( dlgs.begin(), dlgs.end(), dialog ) ; it != dlgs.end() ) else if( auto it = std::find( dlgs.begin(), dlgs.end(), dialog );
it != dlgs.end() )
dlgs.erase( it, dlgs.end() ); dlgs.erase( it, dlgs.end() );
} }
} }
@ -289,9 +294,10 @@ struct APP_SINGLE_TOP : public wxApp
#ifdef __WXMAC__ #ifdef __WXMAC__
/** /**
* Function MacOpenFile * Specific to MacOSX (not used under Linux or Windows).
* is specific to MacOSX (not used under Linux or Windows). *
* MacOSX requires it for file association. * MacOSX requires it for file association.
*
* @see http://wiki.wxwidgets.org/WxMac-specific_topics * @see http://wiki.wxwidgets.org/WxMac-specific_topics
*/ */
void MacOpenFile( const wxString& aFileName ) override void MacOpenFile( const wxString& aFileName ) override
@ -320,9 +326,10 @@ bool PGM_SINGLE_TOP::OnPgmInit()
// Initialize the git library before trying to initialize individual programs // Initialize the git library before trying to initialize individual programs
git_libgit2_init(); git_libgit2_init();
// Not all kicad applications use the python stuff. skip python init // Not all KiCad applications use the python stuff. skip python init
// for these apps. // for these apps.
bool skip_python_initialization = false; bool skip_python_initialization = false;
#if defined( BITMAP_2_CMP ) || defined( PL_EDITOR ) || defined( GERBVIEW ) || \ #if defined( BITMAP_2_CMP ) || defined( PL_EDITOR ) || defined( GERBVIEW ) || \
defined( PCB_CALCULATOR_BUILD ) defined( PCB_CALCULATOR_BUILD )
skip_python_initialization = true; skip_python_initialization = true;
@ -403,6 +410,7 @@ bool PGM_SINGLE_TOP::OnPgmInit()
wxCmdLineParser parser( App().argc, App().argv ); wxCmdLineParser parser( App().argc, App().argv );
parser.SetDesc( desc ); parser.SetDesc( desc );
parser.Parse( false ); parser.Parse( false );
if( parser.GetParamCount() ) if( parser.GetParamCount() )
{ {
/* /*

View File

@ -471,7 +471,6 @@ int ReadDelimitedText( char* aDest, const char* aSource, int aDestSize )
inside = true; // first delimiter found, make note, do not copy inside = true; // first delimiter found, make note, do not copy
} }
else if( inside ) else if( inside )
{ {
if( cc == '\\' ) if( cc == '\\' )
@ -664,10 +663,6 @@ bool NoPrintableChars( const wxString& aString )
} }
/**
* Return the number of printable (ie: non-formatting) chars. Used to approximate rendered
* text size when speed is more important than accuracy.
*/
int PrintableCharCount( const wxString& aString ) int PrintableCharCount( const wxString& aString )
{ {
int char_count = 0; int char_count = 0;
@ -997,7 +992,7 @@ bool ApplyModifier( double& value, const wxString& aString )
bool convertSeparators( wxString* value ) bool convertSeparators( wxString* value )
{ {
// Note: fetching the decimal separtor from the current locale isn't a silver bullet because // Note: fetching the decimal separator from the current locale isn't a silver bullet because
// it assumes the current computer's locale is the same as the locale the schematic was // it assumes the current computer's locale is the same as the locale the schematic was
// authored in -- something that isn't true, for instance, when sharing designs through // authored in -- something that isn't true, for instance, when sharing designs through
// DIYAudio.com. // DIYAudio.com.
@ -1072,7 +1067,7 @@ bool convertSeparators( wxString* value )
{ {
// This is the first separator... // This is the first separator...
// If it's preceeded by a '0' (only), or if it's followed by some number of // If it's preceded by a '0' (only), or if it's followed by some number of
// digits not equal to 3, then it -must- be a decimal separator. // digits not equal to 3, then it -must- be a decimal separator.
// //
// In all other cases we don't really know what it is yet. // In all other cases we don't really know what it is yet.
@ -1097,7 +1092,7 @@ bool convertSeparators( wxString* value )
} }
} }
// If we found nothing difinitive then we have to look at the current locale // If we found nothing definitive then we have to look at the current locale
if( decimalSeparator == '?' && thousandsSeparator == '?' ) if( decimalSeparator == '?' && thousandsSeparator == '?' )
{ {
const struct lconv* lc = localeconv(); const struct lconv* lc = localeconv();

View File

@ -47,7 +47,8 @@ const std::map<LINE_STYLE, struct LINE_STYLE_DESC> lineTypeNames = {
void STROKE_PARAMS::Stroke( const SHAPE* aShape, LINE_STYLE aLineStyle, int aWidth, void STROKE_PARAMS::Stroke( const SHAPE* aShape, LINE_STYLE aLineStyle, int aWidth,
const KIGFX::RENDER_SETTINGS* aRenderSettings, const KIGFX::RENDER_SETTINGS* aRenderSettings,
const std::function<void( const VECTOR2I& a, const VECTOR2I& b )>& aStroker ) const std::function<void( const VECTOR2I& a,
const VECTOR2I& b )>& aStroker )
{ {
double strokes[6] = { aWidth * 1.0, aWidth * 1.0, aWidth * 1.0, aWidth * 1.0, aWidth * 1.0, double strokes[6] = { aWidth * 1.0, aWidth * 1.0, aWidth * 1.0, aWidth * 1.0, aWidth * 1.0,
aWidth * 1.0 }; aWidth * 1.0 };

View File

@ -196,7 +196,7 @@ void TEMPLATES::parse( TEMPLATE_FIELDNAMES_LEXER* in, bool aGlobal )
} }
/* /**
* Flatten project and global templates into a single list. (Project templates take * Flatten project and global templates into a single list. (Project templates take
* precedence.) * precedence.)
*/ */

View File

@ -27,6 +27,7 @@
#include <title_block.h> #include <title_block.h>
#include <core/kicad_algo.h> #include <core/kicad_algo.h>
void TITLE_BLOCK::Format( OUTPUTFORMATTER* aFormatter ) const void TITLE_BLOCK::Format( OUTPUTFORMATTER* aFormatter ) const
{ {
// Don't write the title block information if there is nothing to write. // Don't write the title block information if there is nothing to write.
@ -70,6 +71,7 @@ void TITLE_BLOCK::Format( OUTPUTFORMATTER* aFormatter ) const
} }
} }
void TITLE_BLOCK::GetContextualTextVars( wxArrayString* aVars ) void TITLE_BLOCK::GetContextualTextVars( wxArrayString* aVars )
{ {
if( !alg::contains( *aVars, wxT( "ISSUE_DATE" ) ) ) if( !alg::contains( *aVars, wxT( "ISSUE_DATE" ) ) )

View File

@ -33,6 +33,7 @@
#include <hotkeys_basic.h> #include <hotkeys_basic.h>
#include <cctype> #include <cctype>
ACTION_MANAGER::ACTION_MANAGER( TOOL_MANAGER* aToolManager ) : ACTION_MANAGER::ACTION_MANAGER( TOOL_MANAGER* aToolManager ) :
m_toolMgr( aToolManager ) m_toolMgr( aToolManager )
{ {
@ -56,7 +57,8 @@ ACTION_MANAGER::ACTION_MANAGER( TOOL_MANAGER* aToolManager ) :
} }
wxLogTrace( kicadTraceToolStack, wxLogTrace( kicadTraceToolStack,
"ACTION_MANAGER::ACTION_MANAGER: Registering action %s with ID %d, UI ID %d, and group %s(%d)", "ACTION_MANAGER::ACTION_MANAGER: Registering action %s with ID %d, UI ID %d, "
"and group %s(%d)",
action->m_name, action->m_id, action->GetUIId(), groupName, groupID ); action->m_name, action->m_id, action->GetUIId(), groupName, groupID );
RegisterAction( action ); RegisterAction( action );

View File

@ -108,6 +108,7 @@ void ACTION_MENU::DisplayTitle( bool aDisplay )
wxMenuItem* item = FindItemByPosition( 0 ); wxMenuItem* item = FindItemByPosition( 0 );
wxASSERT( item->GetItemLabelText() == GetTitle() ); wxASSERT( item->GetItemLabelText() == GetTitle() );
Destroy( item ); Destroy( item );
// ..and separator // ..and separator
item = FindItemByPosition( 0 ); item = FindItemByPosition( 0 );
wxASSERT( item->IsSeparator() ); wxASSERT( item->IsSeparator() );
@ -168,7 +169,7 @@ wxMenuItem* ACTION_MENU::Add( const wxString& aLabel, const wxString& aTooltip,
wxMenuItem* ACTION_MENU::Add( const TOOL_ACTION& aAction, bool aIsCheckmarkEntry, wxMenuItem* ACTION_MENU::Add( const TOOL_ACTION& aAction, bool aIsCheckmarkEntry,
const wxString& aOverrideLabel ) const wxString& aOverrideLabel )
{ {
/// ID numbers for tool actions are assigned above ACTION_BASE_UI_ID inside TOOL_EVENT // ID numbers for tool actions are assigned above ACTION_BASE_UI_ID inside TOOL_EVENT
BITMAPS icon = aAction.GetIcon(); BITMAPS icon = aAction.GetIcon();
// Allow the label to be overridden at point of use // Allow the label to be overridden at point of use
@ -190,7 +191,8 @@ wxMenuItem* ACTION_MENU::Add( ACTION_MENU* aMenu )
{ {
m_submenus.push_back( aMenu ); m_submenus.push_back( aMenu );
wxASSERT_MSG( !aMenu->m_title.IsEmpty(), wxS( "Set a title for ACTION_MENU using SetTitle()" ) ); wxASSERT_MSG( !aMenu->m_title.IsEmpty(),
wxS( "Set a title for ACTION_MENU using SetTitle()" ) );
if( !!aMenu->m_icon ) if( !!aMenu->m_icon )
{ {
@ -653,9 +655,10 @@ wxMenuItem* ACTION_MENU::appendCopy( const wxMenuItem* aSource )
// On Windows, for Checkable Menu items, adding a bitmap adds also // On Windows, for Checkable Menu items, adding a bitmap adds also
// our predefined checked alternate bitmap // our predefined checked alternate bitmap
// On other OS, wxITEM_CHECK and wxITEM_RADIO Menu items do not use custom bitmaps. // On other OS, wxITEM_CHECK and wxITEM_RADIO Menu items do not use custom bitmaps.
#if defined( __WXMSW__ ) #if defined( __WXMSW__ )
// On Windows, AddBitmapToMenuItem() uses the unchecked bitmap for wxITEM_CHECK and // On Windows, AddBitmapToMenuItem() uses the unchecked bitmap for wxITEM_CHECK and
// wxITEM_RADIO menuitems and autoamtically adds a checked bitmap. // wxITEM_RADIO menuitems and automatically adds a checked bitmap.
// For other menuitrms, use the "checked" bitmap. // For other menuitrms, use the "checked" bitmap.
bool use_checked_bm = ( aSource->GetKind() == wxITEM_CHECK || bool use_checked_bm = ( aSource->GetKind() == wxITEM_CHECK ||
aSource->GetKind() == wxITEM_RADIO ) ? false : true; aSource->GetKind() == wxITEM_RADIO ) ? false : true;

View File

@ -241,7 +241,8 @@ ACTION_TOOLBAR::~ACTION_TOOLBAR()
void ACTION_TOOLBAR::Add( const TOOL_ACTION& aAction, bool aIsToggleEntry, bool aIsCancellable ) void ACTION_TOOLBAR::Add( const TOOL_ACTION& aAction, bool aIsToggleEntry, bool aIsCancellable )
{ {
wxASSERT( GetParent() ); wxASSERT( GetParent() );
wxASSERT_MSG( !( aIsCancellable && !aIsToggleEntry ), wxS( "aIsCancellable requires aIsToggleEntry" ) ); wxASSERT_MSG( !( aIsCancellable && !aIsToggleEntry ),
wxS( "aIsCancellable requires aIsToggleEntry" ) );
int toolId = aAction.GetUIId(); int toolId = aAction.GetUIId();
@ -371,7 +372,8 @@ void ACTION_TOOLBAR::UpdateControlWidth( int aID )
// The control on the toolbar is stored inside the window field of the item // The control on the toolbar is stored inside the window field of the item
wxControl* control = dynamic_cast<wxControl*>( item->GetWindow() ); wxControl* control = dynamic_cast<wxControl*>( item->GetWindow() );
wxASSERT_MSG( control, wxString::Format( "No control located in toolbar item with ID %d", aID ) ); wxASSERT_MSG( control,
wxString::Format( "No control located in toolbar item with ID %d", aID ) );
// Update the size the item has stored using the best size of the control // Update the size the item has stored using the best size of the control
control->InvalidateBestSize(); control->InvalidateBestSize();
@ -526,6 +528,7 @@ void ACTION_TOOLBAR::onToolRightClick( wxAuiToolBarEvent& aEvent )
SetHoverItem( nullptr ); SetHoverItem( nullptr );
} }
// The time (in milliseconds) between pressing the left mouse button and opening the palette // The time (in milliseconds) between pressing the left mouse button and opening the palette
#define PALETTE_OPEN_DELAY 500 #define PALETTE_OPEN_DELAY 500

View File

@ -1263,24 +1263,31 @@ TOOL_ACTION ACTIONS::extractFile( TOOL_ACTION_ARGS()
// System-wide selection Events // System-wide selection Events
const TOOL_EVENT EVENTS::PointSelectedEvent( TC_MESSAGE, TA_ACTION, "common.Interactive.pointSelected" ); const TOOL_EVENT EVENTS::PointSelectedEvent( TC_MESSAGE, TA_ACTION,
"common.Interactive.pointSelected" );
const TOOL_EVENT EVENTS::SelectedEvent( TC_MESSAGE, TA_ACTION, "common.Interactive.selected" ); const TOOL_EVENT EVENTS::SelectedEvent( TC_MESSAGE, TA_ACTION, "common.Interactive.selected" );
const TOOL_EVENT EVENTS::UnselectedEvent( TC_MESSAGE, TA_ACTION, "common.Interactive.unselected" ); const TOOL_EVENT EVENTS::UnselectedEvent( TC_MESSAGE, TA_ACTION, "common.Interactive.unselected" );
const TOOL_EVENT EVENTS::ClearedEvent( TC_MESSAGE, TA_ACTION, "common.Interactive.cleared" ); const TOOL_EVENT EVENTS::ClearedEvent( TC_MESSAGE, TA_ACTION, "common.Interactive.cleared" );
const TOOL_EVENT EVENTS::ConnectivityChangedEvent( TC_MESSAGE, TA_ACTION, "common.Interactive.connectivityChanged" ); const TOOL_EVENT EVENTS::ConnectivityChangedEvent( TC_MESSAGE, TA_ACTION,
"common.Interactive.connectivityChanged" );
const TOOL_EVENT EVENTS::SelectedItemsModified( TC_MESSAGE, TA_ACTION, "common.Interactive.modified" ); const TOOL_EVENT EVENTS::SelectedItemsModified( TC_MESSAGE, TA_ACTION,
"common.Interactive.modified" );
const TOOL_EVENT EVENTS::SelectedItemsMoved( TC_MESSAGE, TA_ACTION, "common.Interactive.moved" ); const TOOL_EVENT EVENTS::SelectedItemsMoved( TC_MESSAGE, TA_ACTION, "common.Interactive.moved" );
const TOOL_EVENT EVENTS::InhibitSelectionEditing( TC_MESSAGE, TA_ACTION, "common.Interactive.inhibit" ); const TOOL_EVENT EVENTS::InhibitSelectionEditing( TC_MESSAGE, TA_ACTION,
const TOOL_EVENT EVENTS::UninhibitSelectionEditing( TC_MESSAGE, TA_ACTION, "common.Interactive.uninhibit" ); "common.Interactive.inhibit" );
const TOOL_EVENT EVENTS::UninhibitSelectionEditing( TC_MESSAGE, TA_ACTION,
"common.Interactive.uninhibit" );
const TOOL_EVENT EVENTS::DisambiguatePoint( TC_MESSAGE, TA_ACTION, "common.Interactive.disambiguate" ); const TOOL_EVENT EVENTS::DisambiguatePoint( TC_MESSAGE, TA_ACTION,
"common.Interactive.disambiguate" );
const TOOL_EVENT EVENTS::GridChangedByKeyEvent( TC_MESSAGE, TA_ACTION, const TOOL_EVENT EVENTS::GridChangedByKeyEvent( TC_MESSAGE, TA_ACTION,
"common.Interactive.gridChangedByKey" ); "common.Interactive.gridChangedByKey" );
const TOOL_EVENT EVENTS::ContrastModeChangedByKeyEvent( TC_MESSAGE, TA_ACTION, const TOOL_EVENT
EVENTS::ContrastModeChangedByKeyEvent( TC_MESSAGE, TA_ACTION,
"common.Interactive.contrastModeChangedByKeyEvent" ); "common.Interactive.contrastModeChangedByKeyEvent" );
// System-wide undo/redo Events // System-wide undo/redo Events

View File

@ -50,7 +50,8 @@
/// URL to launch a new issue with pre-populated description /// URL to launch a new issue with pre-populated description
wxString COMMON_CONTROL::m_bugReportUrl = wxString COMMON_CONTROL::m_bugReportUrl =
wxS( "https://gitlab.com/kicad/code/kicad/-/issues/new?issuable_template=bare&issue[description]=%s" ); wxS( "https://gitlab.com/kicad/code/kicad/-/issues/new?issuable_template=bare&issue"
"[description]=%s" );
/// Issue template to use for reporting bugs (this should not be translated) /// Issue template to use for reporting bugs (this should not be translated)
@ -136,7 +137,8 @@ int COMMON_CONTROL::ShowLibraryTable( const TOOL_EVENT& aEvent )
try // Kicad frame was not available, try to start it try // Kicad frame was not available, try to start it
{ {
if( KIFACE* kiface = m_frame->Kiway().KiFACE( KIWAY::FACE_SCH ) ) if( KIFACE* kiface = m_frame->Kiway().KiFACE( KIWAY::FACE_SCH ) )
kiface->CreateKiWindow( m_frame, DIALOG_DESIGN_BLOCK_LIBRARY_TABLE, &m_frame->Kiway() ); kiface->CreateKiWindow( m_frame, DIALOG_DESIGN_BLOCK_LIBRARY_TABLE,
&m_frame->Kiway() );
} }
catch( ... ) catch( ... )
{ {

View File

@ -55,6 +55,7 @@ COMMON_TOOLS::COMMON_TOOLS() :
{ {
} }
void COMMON_TOOLS::Reset( RESET_REASON aReason ) void COMMON_TOOLS::Reset( RESET_REASON aReason )
{ {
m_frame = getEditFrame<EDA_DRAW_FRAME>(); m_frame = getEditFrame<EDA_DRAW_FRAME>();
@ -102,7 +103,6 @@ int COMMON_TOOLS::SelectionTool( const TOOL_EVENT& aEvent )
} }
// Cursor control
int COMMON_TOOLS::CursorControl( const TOOL_EVENT& aEvent ) int COMMON_TOOLS::CursorControl( const TOOL_EVENT& aEvent )
{ {
ACTIONS::CURSOR_EVENT_TYPE type = aEvent.Parameter<ACTIONS::CURSOR_EVENT_TYPE>(); ACTIONS::CURSOR_EVENT_TYPE type = aEvent.Parameter<ACTIONS::CURSOR_EVENT_TYPE>();
@ -405,6 +405,7 @@ int COMMON_TOOLS::CenterSelection( const TOOL_EVENT& aEvent )
return doCenter( CENTER_TYPE::CENTER_SELECTION ); return doCenter( CENTER_TYPE::CENTER_SELECTION );
} }
int COMMON_TOOLS::CenterContents( const TOOL_EVENT& aEvent ) int COMMON_TOOLS::CenterContents( const TOOL_EVENT& aEvent )
{ {
return doCenter( CENTER_TYPE::CENTER_CONTENTS ); return doCenter( CENTER_TYPE::CENTER_CONTENTS );
@ -489,7 +490,6 @@ int COMMON_TOOLS::doZoomToPreset( int idx, bool aCenterOnCursor )
} }
// Grid control
int COMMON_TOOLS::GridNext( const TOOL_EVENT& aEvent ) int COMMON_TOOLS::GridNext( const TOOL_EVENT& aEvent )
{ {
int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx; int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;

View File

@ -231,9 +231,11 @@ CONDITIONAL_MENU::ENTRY::ENTRY( const ENTRY& aEntry )
case ACTION: case ACTION:
m_data.action = aEntry.m_data.action; m_data.action = aEntry.m_data.action;
break; break;
case MENU: case MENU:
m_data.menu = aEntry.m_data.menu; m_data.menu = aEntry.m_data.menu;
break; break;
case WXITEM: case WXITEM:
// We own the wxItem, so we need to make a new one for the new object // We own the wxItem, so we need to make a new one for the new object
m_data.wxItem = new wxMenuItem( nullptr, m_data.wxItem = new wxMenuItem( nullptr,
@ -242,14 +244,17 @@ CONDITIONAL_MENU::ENTRY::ENTRY( const ENTRY& aEntry )
aEntry.m_data.wxItem->GetHelp(), aEntry.m_data.wxItem->GetHelp(),
aEntry.m_data.wxItem->GetKind() ); aEntry.m_data.wxItem->GetKind() );
break; break;
case SEPARATOR: case SEPARATOR:
break; //No data to copy break; //No data to copy
} }
m_condition = aEntry.m_condition; m_condition = aEntry.m_condition;
m_order = aEntry.m_order; m_order = aEntry.m_order;
m_isCheckmarkEntry = aEntry.m_isCheckmarkEntry; m_isCheckmarkEntry = aEntry.m_isCheckmarkEntry;
} }
CONDITIONAL_MENU::ENTRY::~ENTRY() CONDITIONAL_MENU::ENTRY::~ENTRY()
{ {
if( WXITEM == m_type ) if( WXITEM == m_type )

View File

@ -34,7 +34,7 @@
* A helper class to manage the activation of a "proposal" after a timeout. * A helper class to manage the activation of a "proposal" after a timeout.
* *
* When a proposal is made, a timer starts. If no new proposal is made and the proposal * When a proposal is made, a timer starts. If no new proposal is made and the proposal
* is not cancelled before the timer expires, the proposal is "accepted" via a callback. * is not canceled before the timer expires, the proposal is "accepted" via a callback.
* *
* Propos * Propos
* *
@ -102,6 +102,7 @@ public:
while( !m_stop ) while( !m_stop )
{ {
std::unique_lock<std::mutex> lock( m_mutex ); std::unique_lock<std::mutex> lock( m_mutex );
if( !m_stop && !m_pendingProposalTag.has_value() ) if( !m_stop && !m_pendingProposalTag.has_value() )
{ {
// No active proposal - wait for one (unlocks while waiting) // No active proposal - wait for one (unlocks while waiting)
@ -117,6 +118,7 @@ public:
{ {
// See if the timeout was extended for a new proposal // See if the timeout was extended for a new proposal
now = std::chrono::steady_clock::now(); now = std::chrono::steady_clock::now();
if( now < m_proposalDeadline ) if( now < m_proposalDeadline )
{ {
// Extended - wait for the new deadline // Extended - wait for the new deadline
@ -124,7 +126,7 @@ public:
} }
// See if there is still a proposal to accept // See if there is still a proposal to accept
// (could have been cancelled in the meantime) // (could have been canceled in the meantime)
if( m_pendingProposalTag ) if( m_pendingProposalTag )
{ {
m_lastAcceptedProposalTag = m_pendingProposalTag; m_lastAcceptedProposalTag = m_pendingProposalTag;
@ -132,6 +134,7 @@ public:
T proposalToAccept = std::move( m_lastProposal ); T proposalToAccept = std::move( m_lastProposal );
lock.unlock(); lock.unlock();
// Call the callback (outside the lock) // Call the callback (outside the lock)
m_callback( std::move( proposalToAccept ) ); m_callback( std::move( proposalToAccept ) );
} }
@ -143,25 +146,26 @@ public:
private: private:
mutable std::mutex m_mutex; mutable std::mutex m_mutex;
// Activation timeout in milliseconds /// Activation timeout in milliseconds.
std::chrono::milliseconds m_timeout; std::chrono::milliseconds m_timeout;
std::chrono::time_point<std::chrono::steady_clock> m_proposalDeadline; std::chrono::time_point<std::chrono::steady_clock> m_proposalDeadline;
///< The last proposal tag that was made /// The last proposal tag that was made.
std::optional<std::size_t> m_pendingProposalTag; std::optional<std::size_t> m_pendingProposalTag;
///< The last proposal that was accepted /// The last proposal that was accepted.
std::optional<std::size_t> m_lastAcceptedProposalTag; std::optional<std::size_t> m_lastAcceptedProposalTag;
// The most recently-proposed item /// The most recently-proposed item.
T m_lastProposal; T m_lastProposal;
///< Callback to call when the proposal is accepted /// Callback to call when the proposal is accepted.
ACTIVATION_CALLBACK m_callback; ACTIVATION_CALLBACK m_callback;
std::condition_variable m_cv; std::condition_variable m_cv;
std::atomic<bool> m_stop; std::atomic<bool> m_stop;
// The thread must be constructed last, as it starts running immediately
/// The thread must be constructed last, as it starts running immediately.
std::thread m_thread; std::thread m_thread;
}; };
@ -329,6 +333,7 @@ void CONSTRUCTION_MANAGER::acceptConstructionItems( std::unique_ptr<PENDING_BATC
m_viewHandler.updateView(); m_viewHandler.updateView();
} }
bool CONSTRUCTION_MANAGER::InvolvesAllGivenRealItems( const std::vector<EDA_ITEM*>& aItems ) const bool CONSTRUCTION_MANAGER::InvolvesAllGivenRealItems( const std::vector<EDA_ITEM*>& aItems ) const
{ {
for( EDA_ITEM* item : aItems ) for( EDA_ITEM* item : aItems )
@ -343,6 +348,7 @@ bool CONSTRUCTION_MANAGER::InvolvesAllGivenRealItems( const std::vector<EDA_ITEM
return true; return true;
} }
void CONSTRUCTION_MANAGER::GetConstructionItems( void CONSTRUCTION_MANAGER::GetConstructionItems(
std::vector<CONSTRUCTION_ITEM_BATCH>& aToExtend ) const std::vector<CONSTRUCTION_ITEM_BATCH>& aToExtend ) const
{ {
@ -358,17 +364,20 @@ void CONSTRUCTION_MANAGER::GetConstructionItems(
} }
} }
bool CONSTRUCTION_MANAGER::HasActiveConstruction() const bool CONSTRUCTION_MANAGER::HasActiveConstruction() const
{ {
std::lock_guard<std::mutex> lock( m_batchesMutex ); std::lock_guard<std::mutex> lock( m_batchesMutex );
return m_persistentConstructionBatch.has_value() || !m_temporaryConstructionBatches.empty(); return m_persistentConstructionBatch.has_value() || !m_temporaryConstructionBatches.empty();
} }
SNAP_LINE_MANAGER::SNAP_LINE_MANAGER( CONSTRUCTION_VIEW_HANDLER& aViewHandler ) : SNAP_LINE_MANAGER::SNAP_LINE_MANAGER( CONSTRUCTION_VIEW_HANDLER& aViewHandler ) :
m_viewHandler( aViewHandler ) m_viewHandler( aViewHandler )
{ {
} }
void SNAP_LINE_MANAGER::SetSnapLineOrigin( const VECTOR2I& aOrigin ) void SNAP_LINE_MANAGER::SetSnapLineOrigin( const VECTOR2I& aOrigin )
{ {
// Setting the origin clears the snap line as the end point is no longer valid // Setting the origin clears the snap line as the end point is no longer valid
@ -376,6 +385,7 @@ void SNAP_LINE_MANAGER::SetSnapLineOrigin( const VECTOR2I& aOrigin )
m_snapLineOrigin = aOrigin; m_snapLineOrigin = aOrigin;
} }
void SNAP_LINE_MANAGER::SetSnapLineEnd( const OPT_VECTOR2I& aSnapEnd ) void SNAP_LINE_MANAGER::SetSnapLineEnd( const OPT_VECTOR2I& aSnapEnd )
{ {
if( m_snapLineOrigin && aSnapEnd != m_snapLineEnd ) if( m_snapLineOrigin && aSnapEnd != m_snapLineEnd )
@ -391,6 +401,7 @@ void SNAP_LINE_MANAGER::SetSnapLineEnd( const OPT_VECTOR2I& aSnapEnd )
} }
} }
void SNAP_LINE_MANAGER::ClearSnapLine() void SNAP_LINE_MANAGER::ClearSnapLine()
{ {
m_snapLineOrigin.reset(); m_snapLineOrigin.reset();
@ -399,6 +410,7 @@ void SNAP_LINE_MANAGER::ClearSnapLine()
m_viewHandler.updateView(); m_viewHandler.updateView();
} }
void SNAP_LINE_MANAGER::SetSnappedAnchor( const VECTOR2I& aAnchorPos ) void SNAP_LINE_MANAGER::SetSnappedAnchor( const VECTOR2I& aAnchorPos )
{ {
if( m_snapLineOrigin.has_value() ) if( m_snapLineOrigin.has_value() )
@ -440,6 +452,7 @@ static bool pointHasEscapedSnapLineX( const VECTOR2I& aCursor, const VECTOR2I& a
return std::abs( angle.Normalize90() ) > aLongRangeEscapeAngle; return std::abs( angle.Normalize90() ) > aLongRangeEscapeAngle;
} }
/** /**
* As above, but for the Y direction. * As above, but for the Y direction.
*/ */

View File

@ -56,6 +56,7 @@ void EMBED_TOOL::Reset( RESET_REASON aReason )
m_files = getModel<EDA_ITEM>()->GetEmbeddedFiles(); m_files = getModel<EDA_ITEM>()->GetEmbeddedFiles();
} }
int EMBED_TOOL::AddFile( const TOOL_EVENT& aEvent ) int EMBED_TOOL::AddFile( const TOOL_EVENT& aEvent )
{ {
wxString name = aEvent.Parameter<wxString>(); wxString name = aEvent.Parameter<wxString>();
@ -64,6 +65,7 @@ int EMBED_TOOL::AddFile( const TOOL_EVENT& aEvent )
return 1; return 1;
} }
int EMBED_TOOL::RemoveFile( const TOOL_EVENT& aEvent ) int EMBED_TOOL::RemoveFile( const TOOL_EVENT& aEvent )
{ {
wxString name = aEvent.Parameter<wxString>(); wxString name = aEvent.Parameter<wxString>();
@ -72,6 +74,7 @@ int EMBED_TOOL::RemoveFile( const TOOL_EVENT& aEvent )
return 1; return 1;
} }
std::vector<wxString> EMBED_TOOL::GetFileList() std::vector<wxString> EMBED_TOOL::GetFileList()
{ {
std::vector<wxString> list; std::vector<wxString> list;
@ -84,6 +87,7 @@ std::vector<wxString> EMBED_TOOL::GetFileList()
return list; return list;
} }
void EMBED_TOOL::setTransitions() void EMBED_TOOL::setTransitions()
{ {
Go( &EMBED_TOOL::AddFile, ACTIONS::embeddedFiles.MakeEvent() ); Go( &EMBED_TOOL::AddFile, ACTIONS::embeddedFiles.MakeEvent() );

View File

@ -85,6 +85,7 @@ GRID_HELPER::~GRID_HELPER()
KIGFX::ANCHOR_DEBUG* GRID_HELPER::enableAndGetAnchorDebug() KIGFX::ANCHOR_DEBUG* GRID_HELPER::enableAndGetAnchorDebug()
{ {
static bool permitted = ADVANCED_CFG::GetCfg().m_EnableSnapAnchorsDebug; static bool permitted = ADVANCED_CFG::GetCfg().m_EnableSnapAnchorsDebug;
if( permitted && !m_anchorDebug ) if( permitted && !m_anchorDebug )
{ {
KIGFX::VIEW& view = *m_toolMgr->GetView(); KIGFX::VIEW& view = *m_toolMgr->GetView();
@ -92,6 +93,7 @@ KIGFX::ANCHOR_DEBUG* GRID_HELPER::enableAndGetAnchorDebug()
view.Add( m_anchorDebug.get() ); view.Add( m_anchorDebug.get() );
view.SetVisible( m_anchorDebug.get(), true ); view.SetVisible( m_anchorDebug.get(), true );
} }
return m_anchorDebug.get(); return m_anchorDebug.get();
} }

View File

@ -45,14 +45,17 @@ void LIBRARY_EDITOR_CONTROL::AddContextMenuItems( CONDITIONAL_MENU* aMenu )
{ {
LIB_TREE* libTree = m_frame->GetLibTree(); LIB_TREE* libTree = m_frame->GetLibTree();
LIB_TREE_NODE* current = libTree ? libTree->GetCurrentTreeNode() : nullptr; LIB_TREE_NODE* current = libTree ? libTree->GetCurrentTreeNode() : nullptr;
return current && current->m_Type == LIB_TREE_NODE::TYPE::LIBRARY && current->m_Pinned; return current && current->m_Type == LIB_TREE_NODE::TYPE::LIBRARY
&& current->m_Pinned;
}; };
auto unpinnedLibSelectedCondition = auto unpinnedLibSelectedCondition =
[this](const SELECTION& aSel ) [this](const SELECTION& aSel )
{ {
LIB_TREE* libTree = m_frame->GetLibTree(); LIB_TREE* libTree = m_frame->GetLibTree();
LIB_TREE_NODE* current = libTree ? libTree->GetCurrentTreeNode() : nullptr; LIB_TREE_NODE* current = libTree ? libTree->GetCurrentTreeNode() : nullptr;
return current && current->m_Type == LIB_TREE_NODE::TYPE::LIBRARY && !current->m_Pinned; return current && current->m_Type == LIB_TREE_NODE::TYPE::LIBRARY
&& !current->m_Pinned;
}; };
aMenu->AddItem( ACTIONS::pinLibrary, unpinnedLibSelectedCondition, 1 ); aMenu->AddItem( ACTIONS::pinLibrary, unpinnedLibSelectedCondition, 1 );
@ -89,11 +92,15 @@ int LIBRARY_EDITOR_CONTROL::PinLibrary( const TOOL_EVENT& aEvent )
m_frame->Prj().PinLibrary( current->m_LibId.GetLibNickname(), m_frame->Prj().PinLibrary( current->m_LibId.GetLibNickname(),
PROJECT::LIB_TYPE_T::SYMBOL_LIB ); PROJECT::LIB_TYPE_T::SYMBOL_LIB );
break; break;
case KIWAY::FACE_PCB: case KIWAY::FACE_PCB:
m_frame->Prj().PinLibrary( current->m_LibId.GetLibNickname(), m_frame->Prj().PinLibrary( current->m_LibId.GetLibNickname(),
PROJECT::LIB_TYPE_T::FOOTPRINT_LIB ); PROJECT::LIB_TYPE_T::FOOTPRINT_LIB );
break; break;
default: wxFAIL_MSG( wxT( "Unsupported frame type for library pinning." ) ); break;
default:
wxFAIL_MSG( wxT( "Unsupported frame type for library pinning." ) );
break;
} }
current->m_Pinned = true; current->m_Pinned = true;
@ -117,11 +124,15 @@ int LIBRARY_EDITOR_CONTROL::UnpinLibrary( const TOOL_EVENT& aEvent )
m_frame->Prj().UnpinLibrary( current->m_LibId.GetLibNickname(), m_frame->Prj().UnpinLibrary( current->m_LibId.GetLibNickname(),
PROJECT::LIB_TYPE_T::SYMBOL_LIB ); PROJECT::LIB_TYPE_T::SYMBOL_LIB );
break; break;
case KIWAY::FACE_PCB: case KIWAY::FACE_PCB:
m_frame->Prj().UnpinLibrary( current->m_LibId.GetLibNickname(), m_frame->Prj().UnpinLibrary( current->m_LibId.GetLibNickname(),
PROJECT::LIB_TYPE_T::FOOTPRINT_LIB ); PROJECT::LIB_TYPE_T::FOOTPRINT_LIB );
break; break;
default: wxFAIL_MSG( wxT( "Unsupported frame type for library pinning." ) ); break;
default:
wxFAIL_MSG( wxT( "Unsupported frame type for library pinning." ) );
break;
} }
current->m_Pinned = false; current->m_Pinned = false;

View File

@ -46,7 +46,7 @@ public:
std::function<bool( const wxString& aNewName )> aValidator ); std::function<bool( const wxString& aNewName )> aValidator );
private: private:
///< Set up handlers for various events. /// Set up handlers for various events.
void setTransitions() override; void setTransitions() override;
void regenerateLibraryTree(); void regenerateLibraryTree();

View File

@ -130,7 +130,6 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
break; break;
} }
else if( evt->IsClick( BUT_LEFT ) ) else if( evt->IsClick( BUT_LEFT ) )
{ {
bool getNext = false; bool getNext = false;
@ -156,9 +155,10 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
break; break;
} }
else else
{
setControls(); setControls();
} }
}
else if( evt->IsMotion() ) else if( evt->IsMotion() )
{ {
if( m_motionHandler ) if( m_motionHandler )
@ -172,20 +172,19 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
} }
} }
} }
else if( evt->IsDblClick( BUT_LEFT ) || evt->IsDrag( BUT_LEFT ) ) else if( evt->IsDblClick( BUT_LEFT ) || evt->IsDrag( BUT_LEFT ) )
{ {
// Not currently used, but we don't want to pass them either // Not currently used, but we don't want to pass them either
} }
else if( evt->IsClick( BUT_RIGHT ) ) else if( evt->IsClick( BUT_RIGHT ) )
{ {
m_menu->ShowContextMenu(); m_menu->ShowContextMenu();
} }
else else
{
evt->SetPassEvent(); evt->SetPassEvent();
} }
}
if( m_finalizeHandler ) if( m_finalizeHandler )
{ {

View File

@ -63,7 +63,6 @@ void POLYGON_POINT_EDIT_BEHAVIOR::UpdatePointsFromOutline( const SHAPE_POLY_SET&
EDIT_POINTS& aPoints ) EDIT_POINTS& aPoints )
{ {
// No size check here, as we can and will rebuild if that fails // No size check here, as we can and will rebuild if that fails
if( aPoints.PointsSize() != (unsigned) aOutline.TotalVertices() ) if( aPoints.PointsSize() != (unsigned) aOutline.TotalVertices() )
{ {
// Rebuild the points list // Rebuild the points list
@ -107,6 +106,7 @@ void EDA_SEGMENT_POINT_EDIT_BEHAVIOR::MakePoints( EDIT_POINTS& aPoints )
aPoints.AddPoint( m_segment.GetEnd() ); aPoints.AddPoint( m_segment.GetEnd() );
} }
void EDA_SEGMENT_POINT_EDIT_BEHAVIOR::UpdatePoints( EDIT_POINTS& aPoints ) void EDA_SEGMENT_POINT_EDIT_BEHAVIOR::UpdatePoints( EDIT_POINTS& aPoints )
{ {
CHECK_POINT_COUNT( aPoints, SEGMENT_MAX_POINTS ); CHECK_POINT_COUNT( aPoints, SEGMENT_MAX_POINTS );
@ -115,6 +115,7 @@ void EDA_SEGMENT_POINT_EDIT_BEHAVIOR::UpdatePoints( EDIT_POINTS& aPoints )
aPoints.Point( SEGMENT_END ) = m_segment.GetEnd(); aPoints.Point( SEGMENT_END ) = m_segment.GetEnd();
} }
void EDA_SEGMENT_POINT_EDIT_BEHAVIOR::UpdateItem( const EDIT_POINT& aEditedPoint, void EDA_SEGMENT_POINT_EDIT_BEHAVIOR::UpdateItem( const EDIT_POINT& aEditedPoint,
EDIT_POINTS& aPoints, COMMIT& aCommit, EDIT_POINTS& aPoints, COMMIT& aCommit,
std::vector<EDA_ITEM*>& aUpdatedItems ) std::vector<EDA_ITEM*>& aUpdatedItems )
@ -192,6 +193,7 @@ void EDA_BEZIER_POINT_EDIT_BEHAVIOR::MakePoints( EDIT_POINTS& aPoints )
aPoints.AddIndicatorLine( aPoints.Point( BEZIER_CTRL_PT2 ), aPoints.Point( BEZIER_END ) ); aPoints.AddIndicatorLine( aPoints.Point( BEZIER_CTRL_PT2 ), aPoints.Point( BEZIER_END ) );
} }
void EDA_BEZIER_POINT_EDIT_BEHAVIOR::UpdatePoints( EDIT_POINTS& aPoints ) void EDA_BEZIER_POINT_EDIT_BEHAVIOR::UpdatePoints( EDIT_POINTS& aPoints )
{ {
CHECK_POINT_COUNT( aPoints, BEZIER_MAX_POINTS ); CHECK_POINT_COUNT( aPoints, BEZIER_MAX_POINTS );
@ -202,6 +204,7 @@ void EDA_BEZIER_POINT_EDIT_BEHAVIOR::UpdatePoints( EDIT_POINTS& aPoints )
aPoints.Point( BEZIER_END ).SetPosition( m_bezier.GetEnd() ); aPoints.Point( BEZIER_END ).SetPosition( m_bezier.GetEnd() );
} }
void EDA_BEZIER_POINT_EDIT_BEHAVIOR::UpdateItem( const EDIT_POINT& aEditedPoint, void EDA_BEZIER_POINT_EDIT_BEHAVIOR::UpdateItem( const EDIT_POINT& aEditedPoint,
EDIT_POINTS& aPoints, COMMIT& aCommit, EDIT_POINTS& aPoints, COMMIT& aCommit,
std::vector<EDA_ITEM*>& aUpdatedItems ) std::vector<EDA_ITEM*>& aUpdatedItems )

View File

@ -89,7 +89,6 @@ bool SELECTION::Contains( EDA_ITEM* aItem ) const
} }
/// Returns the center point of the selection area bounding box.
VECTOR2I SELECTION::GetCenter() const VECTOR2I SELECTION::GetCenter() const
{ {
static const std::vector<KICAD_T> textTypes = { SCH_TEXT_T, SCH_LABEL_LOCATE_ANY_T }; static const std::vector<KICAD_T> textTypes = { SCH_TEXT_T, SCH_LABEL_LOCATE_ANY_T };
@ -98,7 +97,6 @@ VECTOR2I SELECTION::GetCenter() const
// If the selection contains only texts calculate the center as the mean of all positions // If the selection contains only texts calculate the center as the mean of all positions
// instead of using the center of the total bounding box. Otherwise rotating the selection will // instead of using the center of the total bounding box. Otherwise rotating the selection will
// also translate it. // also translate it.
for( EDA_ITEM* item : m_items ) for( EDA_ITEM* item : m_items )
{ {
if( !item->IsType( textTypes ) ) if( !item->IsType( textTypes ) )

View File

@ -183,6 +183,7 @@ SELECTION_CONDITION operator||( const SELECTION_CONDITION& aConditionA,
return std::bind( &SELECTION_CONDITIONS::orBoolFunc, aConditionA, std::ref( aConditionB ), _1 ); return std::bind( &SELECTION_CONDITIONS::orBoolFunc, aConditionA, std::ref( aConditionB ), _1 );
} }
SELECTION_CONDITION operator||( SELECTION_BOOL aConditionA, SELECTION_CONDITION operator||( SELECTION_BOOL aConditionA,
const SELECTION_CONDITION& aConditionB ) const SELECTION_CONDITION& aConditionB )
{ {
@ -193,9 +194,11 @@ SELECTION_CONDITION operator||( SELECTION_BOOL aConditionA,
SELECTION_CONDITION operator&&( const SELECTION_CONDITION& aConditionA, SELECTION_CONDITION operator&&( const SELECTION_CONDITION& aConditionA,
SELECTION_BOOL aConditionB ) SELECTION_BOOL aConditionB )
{ {
return std::bind( &SELECTION_CONDITIONS::andBoolFunc, aConditionA, std::ref( aConditionB ), _1 ); return std::bind( &SELECTION_CONDITIONS::andBoolFunc, aConditionA,
std::ref( aConditionB ), _1 );
} }
SELECTION_CONDITION operator&&( SELECTION_BOOL aConditionA, SELECTION_CONDITION operator&&( SELECTION_BOOL aConditionA,
const SELECTION_CONDITION& aConditionB ) const SELECTION_CONDITION& aConditionB )
{ {

View File

@ -28,11 +28,13 @@
#include <eda_draw_frame.h> #include <eda_draw_frame.h>
#include <eda_base_frame.h> #include <eda_base_frame.h>
bool TOOL_BASE::IsToolActive() const bool TOOL_BASE::IsToolActive() const
{ {
return m_toolMgr->IsToolActive( m_toolId ); return m_toolMgr->IsToolActive( m_toolId );
} }
KIGFX::VIEW* TOOL_BASE::getView() const KIGFX::VIEW* TOOL_BASE::getView() const
{ {
return m_toolMgr->GetView(); return m_toolMgr->GetView();

View File

@ -48,7 +48,7 @@
#include <kiplatform/ui.h> #include <kiplatform/ui.h>
///< Stores information about a mouse button state /// Store information about a mouse button state.
struct TOOL_DISPATCHER::BUTTON_STATE struct TOOL_DISPATCHER::BUTTON_STATE
{ {
BUTTON_STATE( TOOL_MOUSE_BUTTONS aButton, const wxEventType& aDownEvent, BUTTON_STATE( TOOL_MOUSE_BUTTONS aButton, const wxEventType& aDownEvent,
@ -61,44 +61,44 @@ struct TOOL_DISPATCHER::BUTTON_STATE
dblClickEvent( aDblClickEvent ) dblClickEvent( aDblClickEvent )
{}; {};
///< Flag indicating that dragging is active for the given button. /// Flag indicating that dragging is active for the given button.
bool dragging; bool dragging;
///< Flag indicating that the given button is pressed. /// Flag indicating that the given button is pressed.
bool pressed; bool pressed;
///< Point where dragging has started (in world coordinates). /// Point where dragging has started (in world coordinates).
VECTOR2D dragOrigin; VECTOR2D dragOrigin;
///< Point where dragging has started (in screen coordinates). /// Point where dragging has started (in screen coordinates).
VECTOR2D dragOriginScreen; VECTOR2D dragOriginScreen;
///< Point where click event has occurred. /// Point where click event has occurred.
VECTOR2D downPosition; VECTOR2D downPosition;
///< Determines the mouse button for which information are stored. /// Determines the mouse button for which information are stored.
TOOL_MOUSE_BUTTONS button; TOOL_MOUSE_BUTTONS button;
///< The type of wxEvent that determines mouse button press. /// The type of wxEvent that determines mouse button press.
wxEventType downEvent; wxEventType downEvent;
///< The type of wxEvent that determines mouse button release. /// The type of wxEvent that determines mouse button release.
wxEventType upEvent; wxEventType upEvent;
///< The type of wxEvent that determines mouse button double click. /// The type of wxEvent that determines mouse button double click.
wxEventType dblClickEvent; wxEventType dblClickEvent;
///< Time stamp for the last mouse button press event. /// Time stamp for the last mouse button press event.
wxLongLong downTimestamp; wxLongLong downTimestamp;
///< Restores initial state. /// Restores initial state.
void Reset() void Reset()
{ {
dragging = false; dragging = false;
pressed = false; pressed = false;
} }
///< Checks the current state of the button. /// Checks the current state of the button.
bool GetState() const bool GetState() const
{ {
wxMouseState mouseState = wxGetMouseState(); wxMouseState mouseState = wxGetMouseState();
@ -267,13 +267,14 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
} }
// Helper function to know if a special key ( see key list ) should be captured /**
// or if the event can be skipped * Helper to know if a special key ( see key list ) should be captured.
// on Linux, the event must be passed to the GUI if they are not used by KiCad, *
// especially the wxEVENT_CHAR_HOOK, if it is not handled * If the event can be skipped on Linux, the event must be passed to the GUI if they are not
// Some keys have a predefined action in wxWidgets so, even if not used, * used by KiCad, especially the wxEVENT_CHAR_HOOK, if it is not handled. Some keys have a
// the even will be not skipped * predefined action in wxWidgets so, even if not used, the even will be not skipped the unused
// the unused keys listed in isKeySpecialCode() will be not skipped * keys listed in isKeySpecialCode() will be not skipped.
*/
bool isKeySpecialCode( int aKeyCode ) bool isKeySpecialCode( int aKeyCode )
{ {
// These keys have predefined actions (like move thumbtrack cursor), // These keys have predefined actions (like move thumbtrack cursor),
@ -288,9 +289,10 @@ bool isKeySpecialCode( int aKeyCode )
} }
// Helper function to know if a key should be managed by DispatchWxEvent() /**
// or if the event can be ignored and skipped because the key is only a modifier * Helper to know if a key should be managed by DispatchWxEvent() or if the event can be ignored
// that is not used alone in kicad * and skipped because the key is only a modifier that is not used alone in KiCad.
*/
static bool isKeyModifierOnly( int aKeyCode ) static bool isKeyModifierOnly( int aKeyCode )
{ {
static std::vector<enum wxKeyCode> special_keys = static std::vector<enum wxKeyCode> special_keys =
@ -312,17 +314,19 @@ static bool isMouseClick( wxEventType type )
} }
/* A helper class that convert some special key codes to an equivalent. /**
* WXK_NUMPAD_UP to WXK_UP, * Convert some special key codes to an equivalent.
* WXK_NUMPAD_DOWN to WXK_DOWN, *
* WXK_NUMPAD_LEFT to WXK_LEFT, * - WXK_NUMPAD_UP to WXK_UP
* WXK_NUMPAD_RIGHT, * - WXK_NUMPAD_DOWN to WXK_DOWN
* WXK_NUMPAD_PAGEUP, * - WXK_NUMPAD_LEFT to WXK_LEFT
* WXK_NUMPAD_PAGEDOWN * - WXK_NUMPAD_RIGHT to WXK_RIGHT
* note: * - WXK_NUMPAD_PAGEUP to WXK_PAGEUP
* wxEVT_CHAR_HOOK does this conversion when it is skipped by firing a wxEVT_CHAR * - WXK_NUMPAD_PAGEDOWN to WXK_PAGEDOWN
*
* @note wxEVT_CHAR_HOOK does this conversion when it is skipped by firing a wxEVT_CHAR
* with this converted code, but we do not skip these key events because they also * with this converted code, but we do not skip these key events because they also
* have default action (scroll the panel) * have default action (scroll the panel).
*/ */
int translateSpecialCode( int aKeyCode ) int translateSpecialCode( int aKeyCode )
{ {
@ -347,7 +351,7 @@ std::optional<TOOL_EVENT> TOOL_DISPATCHER::GetToolEvent( wxKeyEvent* aKeyEvent,
int key = aKeyEvent->GetKeyCode(); int key = aKeyEvent->GetKeyCode();
int unicode_key = aKeyEvent->GetUnicodeKey(); int unicode_key = aKeyEvent->GetUnicodeKey();
// This wxEVT_CHAR_HOOK event can be ignored: not useful in Kicad // This wxEVT_CHAR_HOOK event can be ignored: not useful in KiCad
if( isKeyModifierOnly( key ) ) if( isKeyModifierOnly( key ) )
{ {
aKeyEvent->Skip(); aKeyEvent->Skip();
@ -622,11 +626,13 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
if( evt ) if( evt )
{ {
wxLogTrace( kicadTraceToolStack, wxS( "TOOL_DISPATCHER::DispatchWxEvent %s" ), evt->Format() ); wxLogTrace( kicadTraceToolStack, wxS( "TOOL_DISPATCHER::DispatchWxEvent %s" ),
evt->Format() );
handled = m_toolMgr->ProcessEvent( *evt ); handled = m_toolMgr->ProcessEvent( *evt );
wxLogTrace( kicadTraceToolStack, wxS( "TOOL_DISPATCHER::DispatchWxEvent - Handled: %s %s" ), wxLogTrace( kicadTraceToolStack,
wxS( "TOOL_DISPATCHER::DispatchWxEvent - Handled: %s %s" ),
( handled ? wxS( "true" ) : wxS( "false" ) ), evt->Format() ); ( handled ? wxS( "true" ) : wxS( "false" ) ), evt->Format() );
} }
@ -663,3 +669,10 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
wxLogTrace( kicadTraceToolStack, "TOOL_DISPATCHER::DispatchWxEvent - Wx event skipped: %s", wxLogTrace( kicadTraceToolStack, "TOOL_DISPATCHER::DispatchWxEvent - Wx event skipped: %s",
( aEvent.GetSkipped() ? "true" : "false" ) ); ( aEvent.GetSkipped() ? "true" : "false" ) );
} }
// LocalWords: EDA CERN CHANGELOG txt Tomasz Wlostowski wxEvent WXK
// LocalWords: MERCHANTABILITY bool upEvent downEvent touchpad Ctrl
// LocalWords: wxEVENT isKeySpecialCode thumbtrack DispatchWxEvent
// LocalWords: NUMPAD PAGEUP PAGEDOWN wxEVT EVT OSX ctrl ctlr kVK
// LocalWords: unicode ESC keypress wxTimer iconized autopanning WX
// LocalWords: un Wx

View File

@ -35,6 +35,7 @@
#include <wx/log.h> #include <wx/log.h>
TOOL_INTERACTIVE::TOOL_INTERACTIVE( TOOL_ID aId, const std::string& aName ) : TOOL_INTERACTIVE::TOOL_INTERACTIVE( TOOL_ID aId, const std::string& aName ) :
TOOL_BASE( INTERACTIVE, aId, aName ) TOOL_BASE( INTERACTIVE, aId, aName )
{ {
@ -83,7 +84,8 @@ void TOOL_INTERACTIVE::resetTransitions()
void TOOL_INTERACTIVE::goInternal( TOOL_STATE_FUNC& aState, const TOOL_EVENT_LIST& aConditions ) void TOOL_INTERACTIVE::goInternal( TOOL_STATE_FUNC& aState, const TOOL_EVENT_LIST& aConditions )
{ {
wxLogTrace( kicadTraceToolStack, wxLogTrace( kicadTraceToolStack,
wxS( "TOOL_INTERACTIVE::goInternal: Tool '%s', Registering handler for actions '%s'" ), wxS( "TOOL_INTERACTIVE::goInternal: Tool '%s', Registering handler for "
"actions '%s'" ),
GetName(), aConditions.Names() ); GetName(), aConditions.Names() );
m_toolMgr->ScheduleNextState( this, aState, aConditions ); m_toolMgr->ScheduleNextState( this, aState, aConditions );

View File

@ -138,6 +138,7 @@ struct TOOL_MANAGER::TOOL_STATE
waitEvents = aState.waitEvents; waitEvents = aState.waitEvents;
transitions = aState.transitions; transitions = aState.transitions;
vcSettings = aState.vcSettings; vcSettings = aState.vcSettings;
// do not copy stateStack // do not copy stateStack
return *this; return *this;
} }
@ -187,10 +188,10 @@ struct TOOL_MANAGER::TOOL_STATE
} }
private: private:
///< Stack preserving previous states of a TOOL. /// Stack preserving previous states of a TOOL.
std::stack<std::unique_ptr<TOOL_STATE>> stateStack; std::stack<std::unique_ptr<TOOL_STATE>> stateStack;
///< Restores the initial state. /// Restores the initial state.
void clear() void clear()
{ {
idle = true; idle = true;
@ -246,7 +247,8 @@ void TOOL_MANAGER::RegisterTool( TOOL_BASE* aTool )
wxASSERT_MSG( m_toolTypes.find( typeid( *aTool ).name() ) == m_toolTypes.end(), wxASSERT_MSG( m_toolTypes.find( typeid( *aTool ).name() ) == m_toolTypes.end(),
wxT( "Adding two tools of the same type may result in unexpected behavior.") ); wxT( "Adding two tools of the same type may result in unexpected behavior.") );
wxLogTrace( kicadTraceToolStack, wxS( "TOOL_MANAGER::RegisterTool: Registering tool %s with ID %d" ), wxLogTrace( kicadTraceToolStack,
wxS( "TOOL_MANAGER::RegisterTool: Registering tool %s with ID %d" ),
aTool->GetName(), aTool->GetId() ); aTool->GetName(), aTool->GetId() );
m_toolOrder.push_back( aTool ); m_toolOrder.push_back( aTool );
@ -644,7 +646,8 @@ void TOOL_MANAGER::InitTools()
if( !tool->Init() ) if( !tool->Init() )
{ {
wxLogTrace( kicadTraceToolStack, wxS( "TOOL_MANAGER initialization of tool '%s' failed" ), wxLogTrace( kicadTraceToolStack,
wxS( "TOOL_MANAGER initialization of tool '%s' failed" ),
tool->GetName() ); tool->GetName() );
// Unregister the tool // Unregister the tool
@ -785,7 +788,8 @@ bool TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent )
if( !st->wakeupEvent.PassEvent() ) if( !st->wakeupEvent.PassEvent() )
{ {
wxLogTrace( kicadTraceToolStack, wxLogTrace( kicadTraceToolStack,
wxS( "TOOL_MANAGER::dispatchInternal - tool %s stopped passing event: %s" ), wxS( "TOOL_MANAGER::dispatchInternal - tool %s stopped passing "
"event: %s" ),
st->theTool->GetName(), aEvent.Format() ); st->theTool->GetName(), aEvent.Format() );
return true; return true;
@ -826,7 +830,8 @@ bool TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent )
st->cofunc = new COROUTINE<int, const TOOL_EVENT&>( std::move( func_copy ) ); st->cofunc = new COROUTINE<int, const TOOL_EVENT&>( std::move( func_copy ) );
wxLogTrace( kicadTraceToolStack, wxLogTrace( kicadTraceToolStack,
wxS( "TOOL_MANAGER::dispatchInternal - Running tool %s for event: %s" ), wxS( "TOOL_MANAGER::dispatchInternal - Running tool %s for "
"event: %s" ),
st->theTool->GetName(), aEvent.Format() ); st->theTool->GetName(), aEvent.Format() );
// got match? Run the handler. // got match? Run the handler.
@ -891,6 +896,7 @@ bool TOOL_MANAGER::dispatchActivation( const TOOL_EVENT& aEvent )
return false; return false;
} }
void TOOL_MANAGER::DispatchContextMenu( const TOOL_EVENT& aEvent ) void TOOL_MANAGER::DispatchContextMenu( const TOOL_EVENT& aEvent )
{ {
for( TOOL_ID toolId : m_activeTools ) for( TOOL_ID toolId : m_activeTools )
@ -952,7 +958,7 @@ void TOOL_MANAGER::DispatchContextMenu( const TOOL_EVENT& aEvent )
if( m_viewControls && m_warpMouseAfterContextMenu ) if( m_viewControls && m_warpMouseAfterContextMenu )
m_viewControls->WarpMouseCursor( m_menuCursor, true, false ); m_viewControls->WarpMouseCursor( m_menuCursor, true, false );
} }
// Otherwise notify the tool of a cancelled menu // Otherwise notify the tool of a canceled menu
else else
{ {
TOOL_EVENT evt( TC_COMMAND, TA_CHOICE_MENU_CHOICE, -1 ); TOOL_EVENT evt( TC_COMMAND, TA_CHOICE_MENU_CHOICE, -1 );
@ -974,7 +980,8 @@ void TOOL_MANAGER::DispatchContextMenu( const TOOL_EVENT& aEvent )
m_menuOwner = -1; m_menuOwner = -1;
// Restore cursor settings // Restore cursor settings
for( const std::pair<const TOOL_ID, std::optional<VECTOR2D>>& cursorSetting : m_cursorSettings ) for( const std::pair<const TOOL_ID,
std::optional<VECTOR2D>>& cursorSetting : m_cursorSettings )
{ {
auto it = m_toolIdIndex.find( cursorSetting.first ); auto it = m_toolIdIndex.find( cursorSetting.first );
wxASSERT( it != m_toolIdIndex.end() ); wxASSERT( it != m_toolIdIndex.end() );

View File

@ -39,6 +39,7 @@ TOOLS_HOLDER::TOOLS_HOLDER() :
m_moveWarpsCursor( true ) m_moveWarpsCursor( true )
{ } { }
void TOOLS_HOLDER::RegisterUIUpdateHandler( const TOOL_ACTION& aAction, void TOOLS_HOLDER::RegisterUIUpdateHandler( const TOOL_ACTION& aAction,
const ACTION_CONDITIONS& aConditions ) const ACTION_CONDITIONS& aConditions )
{ {
@ -83,7 +84,6 @@ void TOOLS_HOLDER::PopTool( const TOOL_EVENT& aEvent )
// Push/pop events can get out of order (such as when they're generated by the Simulator // Push/pop events can get out of order (such as when they're generated by the Simulator
// frame but not processed until the mouse is back in the Schematic frame), so make sure // frame but not processed until the mouse is back in the Schematic frame), so make sure
// we're popping the right stack frame. // we're popping the right stack frame.
for( int i = (int) m_toolStack.size() - 1; i >= 0; --i ) for( int i = (int) m_toolStack.size() - 1; i >= 0; --i )
{ {
if( m_toolStack[ i ] == actionName ) if( m_toolStack[ i ] == actionName )

View File

@ -74,6 +74,7 @@ void ZOOM_MENU::update()
{ {
// Search for a value near the current zoom setting: // Search for a value near the current zoom setting:
double rel_error = std::fabs( zoomList[jj] - zoom ) / zoom; double rel_error = std::fabs( zoomList[jj] - zoom ) / zoom;
// IDs start with 1 (leaving 0 for auto-zoom) // IDs start with 1 (leaving 0 for auto-zoom)
Check( ID_POPUP_ZOOM_LEVEL_START + jj + 1, rel_error < 0.1 ); Check( ID_POPUP_ZOOM_LEVEL_START + jj + 1, rel_error < 0.1 );
} }

View File

@ -361,6 +361,7 @@ bool FIELD_VALIDATOR::Validate( wxWindow* aParent )
return DoValidate( val, aParent ); return DoValidate( val, aParent );
} }
bool FIELD_VALIDATOR::DoValidate( const wxString& aValue, wxWindow* aParent ) bool FIELD_VALIDATOR::DoValidate( const wxString& aValue, wxWindow* aParent )
{ {
wxString msg; wxString msg;

View File

@ -133,7 +133,6 @@ private:
m_groupsSize = 0; m_groupsSize = 0;
} }
/** /**
* Return information if the item uses at least one group id (ie. if it is cached at all). * Return information if the item uses at least one group id (ie. if it is cached at all).
* *
@ -144,7 +143,6 @@ private:
return m_groupsSize > 0; return m_groupsSize > 0;
} }
/** /**
* Reorder the stored groups (to facilitate reordering of layers). * Reorder the stored groups (to facilitate reordering of layers).
* *
@ -972,7 +970,8 @@ struct VIEW::DRAW_ITEM_VISITOR
std::sort( drawItems.begin(), drawItems.end(), std::sort( drawItems.begin(), drawItems.end(),
[]( VIEW_ITEM* a, VIEW_ITEM* b ) -> bool []( VIEW_ITEM* a, VIEW_ITEM* b ) -> bool
{ {
return b->viewPrivData()->m_drawPriority < a->viewPrivData()->m_drawPriority; return b->viewPrivData()->m_drawPriority
< a->viewPrivData()->m_drawPriority;
} ); } );
} }
else else
@ -980,7 +979,8 @@ struct VIEW::DRAW_ITEM_VISITOR
std::sort( drawItems.begin(), drawItems.end(), std::sort( drawItems.begin(), drawItems.end(),
[]( VIEW_ITEM* a, VIEW_ITEM* b ) -> bool []( VIEW_ITEM* a, VIEW_ITEM* b ) -> bool
{ {
return a->viewPrivData()->m_drawPriority < b->viewPrivData()->m_drawPriority; return a->viewPrivData()->m_drawPriority
< b->viewPrivData()->m_drawPriority;
} ); } );
} }
@ -1541,8 +1541,8 @@ void VIEW::UpdateItems()
} }
} }
KI_TRACE( traceGalProfile, wxS( "View update: total items %u, geom %u anyUpdated %u\n" ), cntTotal, KI_TRACE( traceGalProfile, wxS( "View update: total items %u, geom %u anyUpdated %u\n" ),
cntGeomUpdate, (unsigned) anyUpdated ); cntTotal, cntGeomUpdate, (unsigned) anyUpdated );
} }

View File

@ -261,6 +261,7 @@ struct VIEW_OVERLAY::COMMAND_BITMAP_TEXT : public VIEW_OVERLAY::COMMAND
EDA_ANGLE m_angle; EDA_ANGLE m_angle;
}; };
VIEW_OVERLAY::VIEW_OVERLAY() VIEW_OVERLAY::VIEW_OVERLAY()
{ {
} }
@ -418,11 +419,13 @@ void VIEW_OVERLAY::SetStrokeColor( const COLOR4D& aColor )
m_commands.push_back( new COMMAND_SET_COLOR( true, aColor ) ); m_commands.push_back( new COMMAND_SET_COLOR( true, aColor ) );
} }
void VIEW_OVERLAY::SetLineWidth( double aLineWidth ) void VIEW_OVERLAY::SetLineWidth( double aLineWidth )
{ {
m_commands.push_back( new COMMAND_SET_WIDTH( aLineWidth ) ); m_commands.push_back( new COMMAND_SET_WIDTH( aLineWidth ) );
} }
void VIEW_OVERLAY::Cross( const VECTOR2D& aP, int aSize ) void VIEW_OVERLAY::Cross( const VECTOR2D& aP, int aSize )
{ {
Line( aP + VECTOR2D( -aSize, -aSize ), aP + VECTOR2D( aSize, aSize ) ); Line( aP + VECTOR2D( -aSize, -aSize ), aP + VECTOR2D( aSize, aSize ) );

View File

@ -141,7 +141,7 @@ WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, EDA_DRAW_PANEL_GAL* aParentPane
m_cursorWarped = false; m_cursorWarped = false;
m_panTimer.SetOwner( this ); m_panTimer.SetOwner( this );
this->Connect( wxEVT_TIMER, wxTimerEventHandler( WX_VIEW_CONTROLS::onTimer ), nullptr, this ); Connect( wxEVT_TIMER, wxTimerEventHandler( WX_VIEW_CONTROLS::onTimer ), nullptr, this );
m_settings.m_lastKeyboardCursorPositionValid = false; m_settings.m_lastKeyboardCursorPositionValid = false;
m_settings.m_lastKeyboardCursorPosition = { 0.0, 0.0 }; m_settings.m_lastKeyboardCursorPosition = { 0.0, 0.0 };
@ -292,11 +292,15 @@ void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent )
} }
} }
else else
{
justWarped = false; justWarped = false;
} }
}
else else
{
justWarped = false; justWarped = false;
} }
}
else if( m_state == DRAG_ZOOMING ) else if( m_state == DRAG_ZOOMING )
{ {
static bool justWarped = false; static bool justWarped = false;
@ -337,9 +341,11 @@ void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent )
justWarped = false; justWarped = false;
} }
else else
{
justWarped = false; justWarped = false;
} }
} }
}
if( m_updateCursor ) // do not update the cursor position if it was explicitly set if( m_updateCursor ) // do not update the cursor position if it was explicitly set
m_cursorPos = GetClampedCoords( m_view->ToWorld( mousePos ) ); m_cursorPos = GetClampedCoords( m_view->ToWorld( mousePos ) );
@ -361,16 +367,19 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent )
// Pick the modifier, if any. Shift beats control beats alt, we don't support more than one. // Pick the modifier, if any. Shift beats control beats alt, we don't support more than one.
int nMods = 0; int nMods = 0;
int modifiers = 0; int modifiers = 0;
if( aEvent.ShiftDown() ) if( aEvent.ShiftDown() )
{ {
nMods += 1; nMods += 1;
modifiers = WXK_SHIFT; modifiers = WXK_SHIFT;
} }
if( aEvent.ControlDown() ) if( aEvent.ControlDown() )
{ {
nMods += 1; nMods += 1;
modifiers = modifiers == 0 ? WXK_CONTROL : modifiers; modifiers = modifiers == 0 ? WXK_CONTROL : modifiers;
} }
if( aEvent.AltDown() ) if( aEvent.AltDown() )
{ {
nMods += 1; nMods += 1;
@ -440,7 +449,7 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent )
} }
else else
{ {
// When we have muliple mods, forward it for tool handling // When we have multiple mods, forward it for tool handling
aEvent.Skip(); aEvent.Skip();
} }
} }
@ -461,6 +470,7 @@ void WX_VIEW_CONTROLS::setState( STATE aNewState )
m_state = aNewState; m_state = aNewState;
} }
void WX_VIEW_CONTROLS::onButton( wxMouseEvent& aEvent ) void WX_VIEW_CONTROLS::onButton( wxMouseEvent& aEvent )
{ {
switch( m_state ) switch( m_state )
@ -528,9 +538,9 @@ void WX_VIEW_CONTROLS::onEnter( wxMouseEvent& aEvent )
} }
#if defined( _WIN32 ) || defined( __WXGTK__ ) #if defined( _WIN32 ) || defined( __WXGTK__ )
// Win32 and some *nix WMs transmit mouse move and wheel events to all controls below the mouse regardless // Win32 and some *nix WMs transmit mouse move and wheel events to all controls below the
// of focus. Forcing the focus here will cause the EDA FRAMES to immediately become the // mouse regardless of focus. Forcing the focus here will cause the EDA FRAMES to immediately
// top level active window. // become the top level active window.
if( m_parentPanel->GetParent() != nullptr ) if( m_parentPanel->GetParent() != nullptr )
{ {
// this assumes the parent panel's parent is the eda window // this assumes the parent panel's parent is the eda window
@ -552,6 +562,7 @@ void WX_VIEW_CONTROLS::onLeave( wxMouseEvent& aEvent )
#endif #endif
} }
void WX_VIEW_CONTROLS::onCaptureLost( wxMouseEvent& aEvent ) void WX_VIEW_CONTROLS::onCaptureLost( wxMouseEvent& aEvent )
{ {
// This method must be present to suppress the capture-lost assertion // This method must be present to suppress the capture-lost assertion
@ -776,6 +787,7 @@ void WX_VIEW_CONTROLS::CancelDrag()
if( m_state == DRAG_PANNING || m_state == DRAG_ZOOMING ) if( m_state == DRAG_PANNING || m_state == DRAG_ZOOMING )
{ {
setState( IDLE ); setState( IDLE );
#if defined USE_MOUSE_CAPTURE #if defined USE_MOUSE_CAPTURE
if( !m_settings.m_cursorCaptured && m_parentPanel->HasCapture() ) if( !m_settings.m_cursorCaptured && m_parentPanel->HasCapture() )
m_parentPanel->ReleaseMouse(); m_parentPanel->ReleaseMouse();
@ -894,8 +906,8 @@ void WX_VIEW_CONTROLS::WarpMouseCursor( const VECTOR2D& aPosition, bool aWorldCo
KIPLATFORM::UI::WarpPointer( m_parentPanel, aPosition.x, aPosition.y ); KIPLATFORM::UI::WarpPointer( m_parentPanel, aPosition.x, aPosition.y );
} }
// If we are not refreshing because of mouse movement, don't set the modifiers // If we are not refreshing because of mouse movement, don't set the modifiers because we
// because we are refreshing for keyboard movement, which uses the same modifiers for other actions // are refreshing for keyboard movement, which uses the same modifiers for other actions
refreshMouse( m_updateCursor ); refreshMouse( m_updateCursor );
} }
@ -1129,6 +1141,7 @@ void WX_VIEW_CONTROLS::UpdateScrollbars()
} }
} }
void WX_VIEW_CONTROLS::ForceCursorPosition( bool aEnabled, const VECTOR2D& aPosition ) void WX_VIEW_CONTROLS::ForceCursorPosition( bool aEnabled, const VECTOR2D& aPosition )
{ {
VECTOR2D clampedPosition = GetClampedCoords( aPosition ); VECTOR2D clampedPosition = GetClampedCoords( aPosition );

View File

@ -50,6 +50,7 @@ BUTTON_ROW_PANEL::BUTTON_ROW_PANEL( wxWindow* aWindow,
void BUTTON_ROW_PANEL::addButtons( bool aLeft, const BTN_DEF_LIST& aDefs ) void BUTTON_ROW_PANEL::addButtons( bool aLeft, const BTN_DEF_LIST& aDefs )
{ {
const int btn_margin = KIUI::GetStdMargin(); const int btn_margin = KIUI::GetStdMargin();
// No button expands to fill horizontally // No button expands to fill horizontally
const int btn_proportion = 0; const int btn_proportion = 0;

View File

@ -145,7 +145,8 @@ COLOR_SWATCH::COLOR_SWATCH( wxWindow* aParent, const COLOR4D& aColor, int aID,
m_readOnly( false ), m_readOnly( false ),
m_supportsOpacity( true ) m_supportsOpacity( true )
{ {
wxASSERT_MSG( aSwatchSize != SWATCH_EXPAND, wxS( "SWATCH_EXPAND not supported in COLOR_SWATCH" ) ); wxASSERT_MSG( aSwatchSize != SWATCH_EXPAND,
wxS( "SWATCH_EXPAND not supported in COLOR_SWATCH" ) );
switch( aSwatchSize ) switch( aSwatchSize )
{ {

View File

@ -244,7 +244,6 @@ void FILTER_COMBOPOPUP::onMouseClick( wxMouseEvent& aEvent )
{ {
// Accept a click event from anywhere. Different platform implementations have // Accept a click event from anywhere. Different platform implementations have
// different foibles with regard to transient popups and their children. // different foibles with regard to transient popups and their children.
if( aEvent.GetEventObject() == m_listBox ) if( aEvent.GetEventObject() == m_listBox )
{ {
m_listBox->SetSelection( m_listBox->HitTest( aEvent.GetPosition() ) ); m_listBox->SetSelection( m_listBox->HitTest( aEvent.GetPosition() ) );
@ -294,7 +293,8 @@ void FILTER_COMBOPOPUP::onKeyDown( wxKeyEvent& aEvent )
case WXK_DOWN: case WXK_DOWN:
case WXK_NUMPAD_DOWN: case WXK_NUMPAD_DOWN:
doSetFocus( m_listBox ); doSetFocus( m_listBox );
m_listBox->SetSelection( std::min( m_listBox->GetSelection() + 1, (int) m_listBox->GetCount() - 1 ) ); m_listBox->SetSelection( std::min( m_listBox->GetSelection() + 1,
(int) m_listBox->GetCount() - 1 ) );
break; break;
case WXK_UP: case WXK_UP:
@ -421,27 +421,23 @@ void FILTER_COMBOBOX::onKeyDown( wxKeyEvent& aEvt )
// even get to us. But just to be safe, we go ahead and skip. // even get to us. But just to be safe, we go ahead and skip.
aEvt.Skip(); aEvt.Skip();
} }
// Shift-return accepts dialog // Shift-return accepts dialog
else if( ( key == WXK_RETURN || key == WXK_NUMPAD_ENTER ) && aEvt.ShiftDown() ) else if( ( key == WXK_RETURN || key == WXK_NUMPAD_ENTER ) && aEvt.ShiftDown() )
{ {
wxPostEvent( m_parent, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) ); wxPostEvent( m_parent, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
} }
// Return, arrow-down and space-bar all open popup // Return, arrow-down and space-bar all open popup
else if( key == WXK_RETURN || key == WXK_NUMPAD_ENTER || key == WXK_DOWN else if( key == WXK_RETURN || key == WXK_NUMPAD_ENTER || key == WXK_DOWN
|| key == WXK_NUMPAD_DOWN || key == WXK_SPACE ) || key == WXK_NUMPAD_DOWN || key == WXK_SPACE )
{ {
Popup(); Popup();
} }
// Non-control characters go to filterbox in popup // Non-control characters go to filterbox in popup
else if( key > WXK_SPACE && key < WXK_START ) else if( key > WXK_SPACE && key < WXK_START )
{ {
Popup(); Popup();
m_filterPopup->OnStartingKey( aEvt ); m_filterPopup->OnStartingKey( aEvt );
} }
else else
{ {
aEvt.Skip(); aEvt.Skip();

View File

@ -49,7 +49,8 @@ void FOOTPRINT_CHOICE::DoSetPopupControl( wxComboPopup* aPopup )
GetVListBoxComboPopup()->Bind( wxEVT_LEFT_DOWN, &FOOTPRINT_CHOICE::TryVetoMouse, this ); GetVListBoxComboPopup()->Bind( wxEVT_LEFT_DOWN, &FOOTPRINT_CHOICE::TryVetoMouse, this );
GetVListBoxComboPopup()->Bind( wxEVT_LEFT_UP, &FOOTPRINT_CHOICE::TryVetoMouse, this ); GetVListBoxComboPopup()->Bind( wxEVT_LEFT_UP, &FOOTPRINT_CHOICE::TryVetoMouse, this );
GetVListBoxComboPopup()->Bind( wxEVT_LEFT_DCLICK, &FOOTPRINT_CHOICE::TryVetoMouse, this ); GetVListBoxComboPopup()->Bind( wxEVT_LEFT_DCLICK, &FOOTPRINT_CHOICE::TryVetoMouse, this );
GetVListBoxComboPopup()->Bind( wxEVT_LISTBOX, std::bind( &FOOTPRINT_CHOICE::TryVetoSelect, this, _1, true ) ); GetVListBoxComboPopup()->Bind( wxEVT_LISTBOX, std::bind( &FOOTPRINT_CHOICE::TryVetoSelect,
this, _1, true ) );
Bind( wxEVT_COMBOBOX, std::bind( &FOOTPRINT_CHOICE::TryVetoSelect, this, _1, false ) ); Bind( wxEVT_COMBOBOX, std::bind( &FOOTPRINT_CHOICE::TryVetoSelect, this, _1, false ) );
} }
@ -83,7 +84,6 @@ void FOOTPRINT_CHOICE::OnDrawItem( wxDC& aDC, wxRect const& aRect, int aItem, in
// If this item has a footprint and that footprint has a ":" delimiter, find the // If this item has a footprint and that footprint has a ":" delimiter, find the
// library component, then find that in the display string and grey it out. // library component, then find that in the display string and grey it out.
size_t start_grey = 0; size_t start_grey = 0;
size_t end_grey = 0; size_t end_grey = 0;
@ -121,6 +121,7 @@ void FOOTPRINT_CHOICE::OnDrawItem( wxDC& aDC, wxRect const& aRect, int aItem, in
} }
} }
wxCoord FOOTPRINT_CHOICE::OnMeasureItem( size_t aItem ) const wxCoord FOOTPRINT_CHOICE::OnMeasureItem( size_t aItem ) const
{ {
if( SafeGetString( aItem ) == wxS( "" ) ) if( SafeGetString( aItem ) == wxS( "" ) )

View File

@ -135,7 +135,6 @@ bool FOOTPRINT_SELECT_WIDGET::UpdateList()
// Be careful adding items! "Default" must occupy POS_DEFAULT, // Be careful adding items! "Default" must occupy POS_DEFAULT,
// "Other" must occupy POS_OTHER, and the separator must occupy POS_SEPARATOR. // "Other" must occupy POS_OTHER, and the separator must occupy POS_SEPARATOR.
m_fp_sel_ctrl->Append( m_default_footprint.IsEmpty() ? m_fp_sel_ctrl->Append( m_default_footprint.IsEmpty() ?
_( "No default footprint" ) : _( "No default footprint" ) :
wxS( "[" ) + _( "Default" ) + wxS( "] " ) + m_default_footprint, wxS( "[" ) + _( "Default" ) + wxS( "] " ) + m_default_footprint,
@ -145,7 +144,8 @@ bool FOOTPRINT_SELECT_WIDGET::UpdateList()
{ {
for( FOOTPRINT_INFO& fpinfo : m_fp_filter ) for( FOOTPRINT_INFO& fpinfo : m_fp_filter )
{ {
wxString display_name( fpinfo.GetLibNickname() + wxS( ":" ) + fpinfo.GetFootprintName() ); wxString display_name( fpinfo.GetLibNickname() + wxS( ":" ) +
fpinfo.GetFootprintName() );
m_fp_sel_ctrl->Append( display_name, new wxStringClientData( display_name ) ); m_fp_sel_ctrl->Append( display_name, new wxStringClientData( display_name ) );
++n_items; ++n_items;

View File

@ -54,11 +54,13 @@ void GRID_CELL_COMBOBOX::Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler
wxGridCellEditor::Create(aParent, aId, aEventHandler); wxGridCellEditor::Create(aParent, aId, aEventHandler);
} }
wxString GRID_CELL_COMBOBOX::GetValue() const wxString GRID_CELL_COMBOBOX::GetValue() const
{ {
return Combo()->GetValue(); return Combo()->GetValue();
} }
void GRID_CELL_COMBOBOX::SetSize( const wxRect& aRect ) void GRID_CELL_COMBOBOX::SetSize( const wxRect& aRect )
{ {
wxRect rect( aRect ); wxRect rect( aRect );

View File

@ -208,8 +208,8 @@ GRID_CELL_STATUS_ICON_RENDERER::GRID_CELL_STATUS_ICON_RENDERER( int aStatus ) :
else else
{ {
// Dummy bitmap for size // Dummy bitmap for size
m_bitmap = wxArtProvider::GetBitmap( wxArtProvider::GetMessageBoxIconId( wxICON_INFORMATION ), m_bitmap = wxArtProvider::GetBitmap(
wxART_BUTTON ); wxArtProvider::GetMessageBoxIconId( wxICON_INFORMATION ), wxART_BUTTON );
} }
} }
@ -267,7 +267,8 @@ void GRID_CELL_ICON_TEXT_POPUP::Create( wxWindow* aParent, wxWindowID aId,
{ {
m_control = new wxBitmapComboBox( aParent, aId, wxEmptyString, wxDefaultPosition, m_control = new wxBitmapComboBox( aParent, aId, wxEmptyString, wxDefaultPosition,
wxDefaultSize, 0, nullptr, wxDefaultSize, 0, nullptr,
wxCB_READONLY | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB | wxBORDER_NONE ); wxCB_READONLY | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB |
wxBORDER_NONE );
for( unsigned i = 0; i < m_names.size(); ++i ) for( unsigned i = 0; i < m_names.size(); ++i )
{ {

View File

@ -114,6 +114,7 @@ void GRID_CELL_TEXT_BUTTON::StartingKey( wxKeyEvent& event )
default: default:
if( isPrintable ) if( isPrintable )
textEntry->WriteText( static_cast<wxChar>( ch ) ); textEntry->WriteText( static_cast<wxChar>( ch ) );
break; break;
} }
} }
@ -276,7 +277,8 @@ protected:
{ {
if( !m_symbolNetlist.empty() ) if( !m_symbolNetlist.empty() )
{ {
KIWAY_EXPRESS event( FRAME_FOOTPRINT_CHOOSER, MAIL_SYMBOL_NETLIST, m_symbolNetlist ); KIWAY_EXPRESS event( FRAME_FOOTPRINT_CHOOSER, MAIL_SYMBOL_NETLIST,
m_symbolNetlist );
frame->KiwayMailIn( event ); frame->KiwayMailIn( event );
} }
@ -292,10 +294,12 @@ protected:
protected: protected:
DIALOG_SHIM* m_dlg; DIALOG_SHIM* m_dlg;
wxString m_preselect; wxString m_preselect;
// Lock flag to lock the button to show the FP chooser // Lock flag to lock the button to show the FP chooser
// true when the button is busy, waiting all footprints loaded to // true when the button is busy, waiting all footprints loaded to
// avoid running more than once the FP chooser // avoid running more than once the FP chooser
bool m_buttonFpChooserLock; bool m_buttonFpChooserLock;
/* /*
* Symbol netlist format: * Symbol netlist format:
* pinNumber pinName <tab> pinNumber pinName... * pinNumber pinName <tab> pinNumber pinName...
@ -326,7 +330,8 @@ void GRID_CELL_FPID_EDITOR::Create( wxWindow* aParent, wxWindowID aId,
class TEXT_BUTTON_URL : public wxComboCtrl class TEXT_BUTTON_URL : public wxComboCtrl
{ {
public: public:
TEXT_BUTTON_URL( wxWindow* aParent, DIALOG_SHIM* aParentDlg, SEARCH_STACK* aSearchStack, EMBEDDED_FILES* aFiles ) : TEXT_BUTTON_URL( wxWindow* aParent, DIALOG_SHIM* aParentDlg, SEARCH_STACK* aSearchStack,
EMBEDDED_FILES* aFiles ) :
wxComboCtrl( aParent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxComboCtrl( aParent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize,
wxTE_PROCESS_ENTER | wxBORDER_NONE ), wxTE_PROCESS_ENTER | wxBORDER_NONE ),
m_dlg( aParentDlg ), m_dlg( aParentDlg ),
@ -406,8 +411,7 @@ protected:
}; };
void GRID_CELL_URL_EDITOR::Create( wxWindow* aParent, wxWindowID aId, void GRID_CELL_URL_EDITOR::Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler )
wxEvtHandler* aEventHandler )
{ {
m_control = new TEXT_BUTTON_URL( aParent, m_dlg, m_searchStack, m_files ); m_control = new TEXT_BUTTON_URL( aParent, m_dlg, m_searchStack, m_files );
WX_GRID::CellEditorSetMargins( Combo() ); WX_GRID::CellEditorSetMargins( Combo() );
@ -562,11 +566,12 @@ void GRID_CELL_PATH_EDITOR::Create( wxWindow* aParent, wxWindowID aId,
wxEvtHandler* aEventHandler ) wxEvtHandler* aEventHandler )
{ {
if( m_fileFilterFn ) if( m_fileFilterFn )
m_control = new TEXT_BUTTON_FILE_BROWSER( aParent, m_dlg, m_grid, m_currentDir, m_fileFilterFn, m_control = new TEXT_BUTTON_FILE_BROWSER( aParent, m_dlg, m_grid, m_currentDir,
m_normalize, m_normalizeBasePath ); m_fileFilterFn, m_normalize,
m_normalizeBasePath );
else else
m_control = new TEXT_BUTTON_FILE_BROWSER( aParent, m_dlg, m_grid, m_currentDir, m_fileFilter, m_control = new TEXT_BUTTON_FILE_BROWSER( aParent, m_dlg, m_grid, m_currentDir,
m_normalize, m_normalizeBasePath ); m_fileFilter, m_normalize, m_normalizeBasePath );
WX_GRID::CellEditorSetMargins( Combo() ); WX_GRID::CellEditorSetMargins( Combo() );

View File

@ -156,11 +156,13 @@ void GRID_CELL_STC_EDITOR::Create( wxWindow* aParent, wxWindowID aId, wxEvtHandl
m_scintillaTricks = new SCINTILLA_TRICKS( m_scintillaTricks = new SCINTILLA_TRICKS(
stc_ctrl(), wxEmptyString, true, stc_ctrl(), wxEmptyString, true,
// onAcceptFn // onAcceptFn
[this]( wxKeyEvent& aEvent ) [this]( wxKeyEvent& aEvent )
{ {
HandleReturn( aEvent ); HandleReturn( aEvent );
}, },
// onCharFn // onCharFn
[this]( wxStyledTextEvent& aEvent ) [this]( wxStyledTextEvent& aEvent )
{ {
@ -234,8 +236,7 @@ void GRID_CELL_STC_EDITOR::Show( bool aShow, wxGridCellAttr* aAttr )
void GRID_CELL_STC_EDITOR::BeginEdit( int aRow, int aCol, wxGrid* aGrid ) void GRID_CELL_STC_EDITOR::BeginEdit( int aRow, int aCol, wxGrid* aGrid )
{ {
auto evtHandler = static_cast<wxGridCellEditorEvtHandler*>( m_control->GetEventHandler() auto evtHandler = static_cast<wxGridCellEditorEvtHandler*>( m_control->GetEventHandler() );
);
// Don't immediately end if we get a kill focus event within BeginEdit // Don't immediately end if we get a kill focus event within BeginEdit
evtHandler->SetInSetFocus( true ); evtHandler->SetInSetFocus( true );

View File

@ -47,7 +47,7 @@ KISTATUSBAR::KISTATUSBAR( int aNumberFields, wxWindow* parent, wxWindowID id ) :
{ {
#ifdef __WXOSX__ #ifdef __WXOSX__
// we need +1 extra field on OSX to offset from the rounded corner on the right // we need +1 extra field on OSX to offset from the rounded corner on the right
// OSX doesnt use resize grippers like the other platforms and the statusbar field // OSX doesn't use resize grippers like the other platforms and the statusbar field
// includes the rounded part // includes the rounded part
const int ExtraFields = 5; const int ExtraFields = 5;
#else #else
@ -75,6 +75,7 @@ KISTATUSBAR::KISTATUSBAR( int aNumberFields, wxWindow* parent, wxWindowID id ) :
int* styles = new int[aNumberFields + ExtraFields]; int* styles = new int[aNumberFields + ExtraFields];
for( int i = 0; i < aNumberFields + ExtraFields; i++ ) for( int i = 0; i < aNumberFields + ExtraFields; i++ )
styles[i] = wxSB_FLAT; styles[i] = wxSB_FLAT;
@ -211,6 +212,7 @@ void KISTATUSBAR::SetBackgroundStatusText( const wxString& aTxt )
void KISTATUSBAR::SetNotificationCount(int aCount) void KISTATUSBAR::SetNotificationCount(int aCount)
{ {
wxString cnt = ""; wxString cnt = "";
if( aCount > 0 ) if( aCount > 0 )
{ {
cnt = wxString::Format( "%d", aCount ); cnt = wxString::Format( "%d", aCount );
@ -237,6 +239,7 @@ void KISTATUSBAR::SetEllipsedTextField( const wxString& aText, int aFieldId )
if( width > 20 ) if( width > 20 )
{ {
wxClientDC dc( this ); wxClientDC dc( this );
// Gives a margin to the text to be sure it is not clamped at its end // Gives a margin to the text to be sure it is not clamped at its end
int margin = KIUI::GetTextSize( wxT( "XX" ), this ).x; int margin = KIUI::GetTextSize( wxT( "XX" ), this ).x;
etext = wxControl::Ellipsize( etext, dc, wxELLIPSIZE_MIDDLE, width - margin ); etext = wxControl::Ellipsize( etext, dc, wxELLIPSIZE_MIDDLE, width - margin );

View File

@ -105,8 +105,10 @@ static COLOR4D ICON_WHITE{ 0.86, 0.86, 0.86, 1.0 };
static COLOR4D ICON_BLACK{ 0.28, 0.28, 0.28, 1.0 }; static COLOR4D ICON_BLACK{ 0.28, 0.28, 0.28, 1.0 };
std::unique_ptr<wxBitmap> LAYER_PRESENTATION::CreateLayerPairIcon( const COLOR4D& aBgColor, const COLOR4D& aTopColor, std::unique_ptr<wxBitmap> LAYER_PRESENTATION::CreateLayerPairIcon( const COLOR4D& aBgColor,
const COLOR4D& aBottomColor, int aScale ) const COLOR4D& aTopColor,
const COLOR4D& aBottomColor,
int aScale )
{ {
auto layerPairBitmap = std::make_unique<wxBitmap>( BM_LAYERICON_SIZE, BM_LAYERICON_SIZE ); auto layerPairBitmap = std::make_unique<wxBitmap>( BM_LAYERICON_SIZE, BM_LAYERICON_SIZE );

View File

@ -635,7 +635,8 @@ void LIB_TREE::onQueryCharHook( wxKeyEvent& aKeyStroke )
if( !sel.IsOk() ) if( !sel.IsOk() )
sel = m_adapter->GetCurrentDataViewItem(); sel = m_adapter->GetCurrentDataViewItem();
LIB_TREE_NODE::TYPE type = sel.IsOk() ? m_adapter->GetTypeFor( sel ) : LIB_TREE_NODE::TYPE::INVALID; LIB_TREE_NODE::TYPE type = sel.IsOk() ? m_adapter->GetTypeFor( sel )
: LIB_TREE_NODE::TYPE::INVALID;
switch( aKeyStroke.GetKeyCode() ) switch( aKeyStroke.GetKeyCode() )
{ {

View File

@ -64,7 +64,8 @@ LISTBOX_TRICKS::LISTBOX_TRICKS( wxWindow& aParent, wxListBox& aListBox ) :
Connect( EDA_EVT_LISTBOX_COPY, wxCommandEventHandler( LISTBOX_TRICKS::OnListBoxCopy ) ); Connect( EDA_EVT_LISTBOX_COPY, wxCommandEventHandler( LISTBOX_TRICKS::OnListBoxCopy ) );
Connect( EDA_EVT_LISTBOX_CUT, wxCommandEventHandler( LISTBOX_TRICKS::OnListBoxCut ) ); Connect( EDA_EVT_LISTBOX_CUT, wxCommandEventHandler( LISTBOX_TRICKS::OnListBoxCut ) );
Connect( EDA_EVT_LISTBOX_PASTE, wxCommandEventHandler( LISTBOX_TRICKS::OnListBoxPaste ) ); Connect( EDA_EVT_LISTBOX_PASTE, wxCommandEventHandler( LISTBOX_TRICKS::OnListBoxPaste ) );
Connect( EDA_EVT_LISTBOX_DUPLICATE, wxCommandEventHandler( LISTBOX_TRICKS::OnListBoxDuplicate ) ); Connect( EDA_EVT_LISTBOX_DUPLICATE,
wxCommandEventHandler( LISTBOX_TRICKS::OnListBoxDuplicate ) );
} }
@ -79,7 +80,8 @@ LISTBOX_TRICKS::~LISTBOX_TRICKS()
Disconnect( EDA_EVT_LISTBOX_COPY, wxCommandEventHandler( LISTBOX_TRICKS::OnListBoxCopy ) ); Disconnect( EDA_EVT_LISTBOX_COPY, wxCommandEventHandler( LISTBOX_TRICKS::OnListBoxCopy ) );
Disconnect( EDA_EVT_LISTBOX_CUT, wxCommandEventHandler( LISTBOX_TRICKS::OnListBoxCut ) ); Disconnect( EDA_EVT_LISTBOX_CUT, wxCommandEventHandler( LISTBOX_TRICKS::OnListBoxCut ) );
Disconnect( EDA_EVT_LISTBOX_PASTE, wxCommandEventHandler( LISTBOX_TRICKS::OnListBoxPaste ) ); Disconnect( EDA_EVT_LISTBOX_PASTE, wxCommandEventHandler( LISTBOX_TRICKS::OnListBoxPaste ) );
Disconnect( EDA_EVT_LISTBOX_DUPLICATE, wxCommandEventHandler( LISTBOX_TRICKS::OnListBoxDuplicate ) ); Disconnect( EDA_EVT_LISTBOX_DUPLICATE,
wxCommandEventHandler( LISTBOX_TRICKS::OnListBoxDuplicate ) );
} }
@ -103,6 +105,7 @@ wxArrayInt LISTBOX_TRICKS::listBoxDeleteSelected()
m_listBox.Delete( selections[ii] ); m_listBox.Delete( selections[ii] );
m_listBox.SetSelection( wxNOT_FOUND ); m_listBox.SetSelection( wxNOT_FOUND );
if( m_listBox.GetCount() > 0 ) if( m_listBox.GetCount() > 0 )
m_listBox.SetSelection( std::max( 0, selections[0] - 1 ) ); m_listBox.SetSelection( std::max( 0, selections[0] - 1 ) );
@ -117,6 +120,7 @@ wxArrayString LISTBOX_TRICKS::listBoxGetSelected() const
m_listBox.GetSelections( selections ); m_listBox.GetSelections( selections );
wxArrayString result; wxArrayString result;
for( size_t ii = 0; ii < selections.GetCount(); ii++ ) for( size_t ii = 0; ii < selections.GetCount(); ii++ )
result.Add( m_listBox.GetString( selections[ii] ) ); result.Add( m_listBox.GetString( selections[ii] ) );
@ -150,6 +154,7 @@ void LISTBOX_TRICKS::listBoxCopy()
wxArrayString filters = listBoxGetSelected(); wxArrayString filters = listBoxGetSelected();
wxString result; wxString result;
for( const wxString& filter : filters ) for( const wxString& filter : filters )
{ {
result += filter + wxT( "\n" ); result += filter + wxT( "\n" );
@ -166,6 +171,7 @@ void LISTBOX_TRICKS::listBoxCopy()
void LISTBOX_TRICKS::listBoxPaste() void LISTBOX_TRICKS::listBoxPaste()
{ {
wxArrayString lines; wxArrayString lines;
if( wxTheClipboard->Open() ) if( wxTheClipboard->Open() )
{ {
wxTextDataObject data; wxTextDataObject data;
@ -192,6 +198,7 @@ void LISTBOX_TRICKS::listBoxPaste()
m_listBox.InsertItems( lines, insertAt ); m_listBox.InsertItems( lines, insertAt );
m_listBox.SetSelection( wxNOT_FOUND ); m_listBox.SetSelection( wxNOT_FOUND );
for( size_t ii = insertAt; ii < insertAt + lines.GetCount(); ii++ ) for( size_t ii = insertAt; ii < insertAt + lines.GetCount(); ii++ )
m_listBox.SetSelection( ii ); m_listBox.SetSelection( ii );
@ -276,9 +283,11 @@ void LISTBOX_TRICKS::OnListBoxKeyDown( wxKeyEvent& aEvent )
} }
} }
else else
{
aEvent.Skip(); aEvent.Skip();
} }
} }
}
void LISTBOX_TRICKS::OnListBoxDelete( wxCommandEvent& aEvent ) void LISTBOX_TRICKS::OnListBoxDelete( wxCommandEvent& aEvent )

View File

@ -309,7 +309,8 @@ void mpFX::Plot( wxDC& dc, mpWindow& w )
{ {
iy = w.y2p( GetY( w.p2x( i ) ) ); iy = w.y2p( GetY( w.p2x( i ) ) );
// Draw the point only if you can draw outside margins or if the point is inside margins // Draw the point only if you can draw outside margins or if the point is
// inside margins
if( ( iy >= minYpx ) && ( iy <= maxYpx ) ) if( ( iy >= minYpx ) && ( iy <= maxYpx ) )
dc.DrawPoint( i, iy ); dc.DrawPoint( i, iy );
} }
@ -320,7 +321,8 @@ void mpFX::Plot( wxDC& dc, mpWindow& w )
{ {
iy = w.y2p( GetY( w.p2x( i ) ) ); iy = w.y2p( GetY( w.p2x( i ) ) );
// Draw the point only if you can draw outside margins or if the point is inside margins // Draw the point only if you can draw outside margins or if the point is
// inside margins
if( iy >= minYpx && iy <= maxYpx ) if( iy >= minYpx && iy <= maxYpx )
dc.DrawLine( i, iy, i, iy ); dc.DrawLine( i, iy, i, iy );
} }
@ -336,7 +338,8 @@ void mpFX::Plot( wxDC& dc, mpWindow& w )
if( ( m_flags & mpALIGNMASK ) == mpALIGN_RIGHT ) if( ( m_flags & mpALIGNMASK ) == mpALIGN_RIGHT )
tx = ( w.GetScrX() - tx ) - w.GetMarginRight() - 8; tx = ( w.GetScrX() - tx ) - w.GetMarginRight() - 8;
else if( ( m_flags & mpALIGNMASK ) == mpALIGN_CENTER ) else if( ( m_flags & mpALIGNMASK ) == mpALIGN_CENTER )
tx = ( (w.GetScrX() - w.GetMarginRight() - w.GetMarginLeft() - tx) / 2 ) + w.GetMarginLeft(); tx = ( ( w.GetScrX() - w.GetMarginRight() - w.GetMarginLeft() - tx ) / 2 )
+ w.GetMarginLeft();
else else
tx = w.GetMarginLeft() + 8; tx = w.GetMarginLeft() + 8;
@ -348,6 +351,7 @@ void mpFX::Plot( wxDC& dc, mpWindow& w )
IMPLEMENT_ABSTRACT_CLASS( mpFY, mpLayer ) IMPLEMENT_ABSTRACT_CLASS( mpFY, mpLayer )
mpFY::mpFY( const wxString& name, int flags ) mpFY::mpFY( const wxString& name, int flags )
{ {
SetName( name ); SetName( name );
@ -400,7 +404,8 @@ void mpFY::Plot( wxDC& dc, mpWindow& w )
if( ( m_flags & mpALIGNMASK ) == mpALIGN_TOP ) if( ( m_flags & mpALIGNMASK ) == mpALIGN_TOP )
ty = w.GetMarginTop() + 8; ty = w.GetMarginTop() + 8;
else if( ( m_flags & mpALIGNMASK ) == mpALIGN_CENTER ) else if( ( m_flags & mpALIGNMASK ) == mpALIGN_CENTER )
ty = ( ( w.GetScrY() - w.GetMarginTop() - w.GetMarginBottom() - ty) / 2 ) + w.GetMarginTop(); ty = ( ( w.GetScrY() - w.GetMarginTop() - w.GetMarginBottom() - ty ) / 2 )
+ w.GetMarginTop();
else else
ty = w.GetScrY() - 8 - ty - w.GetMarginBottom(); ty = w.GetScrY() - 8 - ty - w.GetMarginBottom();
@ -412,6 +417,7 @@ void mpFY::Plot( wxDC& dc, mpWindow& w )
IMPLEMENT_ABSTRACT_CLASS( mpFXY, mpLayer ) IMPLEMENT_ABSTRACT_CLASS( mpFXY, mpLayer )
mpFXY::mpFXY( const wxString& name, int flags ) mpFXY::mpFXY( const wxString& name, int flags )
{ {
SetName( name ); SetName( name );
@ -1023,6 +1029,7 @@ IMPLEMENT_ABSTRACT_CLASS( mpScaleXBase, mpLayer )
IMPLEMENT_DYNAMIC_CLASS( mpScaleX, mpScaleXBase ) IMPLEMENT_DYNAMIC_CLASS( mpScaleX, mpScaleXBase )
IMPLEMENT_DYNAMIC_CLASS( mpScaleXLog, mpScaleXBase ) IMPLEMENT_DYNAMIC_CLASS( mpScaleXLog, mpScaleXBase )
mpScaleXBase::mpScaleXBase( const wxString& name, int flags, bool ticks, unsigned int type ) mpScaleXBase::mpScaleXBase( const wxString& name, int flags, bool ticks, unsigned int type )
{ {
SetName( name ); SetName( name );
@ -1084,7 +1091,9 @@ void mpScaleXBase::Plot( wxDC& dc, mpWindow& w )
wxCoord maxYpx = w.GetScrY() - w.GetMarginBottom(); wxCoord maxYpx = w.GetScrY() - w.GetMarginBottom();
// int tmp=-65535; // int tmp=-65535;
int labelH = m_maxLabelHeight; // Control labels height to decide where to put axis name (below labels or on top of axis)
// Control labels height to decide where to put axis name (below labels or on top of axis).
int labelH = m_maxLabelHeight;
// int maxExtent = tc.MaxLabelWidth(); // int maxExtent = tc.MaxLabelWidth();
for( double tp : m_tickValues ) for( double tp : m_tickValues )
@ -1196,6 +1205,7 @@ void mpScaleXBase::Plot( wxDC& dc, mpWindow& w )
IMPLEMENT_DYNAMIC_CLASS( mpScaleY, mpLayer ) IMPLEMENT_DYNAMIC_CLASS( mpScaleY, mpLayer )
mpScaleY::mpScaleY( const wxString& name, int flags, bool ticks ) mpScaleY::mpScaleY( const wxString& name, int flags, bool ticks )
{ {
SetName( name ); SetName( name );
@ -1244,6 +1254,7 @@ void mpScaleY::Plot( wxDC& dc, mpWindow& w )
wxCoord endPx = w.GetScrX() - w.GetMarginRight(); wxCoord endPx = w.GetScrX() - w.GetMarginRight();
wxCoord minYpx = w.GetMarginTop(); wxCoord minYpx = w.GetMarginTop();
wxCoord maxYpx = w.GetScrY() - w.GetMarginBottom(); wxCoord maxYpx = w.GetScrY() - w.GetMarginBottom();
// Draw line // Draw line
dc.DrawLine( orgx, minYpx, orgx, maxYpx ); dc.DrawLine( orgx, minYpx, orgx, maxYpx );
@ -1252,6 +1263,7 @@ void mpScaleY::Plot( wxDC& dc, mpWindow& w )
wxString fmt; wxString fmt;
int labelW = 0; int labelW = 0;
// Before staring cycle, calculate label height // Before staring cycle, calculate label height
int labelHeight = 0; int labelHeight = 0;
s.Printf( fmt, 0 ); s.Printf( fmt, 0 );
@ -1301,7 +1313,8 @@ void mpScaleY::Plot( wxDC& dc, mpWindow& w )
s = tickLabel.label; s = tickLabel.label;
dc.GetTextExtent( s, &tx, &ty ); dc.GetTextExtent( s, &tx, &ty );
if( m_flags == mpALIGN_BORDER_LEFT || m_flags == mpALIGN_RIGHT || m_flags == mpALIGN_FAR_RIGHT ) if( m_flags == mpALIGN_BORDER_LEFT || m_flags == mpALIGN_RIGHT
|| m_flags == mpALIGN_FAR_RIGHT )
dc.DrawText( s, orgx + 4, p - ty / 2 ); dc.DrawText( s, orgx + 4, p - ty / 2 );
else else
dc.DrawText( s, orgx - 4 - tx, p - ty / 2 ); // ( s, orgx+4, p-ty/2); dc.DrawText( s, orgx - 4 - tx, p - ty / 2 ); // ( s, orgx+4, p-ty/2);
@ -1309,7 +1322,6 @@ void mpScaleY::Plot( wxDC& dc, mpWindow& w )
} }
// Draw axis name // Draw axis name
dc.GetTextExtent( m_name, &tx, &ty ); dc.GetTextExtent( m_name, &tx, &ty );
switch( m_nameFlags ) switch( m_nameFlags )
@ -1368,21 +1380,26 @@ EVT_MENU( mpID_ZOOM_UNDO, mpWindow::onZoomUndo )
EVT_MENU( mpID_ZOOM_REDO, mpWindow::onZoomRedo ) EVT_MENU( mpID_ZOOM_REDO, mpWindow::onZoomRedo )
END_EVENT_TABLE() END_EVENT_TABLE()
mpWindow::mpWindow() : mpWindow( DelegatingContructorTag() ) mpWindow::mpWindow() : mpWindow( DelegatingContructorTag() )
{ {
initializeGraphicsContext(); initializeGraphicsContext();
} }
mpWindow::mpWindow( wxWindow* parent, wxWindowID id ) : mpWindow::mpWindow( wxWindow* parent, wxWindowID id ) :
mpWindow( DelegatingContructorTag(), parent, id, wxDefaultPosition, wxDefaultSize, 0, mpWindow( DelegatingContructorTag(), parent, id, wxDefaultPosition, wxDefaultSize, 0,
wxT( "mathplot" ) ) wxT( "mathplot" ) )
{ {
m_popmenu.Append( mpID_ZOOM_UNDO, _( "Undo Last Zoom" ), _( "Return zoom to level prior to last zoom action" ) ); m_popmenu.Append( mpID_ZOOM_UNDO, _( "Undo Last Zoom" ),
m_popmenu.Append( mpID_ZOOM_REDO, _( "Redo Last Zoom" ), _( "Return zoom to level prior to last zoom undo" ) ); _( "Return zoom to level prior to last zoom action" ) );
m_popmenu.Append( mpID_ZOOM_REDO, _( "Redo Last Zoom" ),
_( "Return zoom to level prior to last zoom undo" ) );
m_popmenu.AppendSeparator(); m_popmenu.AppendSeparator();
m_popmenu.Append( mpID_ZOOM_IN, _( "Zoom In" ), _( "Zoom in plot view." ) ); m_popmenu.Append( mpID_ZOOM_IN, _( "Zoom In" ), _( "Zoom in plot view." ) );
m_popmenu.Append( mpID_ZOOM_OUT, _( "Zoom Out" ), _( "Zoom out plot view." ) ); m_popmenu.Append( mpID_ZOOM_OUT, _( "Zoom Out" ), _( "Zoom out plot view." ) );
m_popmenu.Append( mpID_CENTER, _( "Center on Cursor" ), _( "Center plot view to this position" ) ); m_popmenu.Append( mpID_CENTER, _( "Center on Cursor" ),
_( "Center plot view to this position" ) );
m_popmenu.Append( mpID_FIT, _( "Fit on Screen" ), _( "Set plot view to show all items" ) ); m_popmenu.Append( mpID_FIT, _( "Fit on Screen" ), _( "Set plot view to show all items" ) );
m_layers.clear(); m_layers.clear();
@ -1410,7 +1427,8 @@ mpWindow::~mpWindow()
} }
// Mouse handler, for detecting when the user drag with the right button or just "clicks" for the menu // Mouse handler, for detecting when the user drag with the right button or just "clicks" for
// the menu.
// JLB // JLB
void mpWindow::OnMouseMiddleDown( wxMouseEvent& event ) void mpWindow::OnMouseMiddleDown( wxMouseEvent& event )
{ {
@ -1802,6 +1820,7 @@ void mpWindow::ZoomOut( const wxPoint& centerPoint, double zoomFactor, wxOrienta
{ {
if( zoomFactor == 0 ) if( zoomFactor == 0 )
zoomFactor = 1.0; zoomFactor = 1.0;
DoZoom( centerPoint, 1.0 / zoomFactor, directions ); DoZoom( centerPoint, 1.0 / zoomFactor, directions );
} }
@ -1844,13 +1863,14 @@ void mpWindow::ZoomRect( wxPoint p0, wxPoint p1 )
Fit( zoom_x_min, zoom_x_max, zoom_y_min, zoom_y_max ); Fit( zoom_x_min, zoom_x_max, zoom_y_min, zoom_y_max );
// Even with the input rectangle contrained to the plot area, it's still possible for the // Even with the input rectangle constrained to the plot area, it's still possible for the
// resulting view to exceed limits when a portion of the gap is grabbed. // resulting view to exceed limits when a portion of the gap is grabbed.
AdjustLimitedView(); AdjustLimitedView();
// These additional checks are needed because AdjustLimitedView only adjusts the position // These additional checks are needed because AdjustLimitedView only adjusts the position
// and not the scale. // and not the scale.
wxOrientation directionsNeedingRefitting = ViewNeedsRefitting( wxBOTH ); wxOrientation directionsNeedingRefitting = ViewNeedsRefitting( wxBOTH );
if( directionsNeedingRefitting != 0 ) if( directionsNeedingRefitting != 0 )
Fit( m_minX, m_maxX, m_minY, m_maxY, nullptr, nullptr, directionsNeedingRefitting ); Fit( m_minX, m_maxX, m_minY, m_maxY, nullptr, nullptr, directionsNeedingRefitting );
} }
@ -2081,12 +2101,14 @@ void mpWindow::OnPaint( wxPaintEvent& WXUNUSED( event ) )
paintDC.Blit( 0, 0, m_scrX, m_scrY, targetDC, 0, 0 ); paintDC.Blit( 0, 0, m_scrX, m_scrY, targetDC, 0, 0 );
} }
void mpWindow::DoZoom( const wxPoint& centerPoint, double zoomFactor, wxOrientation directions ) void mpWindow::DoZoom( const wxPoint& centerPoint, double zoomFactor, wxOrientation directions )
{ {
if( m_yLocked ) if( m_yLocked )
{ {
if( directions == wxVERTICAL ) if( directions == wxVERTICAL )
return; return;
directions = wxHORIZONTAL; directions = wxHORIZONTAL;
} }
@ -2244,6 +2266,7 @@ void mpWindow::PerformMouseWheelAction( wxMouseEvent& event, MouseWheelAction ac
m_desiredYmin + changeUnitsY ); m_desiredYmin + changeUnitsY );
UpdateAll(); UpdateAll();
} }
break; break;
case MouseWheelAction::ZOOM: case MouseWheelAction::ZOOM:
@ -2251,6 +2274,7 @@ void mpWindow::PerformMouseWheelAction( wxMouseEvent& event, MouseWheelAction ac
ZoomIn( clickPt ); ZoomIn( clickPt );
else else
ZoomOut( clickPt ); ZoomOut( clickPt );
break; break;
case MouseWheelAction::ZOOM_HORIZONTALLY: case MouseWheelAction::ZOOM_HORIZONTALLY:
@ -2258,6 +2282,7 @@ void mpWindow::PerformMouseWheelAction( wxMouseEvent& event, MouseWheelAction ac
ZoomIn( clickPt, zoomIncrementalFactor, wxHORIZONTAL ); ZoomIn( clickPt, zoomIncrementalFactor, wxHORIZONTAL );
else else
ZoomOut( clickPt, zoomIncrementalFactor, wxHORIZONTAL ); ZoomOut( clickPt, zoomIncrementalFactor, wxHORIZONTAL );
break; break;
case MouseWheelAction::ZOOM_VERTICALLY: case MouseWheelAction::ZOOM_VERTICALLY:
@ -2265,9 +2290,11 @@ void mpWindow::PerformMouseWheelAction( wxMouseEvent& event, MouseWheelAction ac
ZoomIn( clickPt, zoomIncrementalFactor, wxVERTICAL ); ZoomIn( clickPt, zoomIncrementalFactor, wxVERTICAL );
else else
ZoomOut( clickPt, zoomIncrementalFactor, wxVERTICAL ); ZoomOut( clickPt, zoomIncrementalFactor, wxVERTICAL );
break; break;
default: break; default:
break;
} }
} }
@ -2460,14 +2487,16 @@ void mpWindow::SetColourTheme( const wxColour& bgColour, const wxColour& drawCol
{ {
if( layer->GetLayerType() == mpLAYER_AXIS ) if( layer->GetLayerType() == mpLAYER_AXIS )
{ {
wxPen axisPen = layer->GetPen(); // Get the old pen to modify only colour, not style or width // Get the old pen to modify only colour, not style or width.
wxPen axisPen = layer->GetPen();
axisPen.SetColour( axesColour ); axisPen.SetColour( axesColour );
layer->SetPen( axisPen ); layer->SetPen( axisPen );
} }
if( layer->GetLayerType() == mpLAYER_INFO ) if( layer->GetLayerType() == mpLAYER_INFO )
{ {
wxPen infoPen = layer->GetPen(); // Get the old pen to modify only colour, not style or width // Get the old pen to modify only colour, not style or width.
wxPen infoPen = layer->GetPen();
infoPen.SetColour( drawColour ); infoPen.SetColour( drawColour );
layer->SetPen( infoPen ); layer->SetPen( infoPen );
} }
@ -2534,7 +2563,7 @@ void mpWindow::initializeGraphicsContext()
IMPLEMENT_DYNAMIC_CLASS( mpFXYVector, mpFXY ) IMPLEMENT_DYNAMIC_CLASS( mpFXYVector, mpFXY )
// Constructor
mpFXYVector::mpFXYVector( const wxString& name, int flags ) : mpFXYVector::mpFXYVector( const wxString& name, int flags ) :
mpFXY( name, flags ) mpFXY( name, flags )
{ {

View File

@ -122,6 +122,7 @@ void NUMBER_BADGE::SetTextSize( int aSize )
#define PLATFORM_FUDGE_Y 1.0 #define PLATFORM_FUDGE_Y 1.0
#endif #endif
void NUMBER_BADGE::computeSize() void NUMBER_BADGE::computeSize()
{ {
wxClientDC dc( this ); wxClientDC dc( this );
@ -182,5 +183,6 @@ void NUMBER_BADGE::onPaint( wxPaintEvent& aEvt )
dc.SetFont( wxFont( m_textSize, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, BADGE_FONTWEIGHT ) ); dc.SetFont( wxFont( m_textSize, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, BADGE_FONTWEIGHT ) );
dc.SetTextForeground( m_textColour ); dc.SetTextForeground( m_textColour );
dc.DrawLabel( text, wxRect( wxPoint( 0, 0 ), clientSize ), wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL ); dc.DrawLabel( text, wxRect( wxPoint( 0, 0 ), clientSize ),
wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL );
} }

View File

@ -45,8 +45,9 @@ std::map<wxString, wxString> g_lastPage;
std::map<wxString, wxString> g_lastParentPage; std::map<wxString, wxString> g_lastParentPage;
PAGED_DIALOG::PAGED_DIALOG( wxWindow* aParent, const wxString& aTitle, bool aShowReset, bool aShowOpenFolder, PAGED_DIALOG::PAGED_DIALOG( wxWindow* aParent, const wxString& aTitle, bool aShowReset,
const wxString& aAuxiliaryAction, const wxSize& aInitialSize ) : bool aShowOpenFolder, const wxString& aAuxiliaryAction,
const wxSize& aInitialSize ) :
DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, aInitialSize, DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, aInitialSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
m_auxiliaryButton( nullptr ), m_auxiliaryButton( nullptr ),
@ -92,7 +93,8 @@ PAGED_DIALOG::PAGED_DIALOG( wxWindow* aParent, const wxString& aTitle, bool aSho
#else #else
m_openPrefsDirButton = new wxButton( this, wxID_ANY, _( "Open Preferences Directory" ) ); m_openPrefsDirButton = new wxButton( this, wxID_ANY, _( "Open Preferences Directory" ) );
#endif #endif
m_buttonsSizer->Add( m_openPrefsDirButton, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxLEFT, 5 ); m_buttonsSizer->Add( m_openPrefsDirButton, 0,
wxALIGN_CENTER_VERTICAL | wxRIGHT | wxLEFT, 5 );
} }
@ -134,7 +136,8 @@ PAGED_DIALOG::PAGED_DIALOG( wxWindow* aParent, const wxString& aTitle, bool aSho
if( m_openPrefsDirButton ) if( m_openPrefsDirButton )
{ {
m_openPrefsDirButton->Bind( wxEVT_COMMAND_BUTTON_CLICKED, &PAGED_DIALOG::onOpenPreferencesButton, this ); m_openPrefsDirButton->Bind( wxEVT_COMMAND_BUTTON_CLICKED,
&PAGED_DIALOG::onOpenPreferencesButton, this );
} }
m_treebook->Bind( wxEVT_CHAR_HOOK, &PAGED_DIALOG::onCharHook, this ); m_treebook->Bind( wxEVT_CHAR_HOOK, &PAGED_DIALOG::onCharHook, this );
@ -204,7 +207,8 @@ PAGED_DIALOG::~PAGED_DIALOG()
if( m_openPrefsDirButton ) if( m_openPrefsDirButton )
{ {
m_openPrefsDirButton->Unbind( wxEVT_COMMAND_BUTTON_CLICKED, &PAGED_DIALOG::onOpenPreferencesButton, this ); m_openPrefsDirButton->Unbind( wxEVT_COMMAND_BUTTON_CLICKED,
&PAGED_DIALOG::onOpenPreferencesButton, this );
} }
m_treebook->Unbind( wxEVT_CHAR_HOOK, &PAGED_DIALOG::onCharHook, this ); m_treebook->Unbind( wxEVT_CHAR_HOOK, &PAGED_DIALOG::onCharHook, this );

View File

@ -121,8 +121,10 @@ PROPERTIES_PANEL::PROPERTIES_PANEL( wxWindow* aParent, EDA_BASE_FRAME* aFrame )
m_grid->CenterSplitter(); m_grid->CenterSplitter();
Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( PROPERTIES_PANEL::onCharHook ), nullptr, this ); Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( PROPERTIES_PANEL::onCharHook ), nullptr, this );
Connect( wxEVT_PG_CHANGED, wxPropertyGridEventHandler( PROPERTIES_PANEL::valueChanged ), nullptr, this ); Connect( wxEVT_PG_CHANGED, wxPropertyGridEventHandler( PROPERTIES_PANEL::valueChanged ),
Connect( wxEVT_PG_CHANGING, wxPropertyGridEventHandler( PROPERTIES_PANEL::valueChanging ), nullptr, this ); nullptr, this );
Connect( wxEVT_PG_CHANGING, wxPropertyGridEventHandler( PROPERTIES_PANEL::valueChanging ),
nullptr, this );
Connect( wxEVT_SHOW, wxShowEventHandler( PROPERTIES_PANEL::onShow ), nullptr, this ); Connect( wxEVT_SHOW, wxShowEventHandler( PROPERTIES_PANEL::onShow ), nullptr, this );
Bind( wxEVT_PG_COL_END_DRAG, Bind( wxEVT_PG_COL_END_DRAG,
@ -205,7 +207,8 @@ void PROPERTIES_PANEL::rebuildProperties( const SELECTION& aSelection )
std::set<PROPERTY_BASE*> commonProps; std::set<PROPERTY_BASE*> commonProps;
const PROPERTY_LIST& allProperties = propMgr.GetProperties( *types.begin() ); const PROPERTY_LIST& allProperties = propMgr.GetProperties( *types.begin() );
copy( allProperties.begin(), allProperties.end(), inserter( commonProps, commonProps.begin() ) ); copy( allProperties.begin(), allProperties.end(),
inserter( commonProps, commonProps.begin() ) );
PROPERTY_DISPLAY_ORDER displayOrder = propMgr.GetDisplayOrder( *types.begin() ); PROPERTY_DISPLAY_ORDER displayOrder = propMgr.GetDisplayOrder( *types.begin() );

View File

@ -163,6 +163,7 @@ void SEARCH_PANE_LISTVIEW::OnChar( wxKeyEvent& aEvent )
if( wxTheClipboard->Open() ) if( wxTheClipboard->Open() )
{ {
wxString txt; wxString txt;
for( int row = 0; row < GetItemCount(); row++ ) for( int row = 0; row < GetItemCount(); row++ )
{ {
if( GetItemState( row, wxLIST_STATE_SELECTED ) == wxLIST_STATE_SELECTED ) if( GetItemState( row, wxLIST_STATE_SELECTED ) == wxLIST_STATE_SELECTED )
@ -172,10 +173,12 @@ void SEARCH_PANE_LISTVIEW::OnChar( wxKeyEvent& aEvent )
if( GetColumnWidth( col ) > 0 ) if( GetColumnWidth( col ) > 0 )
{ {
txt += GetItemText( row, col ); txt += GetItemText( row, col );
if( row <= GetItemCount() - 1 ) if( row <= GetItemCount() - 1 )
txt += wxT( "\t" ); txt += wxT( "\t" );
} }
} }
txt += wxT( "\n" ); txt += wxT( "\n" );
} }
} }

View File

@ -35,7 +35,8 @@
SPLIT_BUTTON::SPLIT_BUTTON( wxWindow* aParent, wxWindowID aId, const wxString& aLabel, SPLIT_BUTTON::SPLIT_BUTTON( wxWindow* aParent, wxWindowID aId, const wxString& aLabel,
const wxPoint& aPos, const wxSize& aSize ) : const wxPoint& aPos, const wxSize& aSize ) :
wxPanel( aParent, aId, aPos, aSize, wxBORDER_NONE | wxTAB_TRAVERSAL, wxS( "DropDownButton" ) ), wxPanel( aParent, aId, aPos, aSize, wxBORDER_NONE | wxTAB_TRAVERSAL,
wxS( "DropDownButton" ) ),
m_label( aLabel ) m_label( aLabel )
{ {
m_arrowButtonWidth = FromDIP( 20 ); // just a fixed eyeballed constant width m_arrowButtonWidth = FromDIP( 20 ); // just a fixed eyeballed constant width
@ -274,6 +275,7 @@ void SPLIT_BUTTON::OnPaint( wxPaintEvent& WXUNUSED( aEvent ) )
// wxRendereNative doesn't handle dark mode on OSX. // wxRendereNative doesn't handle dark mode on OSX.
drawBackground( r1 ); drawBackground( r1 );
#else #else
#ifdef _WXMSW_ #ifdef _WXMSW_
r1.width += 2; r1.width += 2;
#endif #endif

View File

@ -42,6 +42,7 @@ STD_BITMAP_BUTTON::STD_BITMAP_BUTTON( wxWindow* aParent, wxWindowID aId,
if( aSize == wxDefaultSize ) if( aSize == wxDefaultSize )
{ {
wxSize defaultSize = wxButton::GetDefaultSize( aParent ); wxSize defaultSize = wxButton::GetDefaultSize( aParent );
#ifndef __WXMSW__ #ifndef __WXMSW__
defaultSize.IncBy( 1 ); defaultSize.IncBy( 1 );
#endif #endif
@ -153,7 +154,7 @@ void STD_BITMAP_BUTTON::OnLeftButtonUp( wxMouseEvent& aEvent )
Refresh(); Refresh();
wxEvtHandler* pEventHandler = GetEventHandler(); wxEvtHandler* pEventHandler = GetEventHandler();
wxASSERT( pEventHandler ); wxCHECK( pEventHandler, /* void */ );
pEventHandler->CallAfter( pEventHandler->CallAfter(
[this]() [this]()
@ -225,6 +226,7 @@ void STD_BITMAP_BUTTON::OnPaint( wxPaintEvent& WXUNUSED( aEvent ) )
// wxRendereNative doesn't handle dark mode on OSX. // wxRendereNative doesn't handle dark mode on OSX.
drawBackground( r1 ); drawBackground( r1 );
#else #else
#ifdef __WXMSW__ #ifdef __WXMSW__
r1.width += 1; r1.width += 1;
#endif #endif

View File

@ -79,11 +79,14 @@ void STEPPED_SLIDER::OnScroll( wxScrollEvent& aEvent )
if( aEvent.GetEventType() == wxEVT_SCROLL_CHANGED ) if( aEvent.GetEventType() == wxEVT_SCROLL_CHANGED )
{ {
#endif // __WXMSW__ #endif // __WXMSW__
const int value = GetValue(); const int value = GetValue();
const int rounded = value - value % m_step; const int rounded = value - value % m_step;
SetValue( rounded ); SetValue( rounded );
#ifdef __WXMSW__ #ifdef __WXMSW__
} }
#endif // __WXMSW__ #endif // __WXMSW__
aEvent.Skip(); aEvent.Skip();
} }

View File

@ -118,6 +118,7 @@ wxFont getGUIFont( wxWindow* aWindow, int aRelativeSize )
// https://trac.wxwidgets.org/ticket/19210 // https://trac.wxwidgets.org/ticket/19210
if( font.GetFaceName().IsEmpty() ) if( font.GetFaceName().IsEmpty() )
font.SetFaceName( wxS( "San Francisco" ) ); font.SetFaceName( wxS( "San Francisco" ) );
// OSX 10.1 .. 10.9: Lucida Grande // OSX 10.1 .. 10.9: Lucida Grande
// OSX 10.10: Helvetica Neue // OSX 10.10: Helvetica Neue
// OSX 10.11 .. : San Francisco // OSX 10.11 .. : San Francisco
@ -310,7 +311,8 @@ bool KIUI::IsInputControlEditable( wxWindow* aFocus )
else if( searchCtrl ) else if( searchCtrl )
return searchCtrl->IsEditable(); return searchCtrl->IsEditable();
return true; // Must return true if we can't determine the state, intentionally true for non inputs as well // Must return true if we can't determine the state, intentionally true for non inputs as well.
return true;
} }

View File

@ -561,6 +561,7 @@ double UNIT_BINDER::setPrecision( double aValue, bool aValueUsesUserUnits ) cons
{ {
int scale = pow( 10, m_precision ); int scale = pow( 10, m_precision );
int64_t tmp = aValue; int64_t tmp = aValue;
if( !aValueUsesUserUnits ) if( !aValueUsesUserUnits )
{ {
tmp = EDA_UNIT_UTILS::UI::ToUserUnit( *m_iuScale, m_units, aValue ) * scale; tmp = EDA_UNIT_UTILS::UI::ToUserUnit( *m_iuScale, m_units, aValue ) * scale;

View File

@ -105,13 +105,15 @@ public:
mainSizer->Add( new wxStaticLine( this ), 0, wxALL | wxEXPAND, 2 ); mainSizer->Add( new wxStaticLine( this ), 0, wxALL | wxEXPAND, 2 );
wxPanel* panelDisplayCurrent = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize ); wxPanel* panelDisplayCurrent = new wxPanel( this, wxID_ANY, wxDefaultPosition,
wxDefaultSize );
mainSizer->Add( panelDisplayCurrent, 0, wxALL | wxEXPAND, 5 ); mainSizer->Add( panelDisplayCurrent, 0, wxALL | wxEXPAND, 5 );
wxFlexGridSizer* fgsizer = new wxFlexGridSizer( 2 ); wxFlexGridSizer* fgsizer = new wxFlexGridSizer( 2 );
panelDisplayCurrent->SetSizer( fgsizer ); panelDisplayCurrent->SetSizer( fgsizer );
wxStaticText* cmd_label_0 = new wxStaticText( panelDisplayCurrent, wxID_ANY, _( "Command:" ) ); wxStaticText* cmd_label_0 = new wxStaticText( panelDisplayCurrent, wxID_ANY,
_( "Command:" ) );
fgsizer->Add( cmd_label_0, 0, wxALL | wxALIGN_CENTRE_VERTICAL, 5 ); fgsizer->Add( cmd_label_0, 0, wxALL | wxALIGN_CENTRE_VERTICAL, 5 );
wxStaticText* cmd_label_1 = new wxStaticText( panelDisplayCurrent, wxID_ANY, wxEmptyString ); wxStaticText* cmd_label_1 = new wxStaticText( panelDisplayCurrent, wxID_ANY, wxEmptyString );
@ -119,7 +121,8 @@ public:
cmd_label_1->SetLabel( aName ); cmd_label_1->SetLabel( aName );
fgsizer->Add( cmd_label_1, 0, wxALL | wxALIGN_CENTRE_VERTICAL, 5 ); fgsizer->Add( cmd_label_1, 0, wxALL | wxALIGN_CENTRE_VERTICAL, 5 );
wxStaticText* key_label_0 = new wxStaticText( panelDisplayCurrent, wxID_ANY, _( "Current key:" ) ); wxStaticText* key_label_0 = new wxStaticText( panelDisplayCurrent, wxID_ANY,
_( "Current key:" ) );
fgsizer->Add( key_label_0, 0, wxALL | wxALIGN_CENTRE_VERTICAL, 5 ); fgsizer->Add( key_label_0, 0, wxALL | wxALIGN_CENTRE_VERTICAL, 5 );
wxStaticText* key_label_1 = new wxStaticText( panelDisplayCurrent, wxID_ANY, wxEmptyString ); wxStaticText* key_label_1 = new wxStaticText( panelDisplayCurrent, wxID_ANY, wxEmptyString );
@ -129,7 +132,8 @@ public:
fgsizer->AddStretchSpacer(); fgsizer->AddStretchSpacer();
wxButton* resetButton = new wxButton( this, wxID_ANY, _( "Clear assigned hotkey" ), wxDefaultPosition, wxDefaultSize, 0 ); wxButton* resetButton = new wxButton( this, wxID_ANY, _( "Clear assigned hotkey" ),
wxDefaultPosition, wxDefaultSize, 0 );
mainSizer->Add( resetButton, 0, wxALL | wxALIGN_CENTRE_HORIZONTAL, 5 ); mainSizer->Add( resetButton, 0, wxALL | wxALIGN_CENTRE_HORIZONTAL, 5 );
@ -158,7 +162,9 @@ public:
if( dialog.ShowModal() == wxID_OK ) if( dialog.ShowModal() == wxID_OK )
{ {
if( dialog.m_resetkey ) if( dialog.m_resetkey )
{
return std::make_optional( 0 ); return std::make_optional( 0 );
}
else else
{ {
long key = WIDGET_HOTKEY_LIST::MapKeypressToKeycode( dialog.m_event ); long key = WIDGET_HOTKEY_LIST::MapKeypressToKeycode( dialog.m_event );
@ -365,8 +371,8 @@ void WIDGET_HOTKEY_LIST::editItem( wxTreeListItem aItem, int aEditId )
return; return;
wxString name = GetItemText( aItem, 0 ); wxString name = GetItemText( aItem, 0 );
wxString current_key = wxString current_key = aEditId == ID_EDIT_HOTKEY ? GetItemText( aItem, 1 )
aEditId == ID_EDIT_HOTKEY ? GetItemText( aItem, 1 ) : GetItemText( aItem, 2 ); : GetItemText( aItem, 2 );
std::optional<long> key = HK_PROMPT_DIALOG::PromptForKey( this, name, current_key ); std::optional<long> key = HK_PROMPT_DIALOG::PromptForKey( this, name, current_key );
@ -406,9 +412,13 @@ void WIDGET_HOTKEY_LIST::resetItem( wxTreeListItem aItem, int aResetId )
changeHotkey( changed_hk, changed_hk.m_Actions[0]->GetHotKey(), true ); changeHotkey( changed_hk, changed_hk.m_Actions[0]->GetHotKey(), true );
} }
else if( aResetId == ID_CLEAR ) else if( aResetId == ID_CLEAR )
{
changeHotkey( changed_hk, 0, false ); changeHotkey( changed_hk, 0, false );
}
else if( aResetId == ID_CLEAR_ALT ) else if( aResetId == ID_CLEAR_ALT )
{
changeHotkey( changed_hk, 0, true ); changeHotkey( changed_hk, 0, true );
}
else if( aResetId == ID_DEFAULT ) else if( aResetId == ID_DEFAULT )
{ {
changeHotkey( changed_hk, changed_hk.m_Actions[0]->GetDefaultHotKey(), false ); changeHotkey( changed_hk, changed_hk.m_Actions[0]->GetDefaultHotKey(), false );

View File

@ -395,7 +395,8 @@ void WX_COLLAPSIBLE_PANE_HEADER::onChar( wxKeyEvent& aEvent )
void WX_COLLAPSIBLE_PANE_HEADER::drawArrow( wxDC& aDC, wxRect aRect, bool aIsActive ) void WX_COLLAPSIBLE_PANE_HEADER::drawArrow( wxDC& aDC, wxRect aRect, bool aIsActive )
{ {
// The bottom corner of the triangle is located halfway across the area and 3/4 down from the top // The bottom corner of the triangle is located halfway across the area and 3/4 down from
// the top
wxPoint btmCorner( aRect.GetWidth() / 2, 3 * aRect.GetHeight() / 4 ); wxPoint btmCorner( aRect.GetWidth() / 2, 3 * aRect.GetHeight() / 4 );
// The right corner of the triangle is located halfway down from the top and 3/4 across the area // The right corner of the triangle is located halfway down from the top and 3/4 across the area

View File

@ -76,7 +76,8 @@ wxGridCellAttr* WX_GRID_TABLE_BASE::enhanceAttr( wxGridCellAttr* aInputAttr, int
void WX_GRID::CellEditorSetMargins( wxTextEntryBase* aEntry ) void WX_GRID::CellEditorSetMargins( wxTextEntryBase* aEntry )
{ {
// This is consistent with wxGridCellTextEditor. But works differently across platforms or course. // This is consistent with wxGridCellTextEditor. But works differently across platforms or
// course.
aEntry->SetMargins( 0, 0 ); aEntry->SetMargins( 0, 0 );
} }
@ -150,8 +151,8 @@ public:
/** /**
* Attribute provider that provides attributes (or modifies the existing attribute) to alternate a row color * Attribute provider that provides attributes (or modifies the existing attribute) to alternate
* between the odd and even rows. * a row color between the odd and even rows.
*/ */
class WX_GRID_ALT_ROW_COLOR_PROVIDER : public wxGridCellAttrProvider class WX_GRID_ALT_ROW_COLOR_PROVIDER : public wxGridCellAttrProvider
{ {
@ -177,7 +178,8 @@ public:
{ {
wxGridCellAttrPtr cellAttr( wxGridCellAttrProvider::GetAttr( row, col, kind ) ); wxGridCellAttrPtr cellAttr( wxGridCellAttrProvider::GetAttr( row, col, kind ) );
// Just pass through the cell attribute on odd rows (start normal to allow for the header row) // Just pass through the cell attribute on odd rows (start normal to allow for the
// header row)
if( !( row % 2 ) ) if( !( row % 2 ) )
return cellAttr.release(); return cellAttr.release();
@ -214,8 +216,10 @@ WX_GRID::WX_GRID( wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxS
SetLabelFont( KIUI::GetControlFont( this ) ); SetLabelFont( KIUI::GetControlFont( this ) );
Connect( wxEVT_DPI_CHANGED, wxDPIChangedEventHandler( WX_GRID::onDPIChanged ), nullptr, this ); Connect( wxEVT_DPI_CHANGED, wxDPIChangedEventHandler( WX_GRID::onDPIChanged ), nullptr, this );
Connect( wxEVT_GRID_EDITOR_SHOWN, wxGridEventHandler( WX_GRID::onCellEditorShown ), nullptr, this ); Connect( wxEVT_GRID_EDITOR_SHOWN, wxGridEventHandler( WX_GRID::onCellEditorShown ), nullptr,
Connect( wxEVT_GRID_EDITOR_HIDDEN, wxGridEventHandler( WX_GRID::onCellEditorHidden ), nullptr, this ); this );
Connect( wxEVT_GRID_EDITOR_HIDDEN, wxGridEventHandler( WX_GRID::onCellEditorHidden ), nullptr,
this );
} }
@ -224,9 +228,12 @@ WX_GRID::~WX_GRID()
if( m_weOwnTable ) if( m_weOwnTable )
DestroyTable( GetTable() ); DestroyTable( GetTable() );
Disconnect( wxEVT_GRID_EDITOR_SHOWN, wxGridEventHandler( WX_GRID::onCellEditorShown ), nullptr, this ); Disconnect( wxEVT_GRID_EDITOR_SHOWN, wxGridEventHandler( WX_GRID::onCellEditorShown ), nullptr,
Disconnect( wxEVT_GRID_EDITOR_HIDDEN, wxGridEventHandler( WX_GRID::onCellEditorHidden ), nullptr, this ); this );
Disconnect( wxEVT_DPI_CHANGED, wxDPIChangedEventHandler( WX_GRID::onDPIChanged ), nullptr, this ); Disconnect( wxEVT_GRID_EDITOR_HIDDEN, wxGridEventHandler( WX_GRID::onCellEditorHidden ),
nullptr, this );
Disconnect( wxEVT_DPI_CHANGED, wxDPIChangedEventHandler( WX_GRID::onDPIChanged ), nullptr,
this );
} }
@ -238,8 +245,8 @@ void WX_GRID::onDPIChanged(wxDPIChangedEvent& aEvt)
wxGrid::SetColLabelSize( wxGRID_AUTOSIZE ); wxGrid::SetColLabelSize( wxGRID_AUTOSIZE );
} ); } );
/// This terrible hack is a way to avoid the incredibly disruptive resizing of grids that happens on Macs /// This terrible hack is a way to avoid the incredibly disruptive resizing of grids that
/// when moving a window between monitors of different DPIs. /// happens on Macs when moving a window between monitors of different DPIs.
#ifndef __WXMAC__ #ifndef __WXMAC__
aEvt.Skip(); aEvt.Skip();
#endif #endif
@ -296,7 +303,8 @@ void WX_GRID::SetTable( wxGridTableBase* aTable, bool aTakeOwnership )
EnableAlternateRowColors( Pgm().GetCommonSettings()->m_Appearance.grid_striping ); EnableAlternateRowColors( Pgm().GetCommonSettings()->m_Appearance.grid_striping );
Connect( wxEVT_GRID_COL_MOVE, wxGridEventHandler( WX_GRID::onGridColMove ), nullptr, this ); Connect( wxEVT_GRID_COL_MOVE, wxGridEventHandler( WX_GRID::onGridColMove ), nullptr, this );
Connect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( WX_GRID::onGridCellSelect ), nullptr, this ); Connect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( WX_GRID::onGridCellSelect ), nullptr,
this );
m_weOwnTable = aTakeOwnership; m_weOwnTable = aTakeOwnership;
} }
@ -447,7 +455,8 @@ void WX_GRID::DestroyTable( wxGridTableBase* aTable )
CommitPendingChanges( true /* quiet mode */ ); CommitPendingChanges( true /* quiet mode */ );
Disconnect( wxEVT_GRID_COL_MOVE, wxGridEventHandler( WX_GRID::onGridColMove ), nullptr, this ); Disconnect( wxEVT_GRID_COL_MOVE, wxGridEventHandler( WX_GRID::onGridColMove ), nullptr, this );
Disconnect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( WX_GRID::onGridCellSelect ), nullptr, this ); Disconnect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( WX_GRID::onGridCellSelect ), nullptr,
this );
wxGrid::SetTable( nullptr ); wxGrid::SetTable( nullptr );
delete aTable; delete aTable;
@ -789,7 +798,8 @@ int WX_GRID::GetVisibleWidth( int aCol, bool aHeader, bool aContents, bool aKeep
{ {
EnsureColLabelsVisible(); EnsureColLabelsVisible();
size = std::max( size, int( GetTextExtent( GetColLabelValue( aCol ) + wxS( "M" ) ).x ) ); size = std::max( size,
int( GetTextExtent( GetColLabelValue( aCol ) + wxS( "M" ) ).x ) );
} }
for( int row = 0; aContents && row < GetNumberRows(); row++ ) for( int row = 0; aContents && row < GetNumberRows(); row++ )

View File

@ -34,10 +34,12 @@ WX_GRID_AUTOSIZER::WX_GRID_AUTOSIZER( wxGrid& aGrid, COL_MIN_WIDTHS aAutosizedCo
m_flexibleCol( aFlexibleCol ) m_flexibleCol( aFlexibleCol )
{ {
const int colCount = m_grid.GetNumberCols(); const int colCount = m_grid.GetNumberCols();
for( const auto& [colIndex, width] : m_autosizedCols ) for( const auto& [colIndex, width] : m_autosizedCols )
{ {
wxASSERT_MSG( colIndex < colCount, "Autosized column does not exist in grid" ); wxASSERT_MSG( colIndex < colCount, "Autosized column does not exist in grid" );
} }
wxASSERT_MSG( m_flexibleCol < colCount, "Flexible column index does not exist in grid" ); wxASSERT_MSG( m_flexibleCol < colCount, "Flexible column index does not exist in grid" );
m_grid.Bind( wxEVT_UPDATE_UI, m_grid.Bind( wxEVT_UPDATE_UI,
@ -62,6 +64,7 @@ WX_GRID_AUTOSIZER::WX_GRID_AUTOSIZER( wxGrid& aGrid, COL_MIN_WIDTHS aAutosizedCo
} ); } );
} }
void WX_GRID_AUTOSIZER::recomputeGridWidths() void WX_GRID_AUTOSIZER::recomputeGridWidths()
{ {
if( m_gridWidthsDirty ) if( m_gridWidthsDirty )
@ -70,6 +73,7 @@ void WX_GRID_AUTOSIZER::recomputeGridWidths()
m_grid.GetClientRect().GetWidth() - wxSystemSettings::GetMetric( wxSYS_VSCROLL_X ); m_grid.GetClientRect().GetWidth() - wxSystemSettings::GetMetric( wxSYS_VSCROLL_X );
std::optional<int> flexibleMinWidth; std::optional<int> flexibleMinWidth;
for( const auto& [colIndex, minWidth] : m_autosizedCols ) for( const auto& [colIndex, minWidth] : m_autosizedCols )
{ {
m_grid.AutoSizeColumn( colIndex ); m_grid.AutoSizeColumn( colIndex );
@ -102,12 +106,15 @@ void WX_GRID_AUTOSIZER::recomputeGridWidths()
} }
} }
void WX_GRID_AUTOSIZER::onSizeEvent( wxSizeEvent& aEvent ) void WX_GRID_AUTOSIZER::onSizeEvent( wxSizeEvent& aEvent )
{ {
const int width = aEvent.GetSize().GetX(); const int width = aEvent.GetSize().GetX();
if( width != m_gridWidth ) if( width != m_gridWidth )
{ {
m_gridWidthsDirty = true; m_gridWidthsDirty = true;
} }
aEvent.Skip(); aEvent.Skip();
} }

View File

@ -103,6 +103,7 @@ REPORTER& WX_HTML_REPORT_BOX::Report( const wxString& aText, SEVERITY aSeverity
return *this; return *this;
} }
void WX_HTML_REPORT_BOX::Flush() void WX_HTML_REPORT_BOX::Flush()
{ {
wxString html; wxString html;

View File

@ -46,13 +46,15 @@ public:
/** /**
* In immediate mode, messages are flushed as they are added. * In immediate mode, messages are flushed as they are added.
*
* Required for progress-related reports, but can be very slow for larger reports. * Required for progress-related reports, but can be very slow for larger reports.
*/ */
void SetImmediateMode() { m_immediateMode = true; } void SetImmediateMode() { m_immediateMode = true; }
/** /**
* Build the HTML messages page. * Build the HTML messages page.
* Call it if the immediate mode is not activated to be able to display them *
* Call it if the immediate mode is not activated to be able to display them.
*/ */
void Flush(); void Flush();
@ -71,11 +73,11 @@ private:
private: private:
EDA_UNITS m_units; EDA_UNITS m_units;
///< Indicates messages should be flushed as they are added. Required for progress-related /// Indicates messages should be flushed as they are added. Required for progress-related
///< reports, but can be very slow for larger reports. /// reports, but can be very slow for larger reports.
bool m_immediateMode; bool m_immediateMode;
///< copy of the report, stored for filtering /// copy of the report, stored for filtering.
std::vector<wxString> m_messages; std::vector<wxString> m_messages;
}; };

View File

@ -193,7 +193,8 @@ wxString WX_HTML_REPORT_PANEL::generateHtml( const REPORT_LINE& aLine )
wxS( "<font size=3>" ) + aLine.message + wxS( "</font><br>" ); wxS( "<font size=3>" ) + aLine.message + wxS( "</font><br>" );
break; break;
case RPT_SEVERITY_WARNING: case RPT_SEVERITY_WARNING:
retv = wxS( "<font size=3>" ) + _( "Warning:" ) + wxS( " " ) + aLine.message + wxS( "</font><br>" ); retv = wxS( "<font size=3>" ) + _( "Warning:" ) + wxS( " " ) + aLine.message
+ wxS( "</font><br>" );
break; break;
case RPT_SEVERITY_INFO: case RPT_SEVERITY_INFO:
retv = wxS( "<font color=#909090 size=3>" ) + aLine.message + wxS( "</font><br>" ); retv = wxS( "<font color=#909090 size=3>" ) + aLine.message + wxS( "</font><br>" );
@ -214,7 +215,8 @@ wxString WX_HTML_REPORT_PANEL::generateHtml( const REPORT_LINE& aLine )
wxS( "<font size=3>" ) + aLine.message + wxS( "</font><br>" ); wxS( "<font size=3>" ) + aLine.message + wxS( "</font><br>" );
break; break;
case RPT_SEVERITY_WARNING: case RPT_SEVERITY_WARNING:
retv = wxS( "<font size=3>" ) + _( "Warning:" ) + wxS( " " ) + aLine.message + wxS( "</font><br>" ); retv = wxS( "<font size=3>" ) + _( "Warning:" ) + wxS( " " ) + aLine.message
+ wxS( "</font><br>" );
break; break;
case RPT_SEVERITY_INFO: case RPT_SEVERITY_INFO:
retv = wxS( "<font color=#808080 size=3>" ) + aLine.message + wxS( "</font><br>" ); retv = wxS( "<font color=#808080 size=3>" ) + aLine.message + wxS( "</font><br>" );

View File

@ -55,11 +55,10 @@ private:
}; };
/** /**
* A widget for browsing a rich text error/status report. Used in numerous * A widget for browsing a rich text error/status report.
* dialogs in eeschema and pcbnew. Provides error filtering functionality
* and saving report files.
* *
* The messages are reported through a REPORTER object * Used in numerous dialogs in Eeschema and Pcbnew. Provides error filtering functionality
* and saving report files. The messages are reported through a #REPORTER object
*/ */
class KICOMMON_API WX_HTML_REPORT_PANEL : public WX_HTML_REPORT_PANEL_BASE class KICOMMON_API WX_HTML_REPORT_PANEL : public WX_HTML_REPORT_PANEL_BASE
{ {
@ -69,55 +68,56 @@ public:
const wxSize& size = wxSize( 500,300 ), long style = wxTAB_TRAVERSAL ); const wxSize& size = wxSize( 500,300 ), long style = wxTAB_TRAVERSAL );
~WX_HTML_REPORT_PANEL(); ~WX_HTML_REPORT_PANEL();
///< Set the min size of the area which displays html messages: /// Set the min size of the area which displays html messages.
void MsgPanelSetMinSize( const wxSize& aMinSize ); void MsgPanelSetMinSize( const wxSize& aMinSize );
///< returns the reporter object that reports to this panel /// Return the reporter object that reports to this panel.
REPORTER& Reporter(); REPORTER& Reporter();
/** /**
* Reports the string * Report the string.
* @param aText string message to report *
* @param aSeverity string classification level bitfield * @param aText string message to report.
* @param aLocation REPORTER::LOCATION enum for placement of message * @param aSeverity string classification level bitfield.
* @param aLocation REPORTER::LOCATION enum for placement of message.
*/ */
void Report( const wxString& aText, SEVERITY aSeverity, void Report( const wxString& aText, SEVERITY aSeverity,
REPORTER::LOCATION aLocation = REPORTER::LOC_BODY ); REPORTER::LOCATION aLocation = REPORTER::LOC_BODY );
///< clears the report panel /// Clears the report panel.
void Clear(); void Clear();
///< return the number of messages matching the given severity mask. /// Return the number of messages matching the given severity mask.
int Count( int severityMask ); int Count( int severityMask );
///< sets the frame label /// Set the frame label.
void SetLabel( const wxString& aLabel ) override; void SetLabel( const wxString& aLabel ) override;
///< Sets the lazy update. If this mode is on, messages are stored but the display /// Set the lazy update. If this mode is on, messages are stored but the display
///< is not updated (Updating display can be very time consuming if there are many messages) /// is not updated (Updating display can be very time consuming if there are many messages)
///< A call to Flush() will be needed after build the report /// A call to Flush() will be needed after build the report
void SetLazyUpdate( bool aLazyUpdate ); void SetLazyUpdate( bool aLazyUpdate );
///< Forces updating the HTML page, after the report is built in lazy mode /// Force updating the HTML page, after the report is built in lazy mode
///< If aSort = true, the body messages will be ordered by severity /// If aSort = true, the body messages will be ordered by severity
void Flush( bool aSort = false ); void Flush( bool aSort = false );
///< Set the visible severity filter. /// Set the visible severity filter.
///< if aSeverities < 0 the m_showAll option is set /// if aSeverities < 0 the m_showAll option is set
void SetVisibleSeverities( int aSeverities ); void SetVisibleSeverities( int aSeverities );
///< @return the visible severity filter. /// @return the visible severity filter.
///< If the m_showAll option is set, the mask is < 0 /// If the m_showAll option is set, the mask is < 0
int GetVisibleSeverities() const; int GetVisibleSeverities() const;
///< @return the visible severity filter. /// @return the visible severity filter.
///< If the m_showAll option is set, the mask is < 0 /// If the m_showAll option is set, the mask is < 0
void SetShowSeverity( SEVERITY aSeverity, bool aValue ); void SetShowSeverity( SEVERITY aSeverity, bool aValue );
///< Set the report full file name to the string /// Set the report full file name to the string.
void SetFileName( const wxString& aReportFileName ); void SetFileName( const wxString& aReportFileName );
///< @return reference to the current report fill file name string. /// @return reference to the current report fill file name string.
wxString& GetFileName( void ); wxString& GetFileName( void );

View File

@ -63,8 +63,8 @@ WX_INFOBAR::WX_INFOBAR( wxWindow* aParent, wxAuiManager* aMgr, wxWindowID aWinid
KIPLATFORM::UI::GetInfoBarColours( fg, bg ); KIPLATFORM::UI::GetInfoBarColours( fg, bg );
SetBackgroundColour( bg ); SetBackgroundColour( bg );
SetForegroundColour( fg ); SetForegroundColour( fg );
#ifdef __WXMAC__
#ifdef __WXMAC__
// Infobar is broken on Mac without the effects // Infobar is broken on Mac without the effects
SetShowHideEffects( wxSHOW_EFFECT_ROLL_TO_BOTTOM, wxSHOW_EFFECT_ROLL_TO_TOP ); SetShowHideEffects( wxSHOW_EFFECT_ROLL_TO_BOTTOM, wxSHOW_EFFECT_ROLL_TO_TOP );
SetEffectDuration( 200 ); SetEffectDuration( 200 );
@ -73,7 +73,6 @@ WX_INFOBAR::WX_INFOBAR( wxWindow* aParent, wxAuiManager* aMgr, wxWindowID aWinid
SetShowHideEffects( wxSHOW_EFFECT_NONE, wxSHOW_EFFECT_NONE ); SetShowHideEffects( wxSHOW_EFFECT_NONE, wxSHOW_EFFECT_NONE );
#endif #endif
// The infobar seems to start too small, so increase its height // The infobar seems to start too small, so increase its height
int sx, sy; int sx, sy;
GetSize( &sx, &sy ); GetSize( &sx, &sy );
@ -287,6 +286,7 @@ void WX_INFOBAR::AddButton( wxButton* aButton )
// smaller buttons look better in the (narrow) info bar under OS X // smaller buttons look better in the (narrow) info bar under OS X
aButton->SetWindowVariant( wxWINDOW_VARIANT_SMALL ); aButton->SetWindowVariant( wxWINDOW_VARIANT_SMALL );
#endif // __WXMAC__ #endif // __WXMAC__
sizer->Add( aButton, wxSizerFlags().Centre().Border( wxRIGHT ) ); sizer->Add( aButton, wxSizerFlags().Centre().Border( wxRIGHT ) );
if( IsShownOnScreen() ) if( IsShownOnScreen() )

View File

@ -212,7 +212,8 @@ const std::string FILEEXT::StlFileExtension( "stl" );
const std::string FILEEXT::GencadFileExtension( "cad" ); const std::string FILEEXT::GencadFileExtension( "cad" );
const wxString FILEEXT::GerberFileExtensionsRegex( "(gbr|gko|pho|(g[tb][alops])|(gm?\\d\\d*)|(gp[tb]))" ); const wxString
FILEEXT::GerberFileExtensionsRegex( "(gbr|gko|pho|(g[tb][alops])|(gm?\\d\\d*)|(gp[tb]))" );
const std::string FILEEXT::FootprintLibraryTableFileName( "fp-lib-table" ); const std::string FILEEXT::FootprintLibraryTableFileName( "fp-lib-table" );
const std::string FILEEXT::SymbolLibraryTableFileName( "sym-lib-table" ); const std::string FILEEXT::SymbolLibraryTableFileName( "sym-lib-table" );

View File

@ -69,7 +69,6 @@ wxString WX_FILENAME::GetFullPath() const
} }
// Write locally-cached values to the wxFileName. MUST be called before using m_fn.
void WX_FILENAME::resolve() void WX_FILENAME::resolve()
{ {
size_t dot = m_fullName.find_last_of( wxT( '.' ) ); size_t dot = m_fullName.find_last_of( wxT( '.' ) );
@ -88,7 +87,7 @@ long long WX_FILENAME::GetTimestamp()
return 0; return 0;
} }
// Resolve possible symlink(s) in aFileName to an absolute path
void WX_FILENAME::ResolvePossibleSymlinks( wxFileName& aFilename ) void WX_FILENAME::ResolvePossibleSymlinks( wxFileName& aFilename )
{ {
#ifndef __WINDOWS__ #ifndef __WINDOWS__

View File

@ -39,10 +39,12 @@ void XNODE::Format( OUTPUTFORMATTER* out, int nestLevel )
case wxXML_ELEMENT_NODE: case wxXML_ELEMENT_NODE:
out->Print( nestLevel, "(%s", TO_UTF8( GetName() ) ); out->Print( nestLevel, "(%s", TO_UTF8( GetName() ) );
FormatContents( out, nestLevel ); FormatContents( out, nestLevel );
if( GetNext() ) if( GetNext() )
out->Print( 0, ")\n" ); out->Print( 0, ")\n" );
else else
out->Print( 0, ")" ); out->Print( 0, ")" );
break; break;
default: default:
@ -73,6 +75,7 @@ void XNODE::FormatContents( OUTPUTFORMATTER* out, int nestLevel )
{ {
if( kid == GetChildren() ) if( kid == GetChildren() )
out->Print( 0, "\n" ); out->Print( 0, "\n" );
kid->Format( out, nestLevel+1 ); kid->Format( out, nestLevel+1 );
} }
else else
@ -80,6 +83,7 @@ void XNODE::FormatContents( OUTPUTFORMATTER* out, int nestLevel )
kid->Format( out, 0 ); kid->Format( out, 0 );
} }
} }
break; break;
case wxXML_TEXT_NODE: case wxXML_TEXT_NODE: