From e09b095533a8abe77a1081af5889ed7700d133f0 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh <stambaughw@gmail.com> Date: Thu, 16 Jan 2025 07:37:05 -0500 Subject: [PATCH] Common folder housekeeping part 3. --- common/scintilla_tricks.cpp | 9 +- common/search_stack.cpp | 11 +- common/settings/app_settings.cpp | 6 +- common/settings/bom_settings.cpp | 10 +- common/settings/common_settings.cpp | 35 ++++-- common/settings/json_settings.cpp | 6 +- common/settings/kicad_settings.cpp | 3 +- common/settings/settings_manager.cpp | 16 +-- common/single_top.cpp | 38 +++--- common/string_utils.cpp | 17 +-- common/stroke_params.cpp | 3 +- common/template_fieldnames.cpp | 2 +- common/title_block.cpp | 2 + common/tool/action_manager.cpp | 4 +- common/tool/action_menu.cpp | 9 +- common/tool/action_toolbar.cpp | 7 +- common/tool/actions.cpp | 23 ++-- common/tool/common_control.cpp | 6 +- common/tool/common_tools.cpp | 4 +- common/tool/conditional_menu.cpp | 63 +++++----- common/tool/construction_manager.cpp | 29 +++-- common/tool/embed_tool.cpp | 4 + common/tool/grid_helper.cpp | 2 + common/tool/library_editor_control.cpp | 19 ++- common/tool/library_editor_control.h | 2 +- common/tool/picker_tool.cpp | 9 +- common/tool/point_editor_behavior.cpp | 5 +- common/tool/selection.cpp | 2 - common/tool/selection_conditions.cpp | 5 +- common/tool/tool_base.cpp | 2 + common/tool/tool_dispatcher.cpp | 87 +++++++------ common/tool/tool_interactive.cpp | 6 +- common/tool/tool_manager.cpp | 27 ++-- common/tool/tools_holder.cpp | 2 +- common/tool/zoom_menu.cpp | 1 + common/validators.cpp | 1 + common/view/view.cpp | 26 ++-- common/view/view_overlay.cpp | 3 + common/view/wx_view_controls.cpp | 31 +++-- common/widgets/button_row_panel.cpp | 1 + common/widgets/color_swatch.cpp | 3 +- common/widgets/filter_combobox.cpp | 10 +- common/widgets/footprint_choice.cpp | 5 +- common/widgets/footprint_diff_widget.cpp | 2 +- common/widgets/footprint_select_widget.cpp | 4 +- common/widgets/grid_button.cpp | 4 +- common/widgets/grid_combobox.cpp | 2 + common/widgets/grid_icon_text_helpers.cpp | 7 +- common/widgets/grid_text_button_helpers.cpp | 35 +++--- common/widgets/grid_text_helpers.cpp | 5 +- common/widgets/kistatusbar.cpp | 5 +- common/widgets/layer_presentation.cpp | 10 +- common/widgets/lib_tree.cpp | 3 +- common/widgets/listbox_tricks.cpp | 15 ++- common/widgets/mathplot.cpp | 129 ++++++++++++-------- common/widgets/number_badge.cpp | 4 +- common/widgets/paged_dialog.cpp | 14 ++- common/widgets/properties_panel.cpp | 9 +- common/widgets/search_pane_tab.cpp | 3 + common/widgets/split_button.cpp | 10 +- common/widgets/std_bitmap_button.cpp | 10 +- common/widgets/stepped_slider.cpp | 3 + common/widgets/ui_common.cpp | 6 +- common/widgets/unit_binder.cpp | 1 + common/widgets/widget_hotkey_list.cpp | 24 ++-- common/widgets/wx_collapsible_pane.cpp | 5 +- common/widgets/wx_grid.cpp | 40 +++--- common/widgets/wx_grid_autosizer.cpp | 9 +- common/widgets/wx_html_report_box.cpp | 1 + common/widgets/wx_html_report_box.h | 10 +- common/widgets/wx_html_report_panel.cpp | 8 +- common/widgets/wx_html_report_panel.h | 52 ++++---- common/widgets/wx_infobar.cpp | 4 +- common/wildcards_and_files_ext.cpp | 3 +- common/wx_filename.cpp | 3 +- common/xnode.cpp | 4 + 76 files changed, 621 insertions(+), 379 deletions(-) diff --git a/common/scintilla_tricks.cpp b/common/scintilla_tricks.cpp index b9c64945c7..45cf2ae3c0 100644 --- a/common/scintilla_tricks.cpp +++ b/common/scintilla_tricks.cpp @@ -150,16 +150,16 @@ bool isCtrlSlash( wxKeyEvent& aEvent ) // OK, now the wxWidgets hacks start. // (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 // keyboards (such as France and Belgium) have 7 in the shifted position, so a Shift+7 // *could* be legitimate. // 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 - // 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. if( aEvent.ShiftDown() && ( aEvent.GetUnicodeKey() == '7' || aEvent.GetUnicodeKey() == ':' ) ) @@ -576,7 +576,8 @@ void SCINTILLA_TRICKS::DoTextVarAutocomplete( auto textVarRef = [&]( 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 diff --git a/common/search_stack.cpp b/common/search_stack.cpp index 47eefabb9a..56528d9c11 100644 --- a/common/search_stack.cpp +++ b/common/search_stack.cpp @@ -58,7 +58,8 @@ static wxString base_dir( const wxString& aRelativePath, const wxString& aBaseDi 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 ); } @@ -82,7 +83,7 @@ wxString SEARCH_STACK::FilenameWithRelativePathInSearchList( // Search for the shortest subpath within 'this': 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; if( pathlen > fn.GetPath().Len() ) // A better (shortest) subpath is found @@ -199,14 +200,14 @@ const wxString SEARCH_STACK::LastVisitedPath( const wxString& aSubPathToSearch ) #endif -#if defined(DEBUG) +#if defined( DEBUG ) void SEARCH_STACK::Show( const wxString& aPrefix ) const { wxLogTrace( tracePathsAndFiles, "%s SEARCH_STACK:", aPrefix ); - for( unsigned i=0; i<GetCount(); ++i ) + for( unsigned i = 0; i < GetCount(); ++i ) { - wxLogTrace( tracePathsAndFiles, " [%2u]:%s", i, TO_UTF8( (*this)[i] ) ); + wxLogTrace( tracePathsAndFiles, " [%2u]:%s", i, TO_UTF8( ( *this )[i] ) ); } } #endif diff --git a/common/settings/app_settings.cpp b/common/settings/app_settings.cpp index 814b7e23d2..23a3b793f1 100644 --- a/common/settings/app_settings.cpp +++ b/common/settings/app_settings.cpp @@ -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_y", aJsonPath + ".pos_y" ); - ret &= fromLegacy<bool>( aCfg, frameGDO + "ForceDisplayCursor", cursorPath + ".always_show_cursor" ); - ret &= fromLegacy<bool>( aCfg, frameGDO + "CursorFullscreen", cursorPath + ".fullscreen_cursor" ); + ret &= fromLegacy<bool>( aCfg, frameGDO + "ForceDisplayCursor", + cursorPath + ".always_show_cursor" ); + ret &= fromLegacy<bool>( aCfg, frameGDO + "CursorFullscreen", + cursorPath + ".fullscreen_cursor" ); ret &= fromLegacy<int>( aCfg, aFrame + "_LastGridSize", gridPath + ".last_size" ); diff --git a/common/settings/bom_settings.cpp b/common/settings/bom_settings.cpp index cb5e828538..69d7fdbe81 100644 --- a/common/settings/bom_settings.cpp +++ b/common/settings/bom_settings.cpp @@ -99,6 +99,7 @@ void from_json( const nlohmann::json& j, BOM_PRESET& f ) j.at( "filter_string" ).get_to( f.filterString ); j.at( "group_symbols" ).get_to( f.groupSymbols ); 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 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 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>{ @@ -198,12 +200,14 @@ BOM_PRESET BOM_PRESET::Attributes() return p; } + std::vector<BOM_PRESET> BOM_PRESET::BuiltInPresets() { return { BOM_PRESET::DefaultEditing(), BOM_PRESET::GroupedByValue(), BOM_PRESET::GroupedByValueFootprint(), BOM_PRESET::Attributes() }; } + //Implementations for BOM_FMT_PRESET 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 }; } + BOM_FMT_PRESET BOM_FMT_PRESET::TSV() { return { _HKI( "TSV" ), true, wxS( "\t" ), wxT( "" ), wxT( "," ), wxT( "" ), false, false }; } + BOM_FMT_PRESET BOM_FMT_PRESET::Semicolons() { return { @@ -268,11 +274,13 @@ BOM_FMT_PRESET BOM_FMT_PRESET::Semicolons() }; } + std::vector<BOM_FMT_PRESET> BOM_FMT_PRESET::BuiltInPresets() { return { BOM_FMT_PRESET::CSV(), BOM_FMT_PRESET::TSV(), BOM_FMT_PRESET::Semicolons() }; } + #if !defined( __MINGW32__ ) template class KICOMMON_API PARAM_LIST<BOM_PRESET>; template class KICOMMON_API PARAM_LIST<BOM_FMT_PRESET>; diff --git a/common/settings/common_settings.cpp b/common/settings/common_settings.cpp index d6d87535e7..1e14eaef35 100644 --- a/common/settings/common_settings.cpp +++ b/common/settings/common_settings.cpp @@ -450,24 +450,29 @@ bool COMMON_SETTINGS::migrateSchema0to1() } 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 ) { ( *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_zoom" )] = WXK_CONTROL; + ( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_zoom" )] = + WXK_CONTROL; } else { ( *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_v" )] = WXK_SHIFT; - ( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_zoom" )] = 0; + ( *m_internals )[nlohmann::json::json_pointer( "/input/scroll_modifier_pan_h" )] = + 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; } return true; @@ -483,17 +488,21 @@ bool COMMON_SETTINGS::migrateSchema1to2() try { 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( ... ) { - 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 ) - ( *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 - ( *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; } @@ -518,11 +527,12 @@ bool COMMON_SETTINGS::migrateSchema2to3() wxString key = path.m_Alias; 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 // upper case only key.MakeUpper(); + // logically swap - with _ key.Replace( wxS( "-" ), wxS( "_" ) ); @@ -559,7 +569,8 @@ bool COMMON_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg ) { wxString key, value; 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" ); ( *m_internals )[ptr] = nlohmann::json( {} ); diff --git a/common/settings/json_settings.cpp b/common/settings/json_settings.cpp index e4858435dd..359c8cc14c 100644 --- a/common/settings/json_settings.cpp +++ b/common/settings/json_settings.cpp @@ -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 -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> JSON_SETTINGS::Get<double>( const std::string& aPath ) const; 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; template KICOMMON_API std::optional<BOM_FMT_PRESET> 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> JSON_SETTINGS::Get<wxPoint>( const std::string& aPath ) const; template KICOMMON_API std::optional<wxSize> diff --git a/common/settings/kicad_settings.cpp b/common/settings/kicad_settings.cpp index 24d48d418a..db79a36fab 100644 --- a/common/settings/kicad_settings.cpp +++ b/common/settings/kicad_settings.cpp @@ -60,7 +60,8 @@ KICAD_SETTINGS::KICAD_SETTINGS() : m_params.emplace_back( new PARAM<wxPoint>( "template.window.pos", &m_TemplateWindowPos, 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>( "pcm.repositories", diff --git a/common/settings/settings_manager.cpp b/common/settings/settings_manager.cpp index 109aad6849..d1357bf24f 100644 --- a/common/settings/settings_manager.cpp +++ b/common/settings/settings_manager.cpp @@ -83,6 +83,7 @@ SETTINGS_MANAGER::SETTINGS_MANAGER( bool aHeadless ) : } } + SETTINGS_MANAGER::~SETTINGS_MANAGER() { 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 // Load() could be called late in the application lifecycle - std::vector<JSON_SETTINGS*> toLoad; // 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 ) ( *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(); if( m_app_settings_cache.count( typeHash ) ) @@ -903,8 +903,8 @@ bool SETTINGS_MANAGER::LoadProject( const wxString& aFullPath, bool aSetActive ) wxString fullPath = path.GetFullPath(); // 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 - // pcbnew try to load it again when they are launched. + // 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. if( m_projects.count( fullPath ) ) return true; @@ -1044,7 +1044,8 @@ bool SETTINGS_MANAGER::IsProjectOpen() 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 ); - // 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 project->SetReadOnly( aProject->IsReadOnly() ); aProject->GetLocalSettings().SetReadOnly( aProject->IsReadOnly() ); @@ -1254,7 +1255,8 @@ bool SETTINGS_MANAGER::BackupProject( REPORTER& aReporter, wxFileName& aTarget ) 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; } diff --git a/common/single_top.cpp b/common/single_top.cpp index 5c34d21c5b..48140dd316 100644 --- a/common/single_top.cpp +++ b/common/single_top.cpp @@ -71,8 +71,7 @@ KIWAY Kiway( KFCTL_STANDALONE ); // implement a PGM_BASE and a wxApp side by side: /** - * Struct PGM_SINGLE_TOP - * implements PGM_BASE with its own OnPgmInit() and OnPgmExit(). + * Implement PGM_BASE with its own OnPgmInit() and OnPgmExit(). */ static struct PGM_SINGLE_TOP : public PGM_BASE { @@ -124,6 +123,7 @@ static struct PGM_SINGLE_TOP : public PGM_BASE } program; + // A module to allow Html module initialization/cleanup // When a wxHtmlWindow is used *only* in a dll/so module, the Html text is displayed // as plain text. @@ -135,26 +135,29 @@ public: HtmlModule() { } virtual bool OnInit() override { AddDependency( CLASSINFO( wxHtmlWinParser ) ); return true; }; virtual void OnExit() override {}; + private: wxDECLARE_DYNAMIC_CLASS( HtmlModule ); }; + wxIMPLEMENT_DYNAMIC_CLASS(HtmlModule, wxModule); + #ifdef NDEBUG // Define a custom assertion handler -void CustomAssertHandler(const wxString& file, - int line, - const wxString& func, - const wxString& cond, - const wxString& msg) +void CustomAssertHandler( const wxString& file, + int line, + const wxString& func, + const wxString& cond, + const wxString& msg ) { Pgm().HandleAssert( file, line, func, cond, msg ); } #endif + /** - * Struct APP_SINGLE_TOP - * implements a bare naked wxApp (so that we don't become dependent on + * Implement a bare naked wxApp (so that we don't become dependent on * functionality in a wxApp derivative that we cannot deliver under wxPython). */ struct APP_SINGLE_TOP : public wxApp @@ -162,6 +165,7 @@ struct APP_SINGLE_TOP : public wxApp APP_SINGLE_TOP() : wxApp() { SetPgm( &program ); + // Init the environment each platform wants KIPLATFORM::ENV::Init(); } @@ -254,7 +258,8 @@ struct APP_SINGLE_TOP : public wxApp if( dlgs.back() == dialog ) dlgs.pop_back(); // 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() ); } } @@ -289,9 +294,10 @@ struct APP_SINGLE_TOP : public wxApp #ifdef __WXMAC__ /** - * Function MacOpenFile - * is specific to MacOSX (not used under Linux or Windows). + * Specific to MacOSX (not used under Linux or Windows). + * * MacOSX requires it for file association. + * * @see http://wiki.wxwidgets.org/WxMac-specific_topics */ void MacOpenFile( const wxString& aFileName ) override @@ -320,11 +326,12 @@ bool PGM_SINGLE_TOP::OnPgmInit() // Initialize the git library before trying to initialize individual programs 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. bool skip_python_initialization = false; -#if defined( BITMAP_2_CMP ) || defined( PL_EDITOR ) || defined( GERBVIEW ) ||\ - defined( PCB_CALCULATOR_BUILD ) + +#if defined( BITMAP_2_CMP ) || defined( PL_EDITOR ) || defined( GERBVIEW ) || \ + defined( PCB_CALCULATOR_BUILD ) skip_python_initialization = true; #endif @@ -403,6 +410,7 @@ bool PGM_SINGLE_TOP::OnPgmInit() wxCmdLineParser parser( App().argc, App().argv ); parser.SetDesc( desc ); parser.Parse( false ); + if( parser.GetParamCount() ) { /* diff --git a/common/string_utils.cpp b/common/string_utils.cpp index 5ad6ad5b39..63ef6593f5 100644 --- a/common/string_utils.cpp +++ b/common/string_utils.cpp @@ -462,7 +462,7 @@ int ReadDelimitedText( char* aDest, const char* aSource, int aDestSize ) char* limit = aDest + aDestSize - 1; char cc; - while( (cc = *aSource++) != 0 && aDest < limit ) + while( ( cc = *aSource++ ) != 0 && aDest < limit ) { if( cc == '"' ) { @@ -471,7 +471,6 @@ int ReadDelimitedText( char* aDest, const char* aSource, int aDestSize ) inside = true; // first delimiter found, make note, do not copy } - else if( inside ) { 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 char_count = 0; @@ -997,7 +992,7 @@ bool ApplyModifier( double& value, const wxString& aString ) 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 // authored in -- something that isn't true, for instance, when sharing designs through // DIYAudio.com. @@ -1072,7 +1067,7 @@ bool convertSeparators( wxString* value ) { // 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. // // 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 == '?' ) { const struct lconv* lc = localeconv(); @@ -1406,7 +1401,7 @@ std::string UIDouble2Str( double aValue ) { // For these small values, %f works fine, // and %g gives an exponent - len = snprintf( buf, sizeof(buf), "%.16f", aValue ); + len = snprintf( buf, sizeof( buf ), "%.16f", aValue ); while( --len > 0 && buf[len] == '0' ) buf[len] = '\0'; @@ -1420,7 +1415,7 @@ std::string UIDouble2Str( double aValue ) { // For these values, %g works fine, and sometimes %f // gives a bad value (try aValue = 1.222222222222, with %.16f format!) - len = snprintf( buf, sizeof(buf), "%.10g", aValue ); + len = snprintf( buf, sizeof( buf ), "%.10g", aValue ); } return std::string( buf, len ); diff --git a/common/stroke_params.cpp b/common/stroke_params.cpp index 7518b53b45..62e0db90ef 100644 --- a/common/stroke_params.cpp +++ b/common/stroke_params.cpp @@ -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, 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, aWidth * 1.0 }; diff --git a/common/template_fieldnames.cpp b/common/template_fieldnames.cpp index ab6fa094c1..9f7dea3fa1 100644 --- a/common/template_fieldnames.cpp +++ b/common/template_fieldnames.cpp @@ -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 * precedence.) */ diff --git a/common/title_block.cpp b/common/title_block.cpp index 46d2f58195..c055a4cbaf 100644 --- a/common/title_block.cpp +++ b/common/title_block.cpp @@ -27,6 +27,7 @@ #include <title_block.h> #include <core/kicad_algo.h> + void TITLE_BLOCK::Format( OUTPUTFORMATTER* aFormatter ) const { // 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 ) { if( !alg::contains( *aVars, wxT( "ISSUE_DATE" ) ) ) diff --git a/common/tool/action_manager.cpp b/common/tool/action_manager.cpp index 76e5917b7a..808dede4a3 100644 --- a/common/tool/action_manager.cpp +++ b/common/tool/action_manager.cpp @@ -33,6 +33,7 @@ #include <hotkeys_basic.h> #include <cctype> + ACTION_MANAGER::ACTION_MANAGER( TOOL_MANAGER* aToolManager ) : m_toolMgr( aToolManager ) { @@ -56,7 +57,8 @@ ACTION_MANAGER::ACTION_MANAGER( TOOL_MANAGER* aToolManager ) : } 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 ); RegisterAction( action ); diff --git a/common/tool/action_menu.cpp b/common/tool/action_menu.cpp index f660f8d899..db7937bb36 100644 --- a/common/tool/action_menu.cpp +++ b/common/tool/action_menu.cpp @@ -108,6 +108,7 @@ void ACTION_MENU::DisplayTitle( bool aDisplay ) wxMenuItem* item = FindItemByPosition( 0 ); wxASSERT( item->GetItemLabelText() == GetTitle() ); Destroy( item ); + // ..and separator item = FindItemByPosition( 0 ); 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, 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(); // 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 ); - 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 ) { @@ -653,9 +655,10 @@ wxMenuItem* ACTION_MENU::appendCopy( const wxMenuItem* aSource ) // On Windows, for Checkable Menu items, adding a bitmap adds also // our predefined checked alternate bitmap // On other OS, wxITEM_CHECK and wxITEM_RADIO Menu items do not use custom bitmaps. + #if defined( __WXMSW__ ) // 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. bool use_checked_bm = ( aSource->GetKind() == wxITEM_CHECK || aSource->GetKind() == wxITEM_RADIO ) ? false : true; diff --git a/common/tool/action_toolbar.cpp b/common/tool/action_toolbar.cpp index 641c3bfd11..ac2f54e4b5 100644 --- a/common/tool/action_toolbar.cpp +++ b/common/tool/action_toolbar.cpp @@ -241,7 +241,8 @@ ACTION_TOOLBAR::~ACTION_TOOLBAR() void ACTION_TOOLBAR::Add( const TOOL_ACTION& aAction, bool aIsToggleEntry, bool aIsCancellable ) { wxASSERT( GetParent() ); - wxASSERT_MSG( !( aIsCancellable && !aIsToggleEntry ), wxS( "aIsCancellable requires aIsToggleEntry" ) ); + wxASSERT_MSG( !( aIsCancellable && !aIsToggleEntry ), + wxS( "aIsCancellable requires aIsToggleEntry" ) ); 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 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 control->InvalidateBestSize(); @@ -526,6 +528,7 @@ void ACTION_TOOLBAR::onToolRightClick( wxAuiToolBarEvent& aEvent ) SetHoverItem( nullptr ); } + // The time (in milliseconds) between pressing the left mouse button and opening the palette #define PALETTE_OPEN_DELAY 500 diff --git a/common/tool/actions.cpp b/common/tool/actions.cpp index 815347c98e..ed4c561825 100644 --- a/common/tool/actions.cpp +++ b/common/tool/actions.cpp @@ -1263,25 +1263,32 @@ TOOL_ACTION ACTIONS::extractFile( TOOL_ACTION_ARGS() // 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::UnselectedEvent( TC_MESSAGE, TA_ACTION, "common.Interactive.unselected" ); 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::InhibitSelectionEditing( TC_MESSAGE, TA_ACTION, "common.Interactive.inhibit" ); -const TOOL_EVENT EVENTS::UninhibitSelectionEditing( TC_MESSAGE, TA_ACTION, "common.Interactive.uninhibit" ); +const TOOL_EVENT EVENTS::InhibitSelectionEditing( TC_MESSAGE, TA_ACTION, + "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, "common.Interactive.gridChangedByKey" ); -const TOOL_EVENT EVENTS::ContrastModeChangedByKeyEvent( TC_MESSAGE, TA_ACTION, - "common.Interactive.contrastModeChangedByKeyEvent" ); +const TOOL_EVENT + EVENTS::ContrastModeChangedByKeyEvent( TC_MESSAGE, TA_ACTION, + "common.Interactive.contrastModeChangedByKeyEvent" ); // System-wide undo/redo Events diff --git a/common/tool/common_control.cpp b/common/tool/common_control.cpp index 568a80e90a..15e00a986f 100644 --- a/common/tool/common_control.cpp +++ b/common/tool/common_control.cpp @@ -50,7 +50,8 @@ /// URL to launch a new issue with pre-populated description 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) @@ -136,7 +137,8 @@ int COMMON_CONTROL::ShowLibraryTable( const TOOL_EVENT& aEvent ) try // Kicad frame was not available, try to start it { 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( ... ) { diff --git a/common/tool/common_tools.cpp b/common/tool/common_tools.cpp index 14864c17a4..99e8f42f8b 100644 --- a/common/tool/common_tools.cpp +++ b/common/tool/common_tools.cpp @@ -55,6 +55,7 @@ COMMON_TOOLS::COMMON_TOOLS() : { } + void COMMON_TOOLS::Reset( RESET_REASON aReason ) { 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 ) { 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 ); } + int COMMON_TOOLS::CenterContents( const TOOL_EVENT& aEvent ) { 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& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx; diff --git a/common/tool/conditional_menu.cpp b/common/tool/conditional_menu.cpp index 03cd874083..5d8f221db9 100644 --- a/common/tool/conditional_menu.cpp +++ b/common/tool/conditional_menu.cpp @@ -152,43 +152,43 @@ void CONDITIONAL_MENU::Evaluate( const SELECTION& aSelection ) switch( entry.Type() ) { - case ENTRY::ACTION: - Add( *entry.Action(), entry.IsCheckmarkEntry() ); - menu_count++; - break; + case ENTRY::ACTION: + Add( *entry.Action(), entry.IsCheckmarkEntry() ); + menu_count++; + break; - case ENTRY::MENU: - entry.Menu()->UpdateTitle(); - Add( entry.Menu()->Clone() ); - menu_count++; - break; + case ENTRY::MENU: + entry.Menu()->UpdateTitle(); + Add( entry.Menu()->Clone() ); + menu_count++; + break; - case ENTRY::WXITEM: - menuItem = new wxMenuItem( this, - entry.wxItem()->GetId(), - wxGetTranslation( entry.wxItem()->GetItemLabel() ), - wxGetTranslation( entry.wxItem()->GetHelp() ), - entry.wxItem()->GetKind() ); + case ENTRY::WXITEM: + menuItem = new wxMenuItem( this, + entry.wxItem()->GetId(), + wxGetTranslation( entry.wxItem()->GetItemLabel() ), + wxGetTranslation( entry.wxItem()->GetHelp() ), + entry.wxItem()->GetKind() ); - if( !!entry.GetIcon() ) - KIUI::AddBitmapToMenuItem( menuItem, KiBitmap( entry.GetIcon() ) ); + if( !!entry.GetIcon() ) + KIUI::AddBitmapToMenuItem( menuItem, KiBitmap( entry.GetIcon() ) ); - // the wxMenuItem must be append only after the bitmap is set: - Append( menuItem ); + // the wxMenuItem must be append only after the bitmap is set: + Append( menuItem ); - menu_count++; - break; + menu_count++; + break; - case ENTRY::SEPARATOR: - if( menu_count ) - AppendSeparator(); + case ENTRY::SEPARATOR: + if( menu_count ) + AppendSeparator(); - menu_count = 0; - break; + menu_count = 0; + break; - default: - wxASSERT( false ); - break; + default: + wxASSERT( false ); + break; } } @@ -231,9 +231,11 @@ CONDITIONAL_MENU::ENTRY::ENTRY( const ENTRY& aEntry ) case ACTION: m_data.action = aEntry.m_data.action; break; + case MENU: m_data.menu = aEntry.m_data.menu; break; + case WXITEM: // We own the wxItem, so we need to make a new one for the new object 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->GetKind() ); break; + case SEPARATOR: break; //No data to copy } + m_condition = aEntry.m_condition; m_order = aEntry.m_order; m_isCheckmarkEntry = aEntry.m_isCheckmarkEntry; } + CONDITIONAL_MENU::ENTRY::~ENTRY() { if( WXITEM == m_type ) diff --git a/common/tool/construction_manager.cpp b/common/tool/construction_manager.cpp index 95f09aeb8f..ff47a072ac 100644 --- a/common/tool/construction_manager.cpp +++ b/common/tool/construction_manager.cpp @@ -34,7 +34,7 @@ * 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 - * 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 * @@ -102,6 +102,7 @@ public: while( !m_stop ) { std::unique_lock<std::mutex> lock( m_mutex ); + if( !m_stop && !m_pendingProposalTag.has_value() ) { // No active proposal - wait for one (unlocks while waiting) @@ -117,6 +118,7 @@ public: { // See if the timeout was extended for a new proposal now = std::chrono::steady_clock::now(); + if( now < m_proposalDeadline ) { // Extended - wait for the new deadline @@ -124,7 +126,7 @@ public: } // 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 ) { m_lastAcceptedProposalTag = m_pendingProposalTag; @@ -132,6 +134,7 @@ public: T proposalToAccept = std::move( m_lastProposal ); lock.unlock(); + // Call the callback (outside the lock) m_callback( std::move( proposalToAccept ) ); } @@ -143,25 +146,26 @@ public: private: mutable std::mutex m_mutex; - // Activation timeout in milliseconds + /// Activation timeout in milliseconds. std::chrono::milliseconds m_timeout; 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; - ///< The last proposal that was accepted + /// The last proposal that was accepted. std::optional<std::size_t> m_lastAcceptedProposalTag; - // The most recently-proposed item + /// The most recently-proposed item. T m_lastProposal; - ///< Callback to call when the proposal is accepted + /// Callback to call when the proposal is accepted. ACTIVATION_CALLBACK m_callback; std::condition_variable m_cv; 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; }; @@ -329,6 +333,7 @@ void CONSTRUCTION_MANAGER::acceptConstructionItems( std::unique_ptr<PENDING_BATC m_viewHandler.updateView(); } + bool CONSTRUCTION_MANAGER::InvolvesAllGivenRealItems( const std::vector<EDA_ITEM*>& aItems ) const { for( EDA_ITEM* item : aItems ) @@ -343,6 +348,7 @@ bool CONSTRUCTION_MANAGER::InvolvesAllGivenRealItems( const std::vector<EDA_ITEM return true; } + void CONSTRUCTION_MANAGER::GetConstructionItems( std::vector<CONSTRUCTION_ITEM_BATCH>& aToExtend ) const { @@ -358,17 +364,20 @@ void CONSTRUCTION_MANAGER::GetConstructionItems( } } + bool CONSTRUCTION_MANAGER::HasActiveConstruction() const { std::lock_guard<std::mutex> lock( m_batchesMutex ); return m_persistentConstructionBatch.has_value() || !m_temporaryConstructionBatches.empty(); } + SNAP_LINE_MANAGER::SNAP_LINE_MANAGER( CONSTRUCTION_VIEW_HANDLER& aViewHandler ) : m_viewHandler( aViewHandler ) { } + void SNAP_LINE_MANAGER::SetSnapLineOrigin( const VECTOR2I& aOrigin ) { // 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; } + void SNAP_LINE_MANAGER::SetSnapLineEnd( const OPT_VECTOR2I& aSnapEnd ) { if( m_snapLineOrigin && aSnapEnd != m_snapLineEnd ) @@ -391,6 +401,7 @@ void SNAP_LINE_MANAGER::SetSnapLineEnd( const OPT_VECTOR2I& aSnapEnd ) } } + void SNAP_LINE_MANAGER::ClearSnapLine() { m_snapLineOrigin.reset(); @@ -399,6 +410,7 @@ void SNAP_LINE_MANAGER::ClearSnapLine() m_viewHandler.updateView(); } + void SNAP_LINE_MANAGER::SetSnappedAnchor( const VECTOR2I& aAnchorPos ) { if( m_snapLineOrigin.has_value() ) @@ -440,6 +452,7 @@ static bool pointHasEscapedSnapLineX( const VECTOR2I& aCursor, const VECTOR2I& a return std::abs( angle.Normalize90() ) > aLongRangeEscapeAngle; } + /** * As above, but for the Y direction. */ diff --git a/common/tool/embed_tool.cpp b/common/tool/embed_tool.cpp index 4e246c24e4..26a5bf7325 100644 --- a/common/tool/embed_tool.cpp +++ b/common/tool/embed_tool.cpp @@ -56,6 +56,7 @@ void EMBED_TOOL::Reset( RESET_REASON aReason ) m_files = getModel<EDA_ITEM>()->GetEmbeddedFiles(); } + int EMBED_TOOL::AddFile( const TOOL_EVENT& aEvent ) { wxString name = aEvent.Parameter<wxString>(); @@ -64,6 +65,7 @@ int EMBED_TOOL::AddFile( const TOOL_EVENT& aEvent ) return 1; } + int EMBED_TOOL::RemoveFile( const TOOL_EVENT& aEvent ) { wxString name = aEvent.Parameter<wxString>(); @@ -72,6 +74,7 @@ int EMBED_TOOL::RemoveFile( const TOOL_EVENT& aEvent ) return 1; } + std::vector<wxString> EMBED_TOOL::GetFileList() { std::vector<wxString> list; @@ -84,6 +87,7 @@ std::vector<wxString> EMBED_TOOL::GetFileList() return list; } + void EMBED_TOOL::setTransitions() { Go( &EMBED_TOOL::AddFile, ACTIONS::embeddedFiles.MakeEvent() ); diff --git a/common/tool/grid_helper.cpp b/common/tool/grid_helper.cpp index 672da9c5c8..572d2b6e65 100644 --- a/common/tool/grid_helper.cpp +++ b/common/tool/grid_helper.cpp @@ -85,6 +85,7 @@ GRID_HELPER::~GRID_HELPER() KIGFX::ANCHOR_DEBUG* GRID_HELPER::enableAndGetAnchorDebug() { static bool permitted = ADVANCED_CFG::GetCfg().m_EnableSnapAnchorsDebug; + if( permitted && !m_anchorDebug ) { KIGFX::VIEW& view = *m_toolMgr->GetView(); @@ -92,6 +93,7 @@ KIGFX::ANCHOR_DEBUG* GRID_HELPER::enableAndGetAnchorDebug() view.Add( m_anchorDebug.get() ); view.SetVisible( m_anchorDebug.get(), true ); } + return m_anchorDebug.get(); } diff --git a/common/tool/library_editor_control.cpp b/common/tool/library_editor_control.cpp index 67525a8251..caeb434c5f 100644 --- a/common/tool/library_editor_control.cpp +++ b/common/tool/library_editor_control.cpp @@ -45,14 +45,17 @@ void LIBRARY_EDITOR_CONTROL::AddContextMenuItems( CONDITIONAL_MENU* aMenu ) { LIB_TREE* libTree = m_frame->GetLibTree(); 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 = [this](const SELECTION& aSel ) { LIB_TREE* libTree = m_frame->GetLibTree(); 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 ); @@ -89,11 +92,15 @@ int LIBRARY_EDITOR_CONTROL::PinLibrary( const TOOL_EVENT& aEvent ) m_frame->Prj().PinLibrary( current->m_LibId.GetLibNickname(), PROJECT::LIB_TYPE_T::SYMBOL_LIB ); break; + case KIWAY::FACE_PCB: m_frame->Prj().PinLibrary( current->m_LibId.GetLibNickname(), PROJECT::LIB_TYPE_T::FOOTPRINT_LIB ); 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; @@ -117,11 +124,15 @@ int LIBRARY_EDITOR_CONTROL::UnpinLibrary( const TOOL_EVENT& aEvent ) m_frame->Prj().UnpinLibrary( current->m_LibId.GetLibNickname(), PROJECT::LIB_TYPE_T::SYMBOL_LIB ); break; + case KIWAY::FACE_PCB: m_frame->Prj().UnpinLibrary( current->m_LibId.GetLibNickname(), PROJECT::LIB_TYPE_T::FOOTPRINT_LIB ); 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; diff --git a/common/tool/library_editor_control.h b/common/tool/library_editor_control.h index d3a90ac90f..7d40f31f48 100644 --- a/common/tool/library_editor_control.h +++ b/common/tool/library_editor_control.h @@ -46,7 +46,7 @@ public: std::function<bool( const wxString& aNewName )> aValidator ); private: - ///< Set up handlers for various events. + /// Set up handlers for various events. void setTransitions() override; void regenerateLibraryTree(); diff --git a/common/tool/picker_tool.cpp b/common/tool/picker_tool.cpp index 503baf4972..9351c7fe76 100644 --- a/common/tool/picker_tool.cpp +++ b/common/tool/picker_tool.cpp @@ -130,7 +130,6 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent ) break; } - else if( evt->IsClick( BUT_LEFT ) ) { bool getNext = false; @@ -156,9 +155,10 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent ) break; } else + { setControls(); + } } - else if( evt->IsMotion() ) { if( m_motionHandler ) @@ -172,19 +172,18 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent ) } } } - else if( evt->IsDblClick( BUT_LEFT ) || evt->IsDrag( BUT_LEFT ) ) { // Not currently used, but we don't want to pass them either } - else if( evt->IsClick( BUT_RIGHT ) ) { m_menu->ShowContextMenu(); } - else + { evt->SetPassEvent(); + } } if( m_finalizeHandler ) diff --git a/common/tool/point_editor_behavior.cpp b/common/tool/point_editor_behavior.cpp index 214d716ffb..7c1eb51407 100644 --- a/common/tool/point_editor_behavior.cpp +++ b/common/tool/point_editor_behavior.cpp @@ -63,7 +63,6 @@ void POLYGON_POINT_EDIT_BEHAVIOR::UpdatePointsFromOutline( const SHAPE_POLY_SET& EDIT_POINTS& aPoints ) { // No size check here, as we can and will rebuild if that fails - if( aPoints.PointsSize() != (unsigned) aOutline.TotalVertices() ) { // Rebuild the points list @@ -107,6 +106,7 @@ void EDA_SEGMENT_POINT_EDIT_BEHAVIOR::MakePoints( EDIT_POINTS& aPoints ) aPoints.AddPoint( m_segment.GetEnd() ); } + void EDA_SEGMENT_POINT_EDIT_BEHAVIOR::UpdatePoints( EDIT_POINTS& aPoints ) { 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(); } + void EDA_SEGMENT_POINT_EDIT_BEHAVIOR::UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints, COMMIT& aCommit, 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 ) ); } + void EDA_BEZIER_POINT_EDIT_BEHAVIOR::UpdatePoints( EDIT_POINTS& aPoints ) { 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() ); } + void EDA_BEZIER_POINT_EDIT_BEHAVIOR::UpdateItem( const EDIT_POINT& aEditedPoint, EDIT_POINTS& aPoints, COMMIT& aCommit, std::vector<EDA_ITEM*>& aUpdatedItems ) diff --git a/common/tool/selection.cpp b/common/tool/selection.cpp index 54fa34a4de..99a8ff7103 100644 --- a/common/tool/selection.cpp +++ b/common/tool/selection.cpp @@ -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 { 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 // instead of using the center of the total bounding box. Otherwise rotating the selection will // also translate it. - for( EDA_ITEM* item : m_items ) { if( !item->IsType( textTypes ) ) diff --git a/common/tool/selection_conditions.cpp b/common/tool/selection_conditions.cpp index 63d98ea2a9..8944ed994e 100644 --- a/common/tool/selection_conditions.cpp +++ b/common/tool/selection_conditions.cpp @@ -183,6 +183,7 @@ SELECTION_CONDITION operator||( const SELECTION_CONDITION& aConditionA, return std::bind( &SELECTION_CONDITIONS::orBoolFunc, aConditionA, std::ref( aConditionB ), _1 ); } + SELECTION_CONDITION operator||( SELECTION_BOOL aConditionA, const SELECTION_CONDITION& aConditionB ) { @@ -193,9 +194,11 @@ SELECTION_CONDITION operator||( SELECTION_BOOL aConditionA, SELECTION_CONDITION operator&&( const SELECTION_CONDITION& aConditionA, 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, const SELECTION_CONDITION& aConditionB ) { diff --git a/common/tool/tool_base.cpp b/common/tool/tool_base.cpp index 51177c164f..aaa9daf828 100644 --- a/common/tool/tool_base.cpp +++ b/common/tool/tool_base.cpp @@ -28,11 +28,13 @@ #include <eda_draw_frame.h> #include <eda_base_frame.h> + bool TOOL_BASE::IsToolActive() const { return m_toolMgr->IsToolActive( m_toolId ); } + KIGFX::VIEW* TOOL_BASE::getView() const { return m_toolMgr->GetView(); diff --git a/common/tool/tool_dispatcher.cpp b/common/tool/tool_dispatcher.cpp index 4b5ada6fdc..59ca3ba873 100644 --- a/common/tool/tool_dispatcher.cpp +++ b/common/tool/tool_dispatcher.cpp @@ -48,7 +48,7 @@ #include <kiplatform/ui.h> -///< Stores information about a mouse button state +/// Store information about a mouse button state. struct TOOL_DISPATCHER::BUTTON_STATE { BUTTON_STATE( TOOL_MOUSE_BUTTONS aButton, const wxEventType& aDownEvent, @@ -61,44 +61,44 @@ struct TOOL_DISPATCHER::BUTTON_STATE dblClickEvent( aDblClickEvent ) {}; - ///< Flag indicating that dragging is active for the given button. + /// Flag indicating that dragging is active for the given button. bool dragging; - ///< Flag indicating that the given button is pressed. + /// Flag indicating that the given button is pressed. bool pressed; - ///< Point where dragging has started (in world coordinates). + /// Point where dragging has started (in world coordinates). VECTOR2D dragOrigin; - ///< Point where dragging has started (in screen coordinates). + /// Point where dragging has started (in screen coordinates). VECTOR2D dragOriginScreen; - ///< Point where click event has occurred. + /// Point where click event has occurred. VECTOR2D downPosition; - ///< Determines the mouse button for which information are stored. + /// Determines the mouse button for which information are stored. TOOL_MOUSE_BUTTONS button; - ///< The type of wxEvent that determines mouse button press. + /// The type of wxEvent that determines mouse button press. wxEventType downEvent; - ///< The type of wxEvent that determines mouse button release. + /// The type of wxEvent that determines mouse button release. wxEventType upEvent; - ///< The type of wxEvent that determines mouse button double click. + /// The type of wxEvent that determines mouse button double click. wxEventType dblClickEvent; - ///< Time stamp for the last mouse button press event. + /// Time stamp for the last mouse button press event. wxLongLong downTimestamp; - ///< Restores initial state. + /// Restores initial state. void Reset() { dragging = false; pressed = false; } - ///< Checks the current state of the button. + /// Checks the current state of the button. bool GetState() const { 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 -// 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 -// Some keys have a predefined action in wxWidgets so, even if not used, -// the even will be not skipped -// the unused keys listed in isKeySpecialCode() will be not skipped +/** + * Helper to know if a special key ( see key list ) should be captured. + * + * If the event can be skipped 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. Some keys have a + * predefined action in wxWidgets so, even if not used, the even will be not skipped the unused + * keys listed in isKeySpecialCode() will be not skipped. + */ bool isKeySpecialCode( int aKeyCode ) { // 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 -// that is not used alone in kicad +/** + * Helper 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 that is not used alone in KiCad. + */ static bool isKeyModifierOnly( int aKeyCode ) { 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, - * WXK_NUMPAD_DOWN to WXK_DOWN, - * WXK_NUMPAD_LEFT to WXK_LEFT, - * WXK_NUMPAD_RIGHT, - * WXK_NUMPAD_PAGEUP, - * WXK_NUMPAD_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 - * have default action (scroll the panel) +/** + * Convert some special key codes to an equivalent. + * + * - WXK_NUMPAD_UP to WXK_UP + * - WXK_NUMPAD_DOWN to WXK_DOWN + * - WXK_NUMPAD_LEFT to WXK_LEFT + * - WXK_NUMPAD_RIGHT to WXK_RIGHT + * - WXK_NUMPAD_PAGEUP to WXK_PAGEUP + * - 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 + * have default action (scroll the panel). */ int translateSpecialCode( int aKeyCode ) { @@ -347,7 +351,7 @@ std::optional<TOOL_EVENT> TOOL_DISPATCHER::GetToolEvent( wxKeyEvent* aKeyEvent, int key = aKeyEvent->GetKeyCode(); 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 ) ) { aKeyEvent->Skip(); @@ -622,11 +626,13 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent ) 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 ); - 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() ); } @@ -663,3 +669,10 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent ) wxLogTrace( kicadTraceToolStack, "TOOL_DISPATCHER::DispatchWxEvent - Wx event skipped: %s", ( 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 diff --git a/common/tool/tool_interactive.cpp b/common/tool/tool_interactive.cpp index b0ecf9014e..01cf9f0c06 100644 --- a/common/tool/tool_interactive.cpp +++ b/common/tool/tool_interactive.cpp @@ -35,6 +35,7 @@ #include <wx/log.h> + TOOL_INTERACTIVE::TOOL_INTERACTIVE( TOOL_ID aId, const std::string& aName ) : TOOL_BASE( INTERACTIVE, aId, aName ) { @@ -47,7 +48,7 @@ TOOL_INTERACTIVE::TOOL_INTERACTIVE( TOOL_ID aId, const std::string& aName ) : TOOL_INTERACTIVE::TOOL_INTERACTIVE( const std::string& aName ) : TOOL_BASE( INTERACTIVE, TOOL_MANAGER::MakeToolId( aName ), aName ) - + { if( Pgm().IsGUI() ) { @@ -83,7 +84,8 @@ void TOOL_INTERACTIVE::resetTransitions() void TOOL_INTERACTIVE::goInternal( TOOL_STATE_FUNC& aState, const TOOL_EVENT_LIST& aConditions ) { 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() ); m_toolMgr->ScheduleNextState( this, aState, aConditions ); diff --git a/common/tool/tool_manager.cpp b/common/tool/tool_manager.cpp index 920288aa26..a4088035b4 100644 --- a/common/tool/tool_manager.cpp +++ b/common/tool/tool_manager.cpp @@ -138,6 +138,7 @@ struct TOOL_MANAGER::TOOL_STATE waitEvents = aState.waitEvents; transitions = aState.transitions; vcSettings = aState.vcSettings; + // do not copy stateStack return *this; } @@ -187,10 +188,10 @@ struct TOOL_MANAGER::TOOL_STATE } private: - ///< Stack preserving previous states of a TOOL. + /// Stack preserving previous states of a TOOL. std::stack<std::unique_ptr<TOOL_STATE>> stateStack; - ///< Restores the initial state. + /// Restores the initial state. void clear() { idle = true; @@ -246,7 +247,8 @@ void TOOL_MANAGER::RegisterTool( TOOL_BASE* aTool ) wxASSERT_MSG( m_toolTypes.find( typeid( *aTool ).name() ) == m_toolTypes.end(), 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() ); m_toolOrder.push_back( aTool ); @@ -284,7 +286,7 @@ bool TOOL_MANAGER::InvokeTool( const std::string& aToolName ) return invokeTool( tool ); wxLogTrace( kicadTraceToolStack, wxS( "TOOL_MANAGER::InvokeTool - no tool with name %s" ), - aToolName ); + aToolName ); return false; // there is no tool with the given name } @@ -644,8 +646,9 @@ void TOOL_MANAGER::InitTools() if( !tool->Init() ) { - wxLogTrace( kicadTraceToolStack, wxS( "TOOL_MANAGER initialization of tool '%s' failed" ), - tool->GetName() ); + wxLogTrace( kicadTraceToolStack, + wxS( "TOOL_MANAGER initialization of tool '%s' failed" ), + tool->GetName() ); // Unregister the tool setActiveState( nullptr ); @@ -785,7 +788,8 @@ bool TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent ) if( !st->wakeupEvent.PassEvent() ) { 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() ); 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 ) ); 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() ); // got match? Run the handler. @@ -891,6 +896,7 @@ bool TOOL_MANAGER::dispatchActivation( const TOOL_EVENT& aEvent ) return false; } + void TOOL_MANAGER::DispatchContextMenu( const TOOL_EVENT& aEvent ) { for( TOOL_ID toolId : m_activeTools ) @@ -952,7 +958,7 @@ void TOOL_MANAGER::DispatchContextMenu( const TOOL_EVENT& aEvent ) if( m_viewControls && m_warpMouseAfterContextMenu ) m_viewControls->WarpMouseCursor( m_menuCursor, true, false ); } - // Otherwise notify the tool of a cancelled menu + // Otherwise notify the tool of a canceled menu else { 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; // 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 ); wxASSERT( it != m_toolIdIndex.end() ); diff --git a/common/tool/tools_holder.cpp b/common/tool/tools_holder.cpp index d0b1361047..3061105493 100644 --- a/common/tool/tools_holder.cpp +++ b/common/tool/tools_holder.cpp @@ -39,6 +39,7 @@ TOOLS_HOLDER::TOOLS_HOLDER() : m_moveWarpsCursor( true ) { } + void TOOLS_HOLDER::RegisterUIUpdateHandler( const TOOL_ACTION& aAction, 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 // frame but not processed until the mouse is back in the Schematic frame), so make sure // we're popping the right stack frame. - for( int i = (int) m_toolStack.size() - 1; i >= 0; --i ) { if( m_toolStack[ i ] == actionName ) diff --git a/common/tool/zoom_menu.cpp b/common/tool/zoom_menu.cpp index 4650f6bd1f..037cb3ba76 100644 --- a/common/tool/zoom_menu.cpp +++ b/common/tool/zoom_menu.cpp @@ -74,6 +74,7 @@ void ZOOM_MENU::update() { // Search for a value near the current zoom setting: double rel_error = std::fabs( zoomList[jj] - zoom ) / zoom; + // IDs start with 1 (leaving 0 for auto-zoom) Check( ID_POPUP_ZOOM_LEVEL_START + jj + 1, rel_error < 0.1 ); } diff --git a/common/validators.cpp b/common/validators.cpp index 46077f4c14..b06d4aa7ab 100644 --- a/common/validators.cpp +++ b/common/validators.cpp @@ -361,6 +361,7 @@ bool FIELD_VALIDATOR::Validate( wxWindow* aParent ) return DoValidate( val, aParent ); } + bool FIELD_VALIDATOR::DoValidate( const wxString& aValue, wxWindow* aParent ) { wxString msg; diff --git a/common/view/view.cpp b/common/view/view.cpp index 76f8197be7..b1f79a92d0 100644 --- a/common/view/view.cpp +++ b/common/view/view.cpp @@ -133,7 +133,6 @@ private: m_groupsSize = 0; } - /** * 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; } - /** * Reorder the stored groups (to facilitate reordering of layers). * @@ -970,18 +968,20 @@ struct VIEW::DRAW_ITEM_VISITOR if( reverseDrawOrder ) { std::sort( drawItems.begin(), drawItems.end(), - []( VIEW_ITEM* a, VIEW_ITEM* b ) -> bool - { - return b->viewPrivData()->m_drawPriority < a->viewPrivData()->m_drawPriority; - } ); + []( VIEW_ITEM* a, VIEW_ITEM* b ) -> bool + { + return b->viewPrivData()->m_drawPriority + < a->viewPrivData()->m_drawPriority; + } ); } else { std::sort( drawItems.begin(), drawItems.end(), - []( VIEW_ITEM* a, VIEW_ITEM* b ) -> bool - { - return a->viewPrivData()->m_drawPriority < b->viewPrivData()->m_drawPriority; - } ); + []( VIEW_ITEM* a, VIEW_ITEM* b ) -> bool + { + return a->viewPrivData()->m_drawPriority + < b->viewPrivData()->m_drawPriority; + } ); } for( VIEW_ITEM* item : drawItems ) @@ -1089,7 +1089,7 @@ void VIEW::draw( VIEW_ITEM* aItem, bool aImmediate ) void VIEW::draw( VIEW_GROUP* aGroup, bool aImmediate ) { - for( unsigned int i = 0; i < aGroup->GetSize(); i++) + for( unsigned int i = 0; i < aGroup->GetSize(); i++ ) draw( aGroup->GetItem(i), aImmediate ); } @@ -1541,8 +1541,8 @@ void VIEW::UpdateItems() } } - KI_TRACE( traceGalProfile, wxS( "View update: total items %u, geom %u anyUpdated %u\n" ), cntTotal, - cntGeomUpdate, (unsigned) anyUpdated ); + KI_TRACE( traceGalProfile, wxS( "View update: total items %u, geom %u anyUpdated %u\n" ), + cntTotal, cntGeomUpdate, (unsigned) anyUpdated ); } diff --git a/common/view/view_overlay.cpp b/common/view/view_overlay.cpp index 7592959fa7..a6f5009ac3 100644 --- a/common/view/view_overlay.cpp +++ b/common/view/view_overlay.cpp @@ -261,6 +261,7 @@ struct VIEW_OVERLAY::COMMAND_BITMAP_TEXT : public VIEW_OVERLAY::COMMAND EDA_ANGLE m_angle; }; + 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 ) ); } + void VIEW_OVERLAY::SetLineWidth( double aLineWidth ) { m_commands.push_back( new COMMAND_SET_WIDTH( aLineWidth ) ); } + void VIEW_OVERLAY::Cross( const VECTOR2D& aP, int aSize ) { Line( aP + VECTOR2D( -aSize, -aSize ), aP + VECTOR2D( aSize, aSize ) ); diff --git a/common/view/wx_view_controls.cpp b/common/view/wx_view_controls.cpp index b7ad913fd3..dc32008c85 100644 --- a/common/view/wx_view_controls.cpp +++ b/common/view/wx_view_controls.cpp @@ -141,7 +141,7 @@ WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, EDA_DRAW_PANEL_GAL* aParentPane m_cursorWarped = false; 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_lastKeyboardCursorPosition = { 0.0, 0.0 }; @@ -292,10 +292,14 @@ void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent ) } } else + { justWarped = false; + } } else + { justWarped = false; + } } else if( m_state == DRAG_ZOOMING ) { @@ -337,7 +341,9 @@ void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent ) justWarped = false; } else + { justWarped = false; + } } } @@ -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. int nMods = 0; int modifiers = 0; + if( aEvent.ShiftDown() ) { nMods += 1; modifiers = WXK_SHIFT; } + if( aEvent.ControlDown() ) { nMods += 1; modifiers = modifiers == 0 ? WXK_CONTROL : modifiers; } + if( aEvent.AltDown() ) { nMods += 1; @@ -440,7 +449,7 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent ) } else { - // When we have muliple mods, forward it for tool handling + // When we have multiple mods, forward it for tool handling aEvent.Skip(); } } @@ -461,6 +470,7 @@ void WX_VIEW_CONTROLS::setState( STATE aNewState ) m_state = aNewState; } + void WX_VIEW_CONTROLS::onButton( wxMouseEvent& aEvent ) { switch( m_state ) @@ -528,9 +538,9 @@ void WX_VIEW_CONTROLS::onEnter( wxMouseEvent& aEvent ) } #if defined( _WIN32 ) || defined( __WXGTK__ ) - // Win32 and some *nix WMs transmit mouse move and wheel events to all controls below the mouse regardless - // of focus. Forcing the focus here will cause the EDA FRAMES to immediately become the - // top level active window. + // Win32 and some *nix WMs transmit mouse move and wheel events to all controls below the + // mouse regardless of focus. Forcing the focus here will cause the EDA FRAMES to immediately + // become the top level active window. if( m_parentPanel->GetParent() != nullptr ) { // this assumes the parent panel's parent is the eda window @@ -552,6 +562,7 @@ void WX_VIEW_CONTROLS::onLeave( wxMouseEvent& aEvent ) #endif } + void WX_VIEW_CONTROLS::onCaptureLost( wxMouseEvent& aEvent ) { // This method must be present to suppress the capture-lost assertion @@ -575,7 +586,7 @@ void WX_VIEW_CONTROLS::onTimer( wxTimerEvent& aEvent ) return; } - #ifdef __WXMSW__ +#ifdef __WXMSW__ // Hackfix: It's possible for the mouse to leave the canvas // without triggering any leave events on windows // Use a MSW only wx function @@ -585,7 +596,7 @@ void WX_VIEW_CONTROLS::onTimer( wxTimerEvent& aEvent ) setState( IDLE ); return; } - #endif +#endif if( !m_parentPanel->HasFocus() && !m_parentPanel->StatusPopupHasFocus() ) { @@ -776,6 +787,7 @@ void WX_VIEW_CONTROLS::CancelDrag() if( m_state == DRAG_PANNING || m_state == DRAG_ZOOMING ) { setState( IDLE ); + #if defined USE_MOUSE_CAPTURE if( !m_settings.m_cursorCaptured && m_parentPanel->HasCapture() ) 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 ); } - // If we are not refreshing because of mouse movement, don't set the modifiers - // because we are refreshing for keyboard movement, which uses the same modifiers for other actions + // If we are not refreshing because of mouse movement, don't set the modifiers because we + // are refreshing for keyboard movement, which uses the same modifiers for other actions refreshMouse( m_updateCursor ); } @@ -1129,6 +1141,7 @@ void WX_VIEW_CONTROLS::UpdateScrollbars() } } + void WX_VIEW_CONTROLS::ForceCursorPosition( bool aEnabled, const VECTOR2D& aPosition ) { VECTOR2D clampedPosition = GetClampedCoords( aPosition ); diff --git a/common/widgets/button_row_panel.cpp b/common/widgets/button_row_panel.cpp index ade91a5fdf..147703610d 100644 --- a/common/widgets/button_row_panel.cpp +++ b/common/widgets/button_row_panel.cpp @@ -50,6 +50,7 @@ BUTTON_ROW_PANEL::BUTTON_ROW_PANEL( wxWindow* aWindow, void BUTTON_ROW_PANEL::addButtons( bool aLeft, const BTN_DEF_LIST& aDefs ) { const int btn_margin = KIUI::GetStdMargin(); + // No button expands to fill horizontally const int btn_proportion = 0; diff --git a/common/widgets/color_swatch.cpp b/common/widgets/color_swatch.cpp index 9b548674c2..19fa670c14 100644 --- a/common/widgets/color_swatch.cpp +++ b/common/widgets/color_swatch.cpp @@ -145,7 +145,8 @@ COLOR_SWATCH::COLOR_SWATCH( wxWindow* aParent, const COLOR4D& aColor, int aID, m_readOnly( false ), 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 ) { diff --git a/common/widgets/filter_combobox.cpp b/common/widgets/filter_combobox.cpp index 92942a811b..4b952fb00b 100644 --- a/common/widgets/filter_combobox.cpp +++ b/common/widgets/filter_combobox.cpp @@ -244,7 +244,6 @@ void FILTER_COMBOPOPUP::onMouseClick( wxMouseEvent& aEvent ) { // Accept a click event from anywhere. Different platform implementations have // different foibles with regard to transient popups and their children. - if( aEvent.GetEventObject() == m_listBox ) { m_listBox->SetSelection( m_listBox->HitTest( aEvent.GetPosition() ) ); @@ -294,7 +293,8 @@ void FILTER_COMBOPOPUP::onKeyDown( wxKeyEvent& aEvent ) case WXK_DOWN: case WXK_NUMPAD_DOWN: 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; case WXK_UP: @@ -387,7 +387,7 @@ void FILTER_COMBOPOPUP::doSetFocus( wxWindow* aWindow ) FILTER_COMBOBOX::FILTER_COMBOBOX( wxWindow *parent, wxWindowID id, const wxPoint &pos, - const wxSize &size, long style ) : + const wxSize &size, long style ) : wxComboCtrl( parent, id, wxEmptyString, pos, size, style|wxCB_READONLY|wxTE_PROCESS_ENTER ), m_filterPopup( nullptr ) { @@ -421,27 +421,23 @@ void FILTER_COMBOBOX::onKeyDown( wxKeyEvent& aEvt ) // even get to us. But just to be safe, we go ahead and skip. aEvt.Skip(); } - // Shift-return accepts dialog else if( ( key == WXK_RETURN || key == WXK_NUMPAD_ENTER ) && aEvt.ShiftDown() ) { wxPostEvent( m_parent, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) ); } - // Return, arrow-down and space-bar all open popup else if( key == WXK_RETURN || key == WXK_NUMPAD_ENTER || key == WXK_DOWN || key == WXK_NUMPAD_DOWN || key == WXK_SPACE ) { Popup(); } - // Non-control characters go to filterbox in popup else if( key > WXK_SPACE && key < WXK_START ) { Popup(); m_filterPopup->OnStartingKey( aEvt ); } - else { aEvt.Skip(); diff --git a/common/widgets/footprint_choice.cpp b/common/widgets/footprint_choice.cpp index 75f95f0353..abbeceac3a 100644 --- a/common/widgets/footprint_choice.cpp +++ b/common/widgets/footprint_choice.cpp @@ -49,7 +49,8 @@ void FOOTPRINT_CHOICE::DoSetPopupControl( wxComboPopup* aPopup ) GetVListBoxComboPopup()->Bind( wxEVT_LEFT_DOWN, &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_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 ) ); } @@ -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 // library component, then find that in the display string and grey it out. - size_t start_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 { if( SafeGetString( aItem ) == wxS( "" ) ) diff --git a/common/widgets/footprint_diff_widget.cpp b/common/widgets/footprint_diff_widget.cpp index cea535b75d..cfffc9d920 100644 --- a/common/widgets/footprint_diff_widget.cpp +++ b/common/widgets/footprint_diff_widget.cpp @@ -178,4 +178,4 @@ void FOOTPRINT_DIFF_WIDGET::onCharHook( wxKeyEvent& aEvent ) { aEvent.Skip(); } -} \ No newline at end of file +} diff --git a/common/widgets/footprint_select_widget.cpp b/common/widgets/footprint_select_widget.cpp index e48a45d738..25a61c50d3 100644 --- a/common/widgets/footprint_select_widget.cpp +++ b/common/widgets/footprint_select_widget.cpp @@ -135,7 +135,6 @@ bool FOOTPRINT_SELECT_WIDGET::UpdateList() // Be careful adding items! "Default" must occupy POS_DEFAULT, // "Other" must occupy POS_OTHER, and the separator must occupy POS_SEPARATOR. - m_fp_sel_ctrl->Append( m_default_footprint.IsEmpty() ? _( "No default footprint" ) : wxS( "[" ) + _( "Default" ) + wxS( "] " ) + m_default_footprint, @@ -145,7 +144,8 @@ bool FOOTPRINT_SELECT_WIDGET::UpdateList() { 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 ) ); ++n_items; diff --git a/common/widgets/grid_button.cpp b/common/widgets/grid_button.cpp index 1ab73a7f32..cee8e7c715 100644 --- a/common/widgets/grid_button.cpp +++ b/common/widgets/grid_button.cpp @@ -37,7 +37,7 @@ GRID_BUTTON_RENDERER* GRID_BUTTON_RENDERER::Clone() const void GRID_BUTTON_RENDERER::Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC& aDc, - const wxRect& aRect, int aRow, int aCol, bool aIsSelected ) + const wxRect& aRect, int aRow, int aCol, bool aIsSelected ) { // erase background wxGridCellRenderer::Draw( aGrid, aAttr, aDc, aRect, aRow, aCol, aIsSelected ); @@ -47,7 +47,7 @@ void GRID_BUTTON_RENDERER::Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC& aDc wxSize GRID_BUTTON_RENDERER::GetBestSize( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC& aDc, - int aRow, int aCol) + int aRow, int aCol) { return m_button.GetSize(); } diff --git a/common/widgets/grid_combobox.cpp b/common/widgets/grid_combobox.cpp index c9160aac0c..5bdd96445a 100644 --- a/common/widgets/grid_combobox.cpp +++ b/common/widgets/grid_combobox.cpp @@ -54,11 +54,13 @@ void GRID_CELL_COMBOBOX::Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler wxGridCellEditor::Create(aParent, aId, aEventHandler); } + wxString GRID_CELL_COMBOBOX::GetValue() const { return Combo()->GetValue(); } + void GRID_CELL_COMBOBOX::SetSize( const wxRect& aRect ) { wxRect rect( aRect ); diff --git a/common/widgets/grid_icon_text_helpers.cpp b/common/widgets/grid_icon_text_helpers.cpp index c1e97f148a..8f40067909 100644 --- a/common/widgets/grid_icon_text_helpers.cpp +++ b/common/widgets/grid_icon_text_helpers.cpp @@ -208,8 +208,8 @@ GRID_CELL_STATUS_ICON_RENDERER::GRID_CELL_STATUS_ICON_RENDERER( int aStatus ) : else { // Dummy bitmap for size - m_bitmap = wxArtProvider::GetBitmap( wxArtProvider::GetMessageBoxIconId( wxICON_INFORMATION ), - wxART_BUTTON ); + m_bitmap = wxArtProvider::GetBitmap( + 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, 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 ) { diff --git a/common/widgets/grid_text_button_helpers.cpp b/common/widgets/grid_text_button_helpers.cpp index e90c9267e2..250c249c55 100644 --- a/common/widgets/grid_text_button_helpers.cpp +++ b/common/widgets/grid_text_button_helpers.cpp @@ -114,6 +114,7 @@ void GRID_CELL_TEXT_BUTTON::StartingKey( wxKeyEvent& event ) default: if( isPrintable ) textEntry->WriteText( static_cast<wxChar>( ch ) ); + break; } } @@ -276,7 +277,8 @@ protected: { 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 ); } @@ -292,10 +294,12 @@ protected: protected: DIALOG_SHIM* m_dlg; wxString m_preselect; + // Lock flag to lock the button to show the FP chooser // true when the button is busy, waiting all footprints loaded to // avoid running more than once the FP chooser bool m_buttonFpChooserLock; + /* * Symbol netlist format: * 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 { 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, wxTE_PROCESS_ENTER | wxBORDER_NONE ), m_dlg( aParentDlg ), @@ -339,12 +344,12 @@ public: Customize( wxCC_IFLAG_HAS_NONSTANDARD_BUTTON ); // Bind event to handle text changes - Bind(wxEVT_TEXT, &TEXT_BUTTON_URL::OnTextChange, this); + Bind( wxEVT_TEXT, &TEXT_BUTTON_URL::OnTextChange, this ); } ~TEXT_BUTTON_URL() { - Unbind(wxEVT_TEXT, &TEXT_BUTTON_URL::OnTextChange, this); + Unbind( wxEVT_TEXT, &TEXT_BUTTON_URL::OnTextChange, this ); } protected: @@ -357,7 +362,7 @@ protected: { wxString filename = GetValue(); - if (filename.IsEmpty() || filename == wxT("~")) + if( filename.IsEmpty() || filename == wxT( "~" ) ) { FILEDLG_OPEN_EMBED_FILE customize; wxFileDialog openFileDialog( this, _( "Open file" ), "", "", "All files (*.*)|*.*", @@ -382,7 +387,7 @@ protected: } else { - GetAssociatedDocument(m_dlg, GetValue(), &m_dlg->Prj(), m_searchStack, m_files); + GetAssociatedDocument( m_dlg, GetValue(), &m_dlg->Prj(), m_searchStack, m_files ); } } @@ -394,10 +399,10 @@ protected: void UpdateButtonBitmaps() { - if (GetValue().IsEmpty()) - SetButtonBitmaps(KiBitmapBundle(BITMAPS::small_folder)); + if( GetValue().IsEmpty() ) + SetButtonBitmaps( KiBitmapBundle( BITMAPS::small_folder ) ); else - SetButtonBitmaps(KiBitmapBundle(BITMAPS::www)); + SetButtonBitmaps( KiBitmapBundle( BITMAPS::www ) ); } DIALOG_SHIM* m_dlg; @@ -406,8 +411,7 @@ protected: }; -void GRID_CELL_URL_EDITOR::Create( wxWindow* aParent, wxWindowID aId, - wxEvtHandler* aEventHandler ) +void GRID_CELL_URL_EDITOR::Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) { m_control = new TEXT_BUTTON_URL( aParent, m_dlg, m_searchStack, m_files ); WX_GRID::CellEditorSetMargins( Combo() ); @@ -562,11 +566,12 @@ void GRID_CELL_PATH_EDITOR::Create( wxWindow* aParent, wxWindowID aId, wxEvtHandler* aEventHandler ) { if( m_fileFilterFn ) - m_control = new TEXT_BUTTON_FILE_BROWSER( aParent, m_dlg, m_grid, m_currentDir, m_fileFilterFn, - m_normalize, m_normalizeBasePath ); + m_control = new TEXT_BUTTON_FILE_BROWSER( aParent, m_dlg, m_grid, m_currentDir, + m_fileFilterFn, m_normalize, + m_normalizeBasePath ); else - m_control = new TEXT_BUTTON_FILE_BROWSER( aParent, m_dlg, m_grid, m_currentDir, m_fileFilter, - m_normalize, m_normalizeBasePath ); + m_control = new TEXT_BUTTON_FILE_BROWSER( aParent, m_dlg, m_grid, m_currentDir, + m_fileFilter, m_normalize, m_normalizeBasePath ); WX_GRID::CellEditorSetMargins( Combo() ); diff --git a/common/widgets/grid_text_helpers.cpp b/common/widgets/grid_text_helpers.cpp index 85e05f7a25..bc99cecaa9 100644 --- a/common/widgets/grid_text_helpers.cpp +++ b/common/widgets/grid_text_helpers.cpp @@ -156,11 +156,13 @@ void GRID_CELL_STC_EDITOR::Create( wxWindow* aParent, wxWindowID aId, wxEvtHandl m_scintillaTricks = new SCINTILLA_TRICKS( stc_ctrl(), wxEmptyString, true, + // onAcceptFn [this]( wxKeyEvent& aEvent ) { HandleReturn( aEvent ); }, + // onCharFn [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 ) { - 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 evtHandler->SetInSetFocus( true ); diff --git a/common/widgets/kistatusbar.cpp b/common/widgets/kistatusbar.cpp index 0748cbe652..b172200135 100644 --- a/common/widgets/kistatusbar.cpp +++ b/common/widgets/kistatusbar.cpp @@ -47,7 +47,7 @@ KISTATUSBAR::KISTATUSBAR( int aNumberFields, wxWindow* parent, wxWindowID id ) : { #ifdef __WXOSX__ // 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 const int ExtraFields = 5; #else @@ -75,6 +75,7 @@ KISTATUSBAR::KISTATUSBAR( int aNumberFields, wxWindow* parent, wxWindowID id ) : int* styles = new int[aNumberFields + ExtraFields]; + for( int i = 0; i < aNumberFields + ExtraFields; i++ ) styles[i] = wxSB_FLAT; @@ -211,6 +212,7 @@ void KISTATUSBAR::SetBackgroundStatusText( const wxString& aTxt ) void KISTATUSBAR::SetNotificationCount(int aCount) { wxString cnt = ""; + if( aCount > 0 ) { cnt = wxString::Format( "%d", aCount ); @@ -237,6 +239,7 @@ void KISTATUSBAR::SetEllipsedTextField( const wxString& aText, int aFieldId ) if( width > 20 ) { wxClientDC dc( this ); + // Gives a margin to the text to be sure it is not clamped at its end int margin = KIUI::GetTextSize( wxT( "XX" ), this ).x; etext = wxControl::Ellipsize( etext, dc, wxELLIPSIZE_MIDDLE, width - margin ); diff --git a/common/widgets/layer_presentation.cpp b/common/widgets/layer_presentation.cpp index abd9f0acbc..b212e60bed 100644 --- a/common/widgets/layer_presentation.cpp +++ b/common/widgets/layer_presentation.cpp @@ -33,7 +33,7 @@ using namespace KIGFX; void LAYER_PRESENTATION::DrawColorSwatch( wxBitmap& aLayerbmp, const COLOR4D& aBackground, - const COLOR4D& aColor ) + const COLOR4D& aColor ) { wxMemoryDC bmpDC; wxBrush brush; @@ -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 }; -std::unique_ptr<wxBitmap> LAYER_PRESENTATION::CreateLayerPairIcon( const COLOR4D& aBgColor, const COLOR4D& aTopColor, - const COLOR4D& aBottomColor, int aScale ) +std::unique_ptr<wxBitmap> LAYER_PRESENTATION::CreateLayerPairIcon( const COLOR4D& aBgColor, + const COLOR4D& aTopColor, + const COLOR4D& aBottomColor, + int aScale ) { auto layerPairBitmap = std::make_unique<wxBitmap>( BM_LAYERICON_SIZE, BM_LAYERICON_SIZE ); @@ -168,4 +170,4 @@ std::unique_ptr<wxBitmap> LAYER_PRESENTATION::CreateLayerPairIcon( int aLeftLaye const COLOR4D bottomColor = getLayerColor( aRightLayer ); return CreateLayerPairIcon( bgColor, topColor, bottomColor, aScale ); -} \ No newline at end of file +} diff --git a/common/widgets/lib_tree.cpp b/common/widgets/lib_tree.cpp index 1b3e5e3b7c..d3075c4e9d 100644 --- a/common/widgets/lib_tree.cpp +++ b/common/widgets/lib_tree.cpp @@ -635,7 +635,8 @@ void LIB_TREE::onQueryCharHook( wxKeyEvent& aKeyStroke ) if( !sel.IsOk() ) 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() ) { diff --git a/common/widgets/listbox_tricks.cpp b/common/widgets/listbox_tricks.cpp index 773a9f698d..6d9b974357 100644 --- a/common/widgets/listbox_tricks.cpp +++ b/common/widgets/listbox_tricks.cpp @@ -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_CUT, wxCommandEventHandler( LISTBOX_TRICKS::OnListBoxCut ) ); 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_CUT, wxCommandEventHandler( LISTBOX_TRICKS::OnListBoxCut ) ); 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.SetSelection( wxNOT_FOUND ); + if( m_listBox.GetCount() > 0 ) m_listBox.SetSelection( std::max( 0, selections[0] - 1 ) ); @@ -117,6 +120,7 @@ wxArrayString LISTBOX_TRICKS::listBoxGetSelected() const m_listBox.GetSelections( selections ); wxArrayString result; + for( size_t ii = 0; ii < selections.GetCount(); ii++ ) result.Add( m_listBox.GetString( selections[ii] ) ); @@ -150,6 +154,7 @@ void LISTBOX_TRICKS::listBoxCopy() wxArrayString filters = listBoxGetSelected(); wxString result; + for( const wxString& filter : filters ) { result += filter + wxT( "\n" ); @@ -166,6 +171,7 @@ void LISTBOX_TRICKS::listBoxCopy() void LISTBOX_TRICKS::listBoxPaste() { wxArrayString lines; + if( wxTheClipboard->Open() ) { wxTextDataObject data; @@ -192,6 +198,7 @@ void LISTBOX_TRICKS::listBoxPaste() m_listBox.InsertItems( lines, insertAt ); m_listBox.SetSelection( wxNOT_FOUND ); + for( size_t ii = insertAt; ii < insertAt + lines.GetCount(); ii++ ) m_listBox.SetSelection( ii ); @@ -276,7 +283,9 @@ void LISTBOX_TRICKS::OnListBoxKeyDown( wxKeyEvent& aEvent ) } } else + { aEvent.Skip(); + } } } @@ -308,4 +317,4 @@ void LISTBOX_TRICKS::OnListBoxPaste( wxCommandEvent& aEvent ) void LISTBOX_TRICKS::OnListBoxDuplicate( wxCommandEvent& aEvent ) { listBoxDuplicateSelected(); -} \ No newline at end of file +} diff --git a/common/widgets/mathplot.cpp b/common/widgets/mathplot.cpp index 1040e35e05..5a8f498457 100644 --- a/common/widgets/mathplot.cpp +++ b/common/widgets/mathplot.cpp @@ -138,14 +138,14 @@ void mpInfoLayer::Plot( wxDC& dc, mpWindow& w ) if( scry == 0 ) scry = 1; - if( (m_winX != scrx) || (m_winY != scry) ) + if( ( m_winX != scrx ) || ( m_winY != scry ) ) { if( m_winX > 1 ) - m_dim.x = (int) floor( (double) (m_dim.x * scrx / m_winX) ); + m_dim.x = (int) floor( (double) ( m_dim.x * scrx / m_winX ) ); if( m_winY > 1 ) { - m_dim.y = (int) floor( (double) (m_dim.y * scry / m_winY) ); + m_dim.y = (int) floor( (double) ( m_dim.y * scry / m_winY ) ); UpdateReference(); } @@ -201,11 +201,11 @@ void mpInfoLegend::Plot( wxDC& dc, mpWindow& w ) if( m_winX != scrx || m_winY != scry ) { if( m_winX > 1 ) - m_dim.x = (int) floor( (double) (m_dim.x * scrx / m_winX) ); + m_dim.x = (int) floor( (double) ( m_dim.x * scrx / m_winX ) ); if( m_winY > 1 ) { - m_dim.y = (int) floor( (double) (m_dim.y * scry / m_winY) ); + m_dim.y = (int) floor( (double) ( m_dim.y * scry / m_winY ) ); UpdateReference(); } @@ -309,8 +309,9 @@ void mpFX::Plot( wxDC& dc, mpWindow& w ) { iy = w.y2p( GetY( w.p2x( i ) ) ); - // Draw the point only if you can draw outside margins or if the point is inside margins - if( (iy >= minYpx) && (iy <= maxYpx) ) + // Draw the point only if you can draw outside margins or if the point is + // inside margins + if( ( iy >= minYpx ) && ( iy <= maxYpx ) ) dc.DrawPoint( i, iy ); } } @@ -320,7 +321,8 @@ void mpFX::Plot( wxDC& dc, mpWindow& w ) { 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 ) dc.DrawLine( i, iy, i, iy ); } @@ -333,10 +335,11 @@ void mpFX::Plot( wxDC& dc, mpWindow& w ) wxCoord tx, ty; dc.GetTextExtent( m_name, &tx, &ty ); - if( (m_flags & mpALIGNMASK) == mpALIGN_RIGHT ) - tx = (w.GetScrX() - tx) - w.GetMarginRight() - 8; - else if( (m_flags & mpALIGNMASK) == mpALIGN_CENTER ) - tx = ( (w.GetScrX() - w.GetMarginRight() - w.GetMarginLeft() - tx) / 2 ) + w.GetMarginLeft(); + if( ( m_flags & mpALIGNMASK ) == mpALIGN_RIGHT ) + tx = ( w.GetScrX() - tx ) - w.GetMarginRight() - 8; + else if( ( m_flags & mpALIGNMASK ) == mpALIGN_CENTER ) + tx = ( ( w.GetScrX() - w.GetMarginRight() - w.GetMarginLeft() - tx ) / 2 ) + + w.GetMarginLeft(); else tx = w.GetMarginLeft() + 8; @@ -348,6 +351,7 @@ void mpFX::Plot( wxDC& dc, mpWindow& w ) IMPLEMENT_ABSTRACT_CLASS( mpFY, mpLayer ) + mpFY::mpFY( const wxString& name, int flags ) { SetName( name ); @@ -375,7 +379,7 @@ void mpFY::Plot( wxDC& dc, mpWindow& w ) { ix = w.x2p( GetX( w.p2y( i ) ) ); - if( (ix >= startPx) && (ix <= endPx) ) + if( ( ix >= startPx ) && ( ix <= endPx ) ) dc.DrawPoint( ix, i ); } } @@ -385,7 +389,7 @@ void mpFY::Plot( wxDC& dc, mpWindow& w ) { ix = w.x2p( GetX( w.p2y( i ) ) ); - if( (ix >= startPx) && (ix <= endPx) ) + if( ( ix >= startPx ) && ( ix <= endPx ) ) dc.DrawLine( ix, i, ix, i ); } } @@ -397,10 +401,11 @@ void mpFY::Plot( wxDC& dc, mpWindow& w ) wxCoord tx, ty; dc.GetTextExtent( m_name, &tx, &ty ); - if( (m_flags & mpALIGNMASK) == mpALIGN_TOP ) + if( ( m_flags & mpALIGNMASK ) == mpALIGN_TOP ) ty = w.GetMarginTop() + 8; - else if( (m_flags & mpALIGNMASK) == mpALIGN_CENTER ) - ty = ( ( w.GetScrY() - w.GetMarginTop() - w.GetMarginBottom() - ty) / 2 ) + w.GetMarginTop(); + else if( ( m_flags & mpALIGNMASK ) == mpALIGN_CENTER ) + ty = ( ( w.GetScrY() - w.GetMarginTop() - w.GetMarginBottom() - ty ) / 2 ) + + w.GetMarginTop(); else ty = w.GetScrY() - 8 - ty - w.GetMarginBottom(); @@ -412,6 +417,7 @@ void mpFY::Plot( wxDC& dc, mpWindow& w ) IMPLEMENT_ABSTRACT_CLASS( mpFXY, mpLayer ) + mpFXY::mpFXY( const wxString& name, int flags ) { SetName( name ); @@ -500,7 +506,7 @@ void mpFXY::Plot( wxDC& dc, mpWindow& w ) for( auto& iy: ys ) { - if( (ix >= startPx) && (ix <= endPx) && (iy >= minYpx) && (iy <= maxYpx) ) + if( ( ix >= startPx ) && ( ix <= endPx ) && ( iy >= minYpx ) && ( iy <= maxYpx ) ) { // for some reason DrawPoint does not use the current pen, so we use // DrawLine for fat pens @@ -662,17 +668,17 @@ void mpFXY::Plot( wxDC& dc, mpWindow& w ) wxCoord tx, ty; dc.GetTextExtent( m_name, &tx, &ty ); - if( (m_flags & mpALIGNMASK) == mpALIGN_NW ) + if( ( m_flags & mpALIGNMASK ) == mpALIGN_NW ) { tx = minDrawX + 8; ty = maxDrawY + 8; } - else if( (m_flags & mpALIGNMASK) == mpALIGN_NE ) + else if( ( m_flags & mpALIGNMASK ) == mpALIGN_NE ) { tx = maxDrawX - tx - 8; ty = maxDrawY + 8; } - else if( (m_flags & mpALIGNMASK) == mpALIGN_SE ) + else if( ( m_flags & mpALIGNMASK ) == mpALIGN_SE ) { tx = maxDrawX - tx - 8; ty = minDrawY - ty - 8; @@ -834,14 +840,14 @@ void mpScaleY::computeSlaveTicks( mpWindow& w ) double p0 = m_masterScale->TransformToPlot( m_masterScale->m_tickValues[0] ); double p1 = m_masterScale->TransformToPlot( m_masterScale->m_tickValues[1] ); - m_scale = 1.0 / ( m_maxV - m_minV ); - m_offset = -m_minV; + m_scale = 1.0 / ( m_maxV - m_minV ); + m_offset = -m_minV; - double y_slave0 = p0 / m_scale; - double y_slave1 = p1 / m_scale; + double y_slave0 = p0 / m_scale; + double y_slave1 = p1 / m_scale; - double dy_slave = (y_slave1 - y_slave0); - double exponent = floor( log10( dy_slave ) ); + double dy_slave = ( y_slave1 - y_slave0 ); + double exponent = floor( log10( dy_slave ) ); double base = dy_slave / pow( 10.0, exponent ); double dy_scaled = ceil( 2.0 * base ) / 2.0 * pow( 10.0, exponent ); @@ -920,7 +926,7 @@ void mpScaleY::recalculateTicks( wxDC& dc, mpWindow& w ) // Half the number of ticks according to window size. // For each 32 device context units, is possible to add a new tick. - while( numberSteps >= m_scrY/32.0 ) + while( numberSteps >= m_scrY / 32.0 ) { bestStep *= 2; numberSteps = floor( ( maxVvis - minVvis ) / bestStep ); @@ -1023,6 +1029,7 @@ IMPLEMENT_ABSTRACT_CLASS( mpScaleXBase, mpLayer ) IMPLEMENT_DYNAMIC_CLASS( mpScaleX, mpScaleXBase ) IMPLEMENT_DYNAMIC_CLASS( mpScaleXLog, mpScaleXBase ) + mpScaleXBase::mpScaleXBase( const wxString& name, int flags, bool ticks, unsigned int type ) { SetName( name ); @@ -1084,7 +1091,9 @@ void mpScaleXBase::Plot( wxDC& dc, mpWindow& w ) wxCoord maxYpx = w.GetScrY() - w.GetMarginBottom(); // 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(); for( double tp : m_tickValues ) @@ -1144,14 +1153,14 @@ void mpScaleXBase::Plot( wxDC& dc, mpWindow& w ) double px = TransformToPlot( tickLabel.pos ); const int p = (int) ( ( px - w.GetPosX() ) * w.GetScaleX() ); - if( (p >= startPx) && (p <= endPx) ) + if( ( p >= startPx ) && ( p <= endPx ) ) { // Write ticks labels in s string wxString s = tickLabel.label; dc.GetTextExtent( s, &tx, &ty ); - if( (m_flags == mpALIGN_BORDER_BOTTOM) || (m_flags == mpALIGN_TOP) ) + if( ( m_flags == mpALIGN_BORDER_BOTTOM ) || ( m_flags == mpALIGN_TOP ) ) dc.DrawText( s, p - tx / 2, orgy - 4 - ty ); else dc.DrawText( s, p - tx / 2, orgy + 4 ); @@ -1168,7 +1177,7 @@ void mpScaleXBase::Plot( wxDC& dc, mpWindow& w ) break; case mpALIGN_BOTTOM: - dc.DrawText( m_name, (endPx + startPx) / 2 - tx / 2, orgy + 6 + labelH ); + dc.DrawText( m_name, ( endPx + startPx ) / 2 - tx / 2, orgy + 6 + labelH ); break; case mpALIGN_CENTER: @@ -1177,7 +1186,7 @@ void mpScaleXBase::Plot( wxDC& dc, mpWindow& w ) case mpALIGN_TOP: if( w.GetMarginTop() > (ty + labelH + 8) ) - dc.DrawText( m_name, (endPx - startPx - tx) >> 1, orgy - 6 - ty - labelH ); + dc.DrawText( m_name, ( endPx - startPx - tx ) >> 1, orgy - 6 - ty - labelH ); else dc.DrawText( m_name, extend - tx - 4, orgy + 4 ); @@ -1196,6 +1205,7 @@ void mpScaleXBase::Plot( wxDC& dc, mpWindow& w ) IMPLEMENT_DYNAMIC_CLASS( mpScaleY, mpLayer ) + mpScaleY::mpScaleY( const wxString& name, int flags, bool ticks ) { SetName( name ); @@ -1244,6 +1254,7 @@ void mpScaleY::Plot( wxDC& dc, mpWindow& w ) wxCoord endPx = w.GetScrX() - w.GetMarginRight(); wxCoord minYpx = w.GetMarginTop(); wxCoord maxYpx = w.GetScrY() - w.GetMarginBottom(); + // Draw line dc.DrawLine( orgx, minYpx, orgx, maxYpx ); @@ -1252,6 +1263,7 @@ void mpScaleY::Plot( wxDC& dc, mpWindow& w ) wxString fmt; int labelW = 0; + // Before staring cycle, calculate label height int labelHeight = 0; s.Printf( fmt, 0 ); @@ -1301,7 +1313,8 @@ void mpScaleY::Plot( wxDC& dc, mpWindow& w ) s = tickLabel.label; 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 ); else 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 - dc.GetTextExtent( m_name, &tx, &ty ); switch( m_nameFlags ) @@ -1368,21 +1380,26 @@ EVT_MENU( mpID_ZOOM_UNDO, mpWindow::onZoomUndo ) EVT_MENU( mpID_ZOOM_REDO, mpWindow::onZoomRedo ) END_EVENT_TABLE() + mpWindow::mpWindow() : mpWindow( DelegatingContructorTag() ) { initializeGraphicsContext(); } + mpWindow::mpWindow( wxWindow* parent, wxWindowID id ) : mpWindow( DelegatingContructorTag(), parent, id, wxDefaultPosition, wxDefaultSize, 0, 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_REDO, _( "Redo Last Zoom" ), _( "Return zoom to level prior to last zoom undo" ) ); + m_popmenu.Append( mpID_ZOOM_UNDO, _( "Undo Last Zoom" ), + _( "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.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_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_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 void mpWindow::OnMouseMiddleDown( wxMouseEvent& event ) { @@ -1802,6 +1820,7 @@ void mpWindow::ZoomOut( const wxPoint& centerPoint, double zoomFactor, wxOrienta { if( zoomFactor == 0 ) zoomFactor = 1.0; + 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 ); - // 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. AdjustLimitedView(); // These additional checks are needed because AdjustLimitedView only adjusts the position // and not the scale. wxOrientation directionsNeedingRefitting = ViewNeedsRefitting( wxBOTH ); + if( directionsNeedingRefitting != 0 ) Fit( m_minX, m_maxX, m_minY, m_maxY, nullptr, nullptr, directionsNeedingRefitting ); } @@ -1918,8 +1938,8 @@ void mpWindow::OnFit( wxCommandEvent& WXUNUSED( event ) ) void mpWindow::OnCenter( wxCommandEvent& WXUNUSED( event ) ) { GetClientSize( &m_scrX, &m_scrY ); - int centerX = (m_scrX - m_marginLeft - m_marginRight) / 2; - int centerY = (m_scrY - m_marginTop - m_marginBottom) / 2; + int centerX = ( m_scrX - m_marginLeft - m_marginRight ) / 2; + int centerY = ( m_scrY - m_marginTop - m_marginBottom ) / 2; SetPos( p2x( m_clickedX - centerX ), p2y( m_clickedY - centerY ) ); } @@ -2081,12 +2101,14 @@ void mpWindow::OnPaint( wxPaintEvent& WXUNUSED( event ) ) paintDC.Blit( 0, 0, m_scrX, m_scrY, targetDC, 0, 0 ); } + void mpWindow::DoZoom( const wxPoint& centerPoint, double zoomFactor, wxOrientation directions ) { if( m_yLocked ) { if( directions == wxVERTICAL ) return; + directions = wxHORIZONTAL; } @@ -2244,6 +2266,7 @@ void mpWindow::PerformMouseWheelAction( wxMouseEvent& event, MouseWheelAction ac m_desiredYmin + changeUnitsY ); UpdateAll(); } + break; case MouseWheelAction::ZOOM: @@ -2251,6 +2274,7 @@ void mpWindow::PerformMouseWheelAction( wxMouseEvent& event, MouseWheelAction ac ZoomIn( clickPt ); else ZoomOut( clickPt ); + break; case MouseWheelAction::ZOOM_HORIZONTALLY: @@ -2258,6 +2282,7 @@ void mpWindow::PerformMouseWheelAction( wxMouseEvent& event, MouseWheelAction ac ZoomIn( clickPt, zoomIncrementalFactor, wxHORIZONTAL ); else ZoomOut( clickPt, zoomIncrementalFactor, wxHORIZONTAL ); + break; case MouseWheelAction::ZOOM_VERTICALLY: @@ -2265,9 +2290,11 @@ void mpWindow::PerformMouseWheelAction( wxMouseEvent& event, MouseWheelAction ac ZoomIn( clickPt, zoomIncrementalFactor, wxVERTICAL ); else ZoomOut( clickPt, zoomIncrementalFactor, wxVERTICAL ); + break; - default: break; + default: + break; } } @@ -2460,14 +2487,16 @@ void mpWindow::SetColourTheme( const wxColour& bgColour, const wxColour& drawCol { 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 ); layer->SetPen( axisPen ); } 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 ); layer->SetPen( infoPen ); } @@ -2534,7 +2563,7 @@ void mpWindow::initializeGraphicsContext() IMPLEMENT_DYNAMIC_CLASS( mpFXYVector, mpFXY ) -// Constructor + mpFXYVector::mpFXYVector( const wxString& name, int flags ) : mpFXY( name, flags ) { @@ -2550,7 +2579,7 @@ mpFXYVector::mpFXYVector( const wxString& name, int flags ) : double mpScaleX::TransformToPlot( double x ) const { - return (x + m_offset) * m_scale; + return ( x + m_offset ) * m_scale; } @@ -2562,7 +2591,7 @@ double mpScaleX::TransformFromPlot( double xplot ) const double mpScaleY::TransformToPlot( double x ) const { - return (x + m_offset) * m_scale; + return ( x + m_offset ) * m_scale; } @@ -2577,7 +2606,7 @@ double mpScaleXLog::TransformToPlot( double x ) const double xlogmin = log10( m_minV ); double xlogmax = log10( m_maxV ); - return ( log10( x ) - xlogmin) / (xlogmax - xlogmin); + return ( log10( x ) - xlogmin ) / ( xlogmax - xlogmin ); } @@ -2586,7 +2615,7 @@ double mpScaleXLog::TransformFromPlot( double xplot ) const double xlogmin = log10( m_minV ); double xlogmax = log10( m_maxV ); - return pow( 10.0, xplot * (xlogmax - xlogmin) + xlogmin ); + return pow( 10.0, xplot * ( xlogmax - xlogmin ) + xlogmin ); } diff --git a/common/widgets/number_badge.cpp b/common/widgets/number_badge.cpp index a9a66b1a9d..629b693ba4 100644 --- a/common/widgets/number_badge.cpp +++ b/common/widgets/number_badge.cpp @@ -122,6 +122,7 @@ void NUMBER_BADGE::SetTextSize( int aSize ) #define PLATFORM_FUDGE_Y 1.0 #endif + void NUMBER_BADGE::computeSize() { 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.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 ); } diff --git a/common/widgets/paged_dialog.cpp b/common/widgets/paged_dialog.cpp index 14d8c95ecc..6d3d22d932 100644 --- a/common/widgets/paged_dialog.cpp +++ b/common/widgets/paged_dialog.cpp @@ -45,8 +45,9 @@ std::map<wxString, wxString> g_lastPage; std::map<wxString, wxString> g_lastParentPage; -PAGED_DIALOG::PAGED_DIALOG( wxWindow* aParent, const wxString& aTitle, bool aShowReset, bool aShowOpenFolder, - const wxString& aAuxiliaryAction, const wxSize& aInitialSize ) : +PAGED_DIALOG::PAGED_DIALOG( wxWindow* aParent, const wxString& aTitle, bool aShowReset, + bool aShowOpenFolder, const wxString& aAuxiliaryAction, + const wxSize& aInitialSize ) : DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, aInitialSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ), m_auxiliaryButton( nullptr ), @@ -92,7 +93,8 @@ PAGED_DIALOG::PAGED_DIALOG( wxWindow* aParent, const wxString& aTitle, bool aSho #else m_openPrefsDirButton = new wxButton( this, wxID_ANY, _( "Open Preferences Directory" ) ); #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 ) { - 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 ); @@ -204,7 +207,8 @@ PAGED_DIALOG::~PAGED_DIALOG() 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 ); diff --git a/common/widgets/properties_panel.cpp b/common/widgets/properties_panel.cpp index f40cee2420..85df99f4f7 100644 --- a/common/widgets/properties_panel.cpp +++ b/common/widgets/properties_panel.cpp @@ -121,8 +121,10 @@ PROPERTIES_PANEL::PROPERTIES_PANEL( wxWindow* aParent, EDA_BASE_FRAME* aFrame ) m_grid->CenterSplitter(); Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( PROPERTIES_PANEL::onCharHook ), nullptr, this ); - Connect( wxEVT_PG_CHANGED, wxPropertyGridEventHandler( PROPERTIES_PANEL::valueChanged ), nullptr, this ); - Connect( wxEVT_PG_CHANGING, wxPropertyGridEventHandler( PROPERTIES_PANEL::valueChanging ), nullptr, this ); + Connect( wxEVT_PG_CHANGED, wxPropertyGridEventHandler( PROPERTIES_PANEL::valueChanged ), + nullptr, this ); + Connect( wxEVT_PG_CHANGING, wxPropertyGridEventHandler( PROPERTIES_PANEL::valueChanging ), + nullptr, this ); Connect( wxEVT_SHOW, wxShowEventHandler( PROPERTIES_PANEL::onShow ), nullptr, this ); Bind( wxEVT_PG_COL_END_DRAG, @@ -205,7 +207,8 @@ void PROPERTIES_PANEL::rebuildProperties( const SELECTION& aSelection ) std::set<PROPERTY_BASE*> commonProps; 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() ); diff --git a/common/widgets/search_pane_tab.cpp b/common/widgets/search_pane_tab.cpp index 4cc35c4944..de6906160e 100644 --- a/common/widgets/search_pane_tab.cpp +++ b/common/widgets/search_pane_tab.cpp @@ -163,6 +163,7 @@ void SEARCH_PANE_LISTVIEW::OnChar( wxKeyEvent& aEvent ) if( wxTheClipboard->Open() ) { wxString txt; + for( int row = 0; row < GetItemCount(); row++ ) { if( GetItemState( row, wxLIST_STATE_SELECTED ) == wxLIST_STATE_SELECTED ) @@ -172,10 +173,12 @@ void SEARCH_PANE_LISTVIEW::OnChar( wxKeyEvent& aEvent ) if( GetColumnWidth( col ) > 0 ) { txt += GetItemText( row, col ); + if( row <= GetItemCount() - 1 ) txt += wxT( "\t" ); } } + txt += wxT( "\n" ); } } diff --git a/common/widgets/split_button.cpp b/common/widgets/split_button.cpp index d46489e93f..a5dfc95ef1 100644 --- a/common/widgets/split_button.cpp +++ b/common/widgets/split_button.cpp @@ -35,7 +35,8 @@ SPLIT_BUTTON::SPLIT_BUTTON( wxWindow* aParent, wxWindowID aId, const wxString& aLabel, 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_arrowButtonWidth = FromDIP( 20 ); // just a fixed eyeballed constant width @@ -274,9 +275,10 @@ void SPLIT_BUTTON::OnPaint( wxPaintEvent& WXUNUSED( aEvent ) ) // wxRendereNative doesn't handle dark mode on OSX. drawBackground( r1 ); #else - #ifdef _WXMSW_ - r1.width += 2; - #endif + +#ifdef _WXMSW_ + r1.width += 2; +#endif wxRendererNative::Get().DrawPushButton( this, dc, r1, m_stateButton ); #endif diff --git a/common/widgets/std_bitmap_button.cpp b/common/widgets/std_bitmap_button.cpp index 97a1d21fab..ccab7e2e00 100644 --- a/common/widgets/std_bitmap_button.cpp +++ b/common/widgets/std_bitmap_button.cpp @@ -42,6 +42,7 @@ STD_BITMAP_BUTTON::STD_BITMAP_BUTTON( wxWindow* aParent, wxWindowID aId, if( aSize == wxDefaultSize ) { wxSize defaultSize = wxButton::GetDefaultSize( aParent ); + #ifndef __WXMSW__ defaultSize.IncBy( 1 ); #endif @@ -153,7 +154,7 @@ void STD_BITMAP_BUTTON::OnLeftButtonUp( wxMouseEvent& aEvent ) Refresh(); wxEvtHandler* pEventHandler = GetEventHandler(); - wxASSERT( pEventHandler ); + wxCHECK( pEventHandler, /* void */ ); pEventHandler->CallAfter( [this]() @@ -225,9 +226,10 @@ void STD_BITMAP_BUTTON::OnPaint( wxPaintEvent& WXUNUSED( aEvent ) ) // wxRendereNative doesn't handle dark mode on OSX. drawBackground( r1 ); #else - #ifdef __WXMSW__ - r1.width += 1; - #endif + +#ifdef __WXMSW__ + r1.width += 1; +#endif wxRendererNative::Get().DrawPushButton( this, dc, r1, m_stateButton ); #endif diff --git a/common/widgets/stepped_slider.cpp b/common/widgets/stepped_slider.cpp index 6bf2984ffc..57020d9911 100644 --- a/common/widgets/stepped_slider.cpp +++ b/common/widgets/stepped_slider.cpp @@ -79,11 +79,14 @@ void STEPPED_SLIDER::OnScroll( wxScrollEvent& aEvent ) if( aEvent.GetEventType() == wxEVT_SCROLL_CHANGED ) { #endif // __WXMSW__ + const int value = GetValue(); const int rounded = value - value % m_step; SetValue( rounded ); + #ifdef __WXMSW__ } #endif // __WXMSW__ + aEvent.Skip(); } diff --git a/common/widgets/ui_common.cpp b/common/widgets/ui_common.cpp index 9ef00f1566..b2f3204d8c 100644 --- a/common/widgets/ui_common.cpp +++ b/common/widgets/ui_common.cpp @@ -42,7 +42,7 @@ #include <string_utils.h> -const wxString KIUI::s_FocusStealableInputName = wxS( "KI_NOFOCUS"); +const wxString KIUI::s_FocusStealableInputName = wxS( "KI_NOFOCUS" ); int KIUI::GetStdMargin() @@ -118,6 +118,7 @@ wxFont getGUIFont( wxWindow* aWindow, int aRelativeSize ) // https://trac.wxwidgets.org/ticket/19210 if( font.GetFaceName().IsEmpty() ) font.SetFaceName( wxS( "San Francisco" ) ); + // OSX 10.1 .. 10.9: Lucida Grande // OSX 10.10: Helvetica Neue // OSX 10.11 .. : San Francisco @@ -310,7 +311,8 @@ bool KIUI::IsInputControlEditable( wxWindow* aFocus ) else if( searchCtrl ) 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; } diff --git a/common/widgets/unit_binder.cpp b/common/widgets/unit_binder.cpp index 54716aab78..e4c0bda375 100644 --- a/common/widgets/unit_binder.cpp +++ b/common/widgets/unit_binder.cpp @@ -561,6 +561,7 @@ double UNIT_BINDER::setPrecision( double aValue, bool aValueUsesUserUnits ) cons { int scale = pow( 10, m_precision ); int64_t tmp = aValue; + if( !aValueUsesUserUnits ) { tmp = EDA_UNIT_UTILS::UI::ToUserUnit( *m_iuScale, m_units, aValue ) * scale; diff --git a/common/widgets/widget_hotkey_list.cpp b/common/widgets/widget_hotkey_list.cpp index 842046b32a..133dea2a4f 100644 --- a/common/widgets/widget_hotkey_list.cpp +++ b/common/widgets/widget_hotkey_list.cpp @@ -105,13 +105,15 @@ public: 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 ); wxFlexGridSizer* fgsizer = new wxFlexGridSizer( 2 ); 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 ); wxStaticText* cmd_label_1 = new wxStaticText( panelDisplayCurrent, wxID_ANY, wxEmptyString ); @@ -119,7 +121,8 @@ public: cmd_label_1->SetLabel( aName ); 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 ); wxStaticText* key_label_1 = new wxStaticText( panelDisplayCurrent, wxID_ANY, wxEmptyString ); @@ -129,7 +132,8 @@ public: 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 ); @@ -158,7 +162,9 @@ public: if( dialog.ShowModal() == wxID_OK ) { if( dialog.m_resetkey ) + { return std::make_optional( 0 ); + } else { long key = WIDGET_HOTKEY_LIST::MapKeypressToKeycode( dialog.m_event ); @@ -269,7 +275,7 @@ public: return true; // Match in the (translated) filter string - const auto normedInfo = wxGetTranslation( aHotkey.m_Actions[ 0 ]->GetFriendlyName() ).Upper(); + const auto normedInfo = wxGetTranslation( aHotkey.m_Actions[0]->GetFriendlyName() ).Upper(); if( normedInfo.Contains( m_normalised_filter_str ) ) return true; @@ -365,8 +371,8 @@ void WIDGET_HOTKEY_LIST::editItem( wxTreeListItem aItem, int aEditId ) return; wxString name = GetItemText( aItem, 0 ); - wxString current_key = - aEditId == ID_EDIT_HOTKEY ? GetItemText( aItem, 1 ) : GetItemText( aItem, 2 ); + wxString current_key = aEditId == ID_EDIT_HOTKEY ? GetItemText( aItem, 1 ) + : GetItemText( aItem, 2 ); 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 ); } else if( aResetId == ID_CLEAR ) + { changeHotkey( changed_hk, 0, false ); + } else if( aResetId == ID_CLEAR_ALT ) + { changeHotkey( changed_hk, 0, true ); + } else if( aResetId == ID_DEFAULT ) { changeHotkey( changed_hk, changed_hk.m_Actions[0]->GetDefaultHotKey(), false ); diff --git a/common/widgets/wx_collapsible_pane.cpp b/common/widgets/wx_collapsible_pane.cpp index 13b952f6b3..c3ebc5786a 100644 --- a/common/widgets/wx_collapsible_pane.cpp +++ b/common/widgets/wx_collapsible_pane.cpp @@ -222,7 +222,7 @@ bool WX_COLLAPSIBLE_PANE_HEADER::Create( wxWindow* aParent, wxWindowID aId, cons const wxPoint& aPos, const wxSize& aSize, long aStyle, const wxValidator& aValidator, const wxString& aName ) { - if ( !wxControl::Create( aParent, aId, aPos, aSize, aStyle, aValidator, aName ) ) + if( !wxControl::Create( aParent, aId, aPos, aSize, aStyle, aValidator, aName ) ) return false; SetLabel( aLabel ); @@ -395,7 +395,8 @@ void WX_COLLAPSIBLE_PANE_HEADER::onChar( wxKeyEvent& aEvent ) 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 ); // The right corner of the triangle is located halfway down from the top and 3/4 across the area diff --git a/common/widgets/wx_grid.cpp b/common/widgets/wx_grid.cpp index 0106523464..99bef4e1b6 100644 --- a/common/widgets/wx_grid.cpp +++ b/common/widgets/wx_grid.cpp @@ -76,7 +76,8 @@ wxGridCellAttr* WX_GRID_TABLE_BASE::enhanceAttr( wxGridCellAttr* aInputAttr, int 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 ); } @@ -150,8 +151,8 @@ public: /** - * Attribute provider that provides attributes (or modifies the existing attribute) to alternate a row color - * between the odd and even rows. + * Attribute provider that provides attributes (or modifies the existing attribute) to alternate + * a row color between the odd and even rows. */ class WX_GRID_ALT_ROW_COLOR_PROVIDER : public wxGridCellAttrProvider { @@ -177,7 +178,8 @@ public: { 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 ) ) return cellAttr.release(); @@ -214,8 +216,10 @@ WX_GRID::WX_GRID( wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxS SetLabelFont( KIUI::GetControlFont( 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_HIDDEN, wxGridEventHandler( WX_GRID::onCellEditorHidden ), nullptr, this ); + Connect( wxEVT_GRID_EDITOR_SHOWN, wxGridEventHandler( WX_GRID::onCellEditorShown ), nullptr, + this ); + Connect( wxEVT_GRID_EDITOR_HIDDEN, wxGridEventHandler( WX_GRID::onCellEditorHidden ), nullptr, + this ); } @@ -224,9 +228,12 @@ WX_GRID::~WX_GRID() if( m_weOwnTable ) DestroyTable( GetTable() ); - Disconnect( wxEVT_GRID_EDITOR_SHOWN, wxGridEventHandler( WX_GRID::onCellEditorShown ), nullptr, this ); - Disconnect( wxEVT_GRID_EDITOR_HIDDEN, wxGridEventHandler( WX_GRID::onCellEditorHidden ), nullptr, this ); - Disconnect( wxEVT_DPI_CHANGED, wxDPIChangedEventHandler( WX_GRID::onDPIChanged ), nullptr, this ); + Disconnect( wxEVT_GRID_EDITOR_SHOWN, wxGridEventHandler( WX_GRID::onCellEditorShown ), 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 ); } ); - /// This terrible hack is a way to avoid the incredibly disruptive resizing of grids that happens on Macs - /// when moving a window between monitors of different DPIs. + /// This terrible hack is a way to avoid the incredibly disruptive resizing of grids that + /// happens on Macs when moving a window between monitors of different DPIs. #ifndef __WXMAC__ aEvt.Skip(); #endif @@ -296,7 +303,8 @@ void WX_GRID::SetTable( wxGridTableBase* aTable, bool aTakeOwnership ) EnableAlternateRowColors( Pgm().GetCommonSettings()->m_Appearance.grid_striping ); 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; } @@ -447,7 +455,8 @@ void WX_GRID::DestroyTable( wxGridTableBase* aTable ) CommitPendingChanges( true /* quiet mode */ ); 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 ); delete aTable; @@ -576,7 +585,7 @@ void WX_GRID::DrawColLabel( wxDC& dc, int col ) void WX_GRID::DrawRowLabel( wxDC& dc, int row ) { - if ( GetRowHeight( row ) <= 0 || m_rowLabelWidth <= 0 ) + if( GetRowHeight( row ) <= 0 || m_rowLabelWidth <= 0 ) return; wxRect rect( 0, GetRowTop( row ), m_rowLabelWidth, GetRowHeight( row ) ); @@ -789,7 +798,8 @@ int WX_GRID::GetVisibleWidth( int aCol, bool aHeader, bool aContents, bool aKeep { 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++ ) diff --git a/common/widgets/wx_grid_autosizer.cpp b/common/widgets/wx_grid_autosizer.cpp index a728e9a79b..91248f980f 100644 --- a/common/widgets/wx_grid_autosizer.cpp +++ b/common/widgets/wx_grid_autosizer.cpp @@ -34,10 +34,12 @@ WX_GRID_AUTOSIZER::WX_GRID_AUTOSIZER( wxGrid& aGrid, COL_MIN_WIDTHS aAutosizedCo m_flexibleCol( aFlexibleCol ) { const int colCount = m_grid.GetNumberCols(); + for( const auto& [colIndex, width] : m_autosizedCols ) { wxASSERT_MSG( colIndex < colCount, "Autosized column does not exist in grid" ); } + wxASSERT_MSG( m_flexibleCol < colCount, "Flexible column index does not exist in grid" ); 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() { if( m_gridWidthsDirty ) @@ -70,6 +73,7 @@ void WX_GRID_AUTOSIZER::recomputeGridWidths() m_grid.GetClientRect().GetWidth() - wxSystemSettings::GetMetric( wxSYS_VSCROLL_X ); std::optional<int> flexibleMinWidth; + for( const auto& [colIndex, minWidth] : m_autosizedCols ) { m_grid.AutoSizeColumn( colIndex ); @@ -102,12 +106,15 @@ void WX_GRID_AUTOSIZER::recomputeGridWidths() } } + void WX_GRID_AUTOSIZER::onSizeEvent( wxSizeEvent& aEvent ) { const int width = aEvent.GetSize().GetX(); + if( width != m_gridWidth ) { m_gridWidthsDirty = true; } + aEvent.Skip(); -} \ No newline at end of file +} diff --git a/common/widgets/wx_html_report_box.cpp b/common/widgets/wx_html_report_box.cpp index 5384baabad..b8ceda74d8 100644 --- a/common/widgets/wx_html_report_box.cpp +++ b/common/widgets/wx_html_report_box.cpp @@ -103,6 +103,7 @@ REPORTER& WX_HTML_REPORT_BOX::Report( const wxString& aText, SEVERITY aSeverity return *this; } + void WX_HTML_REPORT_BOX::Flush() { wxString html; diff --git a/common/widgets/wx_html_report_box.h b/common/widgets/wx_html_report_box.h index a141a1b30c..49b1464813 100644 --- a/common/widgets/wx_html_report_box.h +++ b/common/widgets/wx_html_report_box.h @@ -46,13 +46,15 @@ public: /** * In immediate mode, messages are flushed as they are added. + * * Required for progress-related reports, but can be very slow for larger reports. */ void SetImmediateMode() { m_immediateMode = true; } /** * 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(); @@ -71,11 +73,11 @@ private: private: EDA_UNITS m_units; - ///< Indicates messages should be flushed as they are added. Required for progress-related - ///< reports, but can be very slow for larger reports. + /// Indicates messages should be flushed as they are added. Required for progress-related + /// reports, but can be very slow for larger reports. bool m_immediateMode; - ///< copy of the report, stored for filtering + /// copy of the report, stored for filtering. std::vector<wxString> m_messages; }; diff --git a/common/widgets/wx_html_report_panel.cpp b/common/widgets/wx_html_report_panel.cpp index c81e527935..66ee58f9b3 100644 --- a/common/widgets/wx_html_report_panel.cpp +++ b/common/widgets/wx_html_report_panel.cpp @@ -193,7 +193,8 @@ wxString WX_HTML_REPORT_PANEL::generateHtml( const REPORT_LINE& aLine ) wxS( "<font size=3>" ) + aLine.message + wxS( "</font><br>" ); break; 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; case RPT_SEVERITY_INFO: 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>" ); break; 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; case RPT_SEVERITY_INFO: retv = wxS( "<font color=#808080 size=3>" ) + aLine.message + wxS( "</font><br>" ); @@ -502,4 +504,4 @@ bool WX_HTML_PANEL_REPORTER::HasMessage() const bool WX_HTML_PANEL_REPORTER::HasMessageOfSeverity( int aSeverityMask ) const { return m_panel->Count( aSeverityMask ) > 0; -} \ No newline at end of file +} diff --git a/common/widgets/wx_html_report_panel.h b/common/widgets/wx_html_report_panel.h index 6d7144536b..d6116f23e6 100644 --- a/common/widgets/wx_html_report_panel.h +++ b/common/widgets/wx_html_report_panel.h @@ -55,11 +55,10 @@ private: }; /** - * A widget for browsing a rich text error/status report. Used in numerous - * dialogs in eeschema and pcbnew. Provides error filtering functionality - * and saving report files. + * A widget for browsing a rich text error/status report. * - * 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 { @@ -69,55 +68,56 @@ public: const wxSize& size = wxSize( 500,300 ), long style = wxTAB_TRAVERSAL ); ~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 ); - ///< returns the reporter object that reports to this panel + /// Return the reporter object that reports to this panel. REPORTER& Reporter(); /** - * Reports the string - * @param aText string message to report - * @param aSeverity string classification level bitfield - * @param aLocation REPORTER::LOCATION enum for placement of message + * Report the string. + * + * @param aText string message to report. + * @param aSeverity string classification level bitfield. + * @param aLocation REPORTER::LOCATION enum for placement of message. */ void Report( const wxString& aText, SEVERITY aSeverity, REPORTER::LOCATION aLocation = REPORTER::LOC_BODY ); - ///< clears the report panel + /// Clears the report panel. 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 ); - ///< sets the frame label + /// Set the frame label. void SetLabel( const wxString& aLabel ) override; - ///< Sets 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) - ///< A call to Flush() will be needed after build the report + /// 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) + /// A call to Flush() will be needed after build the report void SetLazyUpdate( bool aLazyUpdate ); - ///< Forces updating the HTML page, after the report is built in lazy mode - ///< If aSort = true, the body messages will be ordered by severity + /// Force updating the HTML page, after the report is built in lazy mode + /// If aSort = true, the body messages will be ordered by severity void Flush( bool aSort = false ); - ///< Set the visible severity filter. - ///< if aSeverities < 0 the m_showAll option is set + /// Set the visible severity filter. + /// if aSeverities < 0 the m_showAll option is set void SetVisibleSeverities( int aSeverities ); - ///< @return the visible severity filter. - ///< If the m_showAll option is set, the mask is < 0 + /// @return the visible severity filter. + /// If the m_showAll option is set, the mask is < 0 int GetVisibleSeverities() const; - ///< @return the visible severity filter. - ///< If the m_showAll option is set, the mask is < 0 + /// @return the visible severity filter. + /// If the m_showAll option is set, the mask is < 0 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 ); - ///< @return reference to the current report fill file name string. + /// @return reference to the current report fill file name string. wxString& GetFileName( void ); diff --git a/common/widgets/wx_infobar.cpp b/common/widgets/wx_infobar.cpp index 10b158757d..49b6f2714f 100644 --- a/common/widgets/wx_infobar.cpp +++ b/common/widgets/wx_infobar.cpp @@ -63,8 +63,8 @@ WX_INFOBAR::WX_INFOBAR( wxWindow* aParent, wxAuiManager* aMgr, wxWindowID aWinid KIPLATFORM::UI::GetInfoBarColours( fg, bg ); SetBackgroundColour( bg ); SetForegroundColour( fg ); -#ifdef __WXMAC__ +#ifdef __WXMAC__ // Infobar is broken on Mac without the effects SetShowHideEffects( wxSHOW_EFFECT_ROLL_TO_BOTTOM, wxSHOW_EFFECT_ROLL_TO_TOP ); SetEffectDuration( 200 ); @@ -73,7 +73,6 @@ WX_INFOBAR::WX_INFOBAR( wxWindow* aParent, wxAuiManager* aMgr, wxWindowID aWinid SetShowHideEffects( wxSHOW_EFFECT_NONE, wxSHOW_EFFECT_NONE ); #endif - // The infobar seems to start too small, so increase its height int 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 aButton->SetWindowVariant( wxWINDOW_VARIANT_SMALL ); #endif // __WXMAC__ + sizer->Add( aButton, wxSizerFlags().Centre().Border( wxRIGHT ) ); if( IsShownOnScreen() ) diff --git a/common/wildcards_and_files_ext.cpp b/common/wildcards_and_files_ext.cpp index fa83b686d4..054d4d814d 100644 --- a/common/wildcards_and_files_ext.cpp +++ b/common/wildcards_and_files_ext.cpp @@ -212,7 +212,8 @@ const std::string FILEEXT::StlFileExtension( "stl" ); 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::SymbolLibraryTableFileName( "sym-lib-table" ); diff --git a/common/wx_filename.cpp b/common/wx_filename.cpp index 82ef657575..6c97ac0fc3 100644 --- a/common/wx_filename.cpp +++ b/common/wx_filename.cpp @@ -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() { size_t dot = m_fullName.find_last_of( wxT( '.' ) ); @@ -88,7 +87,7 @@ long long WX_FILENAME::GetTimestamp() return 0; } -// Resolve possible symlink(s) in aFileName to an absolute path + void WX_FILENAME::ResolvePossibleSymlinks( wxFileName& aFilename ) { #ifndef __WINDOWS__ diff --git a/common/xnode.cpp b/common/xnode.cpp index edd4dcfdc0..bc31cd5465 100644 --- a/common/xnode.cpp +++ b/common/xnode.cpp @@ -39,10 +39,12 @@ void XNODE::Format( OUTPUTFORMATTER* out, int nestLevel ) case wxXML_ELEMENT_NODE: out->Print( nestLevel, "(%s", TO_UTF8( GetName() ) ); FormatContents( out, nestLevel ); + if( GetNext() ) out->Print( 0, ")\n" ); else out->Print( 0, ")" ); + break; default: @@ -73,6 +75,7 @@ void XNODE::FormatContents( OUTPUTFORMATTER* out, int nestLevel ) { if( kid == GetChildren() ) out->Print( 0, "\n" ); + kid->Format( out, nestLevel+1 ); } else @@ -80,6 +83,7 @@ void XNODE::FormatContents( OUTPUTFORMATTER* out, int nestLevel ) kid->Format( out, 0 ); } } + break; case wxXML_TEXT_NODE: