From ad1e8ebda8f119521e51372a3f7605684b698c31 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 7 Nov 2020 21:40:56 +0000 Subject: [PATCH] Cleanup formatting. --- common/widgets/bitmap_button.cpp | 12 +++++------ common/widgets/color_swatch.cpp | 9 ++++---- common/widgets/footprint_choice.cpp | 12 ++++++----- common/widgets/footprint_preview_widget.cpp | 13 +++--------- common/widgets/progress_reporter.cpp | 7 ++++--- common/widgets/split_button.cpp | 23 +++++++++++++-------- common/widgets/stepped_slider.cpp | 21 +++++++------------ common/widgets/text_ctrl_eval.cpp | 10 ++++----- common/widgets/unit_binder.cpp | 9 +++++--- common/widgets/widget_save_restore.cpp | 4 ++-- include/widgets/color_swatch.h | 4 ++-- 11 files changed, 60 insertions(+), 64 deletions(-) diff --git a/common/widgets/bitmap_button.cpp b/common/widgets/bitmap_button.cpp index 5a077362aa..d0ded923c9 100644 --- a/common/widgets/bitmap_button.cpp +++ b/common/widgets/bitmap_button.cpp @@ -101,12 +101,12 @@ void BITMAP_BUTTON::OnLeftButtonUp( wxMouseEvent& aEvent ) wxASSERT( pEventHandler ); pEventHandler->CallAfter( - [=]() - { - wxCommandEvent evt( wxEVT_BUTTON, this->GetId() ); - evt.SetEventObject( this ); - GetEventHandler()->ProcessEvent( evt ); - } ); + [=]() + { + wxCommandEvent evt( wxEVT_BUTTON, this->GetId() ); + evt.SetEventObject( this ); + GetEventHandler()->ProcessEvent( evt ); + } ); } clearFlag( wxCONTROL_PRESSED ); diff --git a/common/widgets/color_swatch.cpp b/common/widgets/color_swatch.cpp index 9db50c78ab..e626882b7a 100644 --- a/common/widgets/color_swatch.cpp +++ b/common/widgets/color_swatch.cpp @@ -59,7 +59,6 @@ wxBitmap COLOR_SWATCH::MakeBitmap( COLOR4D aColor, COLOR4D aBackground, wxSize a COLOR4D black; bool rowCycle; - if( aCheckerboardBackground.GetBrightness() > 0.4 ) { white = COLOR4D::WHITE; @@ -214,9 +213,9 @@ void COLOR_SWATCH::setupEvents() } -void COLOR_SWATCH::rePostEvent( wxEvent& aEvt ) +void COLOR_SWATCH::rePostEvent( wxEvent& aEvent ) { - wxPostEvent( this, aEvt ); + wxPostEvent( this, aEvent ); } @@ -232,14 +231,14 @@ static void sendSwatchChangeEvent( COLOR_SWATCH& aSender ) } -void COLOR_SWATCH::SetSwatchColor( COLOR4D aColor, bool sendEvent ) +void COLOR_SWATCH::SetSwatchColor( COLOR4D aColor, bool aSendEvent ) { m_color = aColor; wxBitmap bm = MakeBitmap( m_color, m_background, m_size, m_checkerboardSize, m_checkerboardBg ); m_swatch->SetBitmap( bm ); - if( sendEvent ) + if( aSendEvent ) sendSwatchChangeEvent( *this ); } diff --git a/common/widgets/footprint_choice.cpp b/common/widgets/footprint_choice.cpp index ec547282b4..f7c3dabc50 100644 --- a/common/widgets/footprint_choice.cpp +++ b/common/widgets/footprint_choice.cpp @@ -28,10 +28,10 @@ wxDEFINE_EVENT( EVT_INTERACTIVE_CHOICE, wxCommandEvent ); wxColour FOOTPRINT_CHOICE::m_grey( 0x808080 ); -FOOTPRINT_CHOICE::FOOTPRINT_CHOICE( wxWindow* aParent, int aId ) - : wxOwnerDrawnComboBox( aParent, aId, wxEmptyString, wxDefaultPosition, wxDefaultSize, - /* n */ 0, /* choices */ nullptr, wxCB_READONLY ), - m_last_selection( 0 ) +FOOTPRINT_CHOICE::FOOTPRINT_CHOICE( wxWindow* aParent, int aId ) : + wxOwnerDrawnComboBox( aParent, aId, wxEmptyString, wxDefaultPosition, wxDefaultSize, + /* n */ 0, /* choices */ nullptr, wxCB_READONLY ), + m_last_selection( 0 ) { } @@ -73,7 +73,7 @@ void FOOTPRINT_CHOICE::OnDrawItem( wxDC& aDC, wxRect const& aRect, int aItem, in aDC.SetPen( pen ); aDC.DrawLine( aRect.x, aRect.y + aRect.height / 2, aRect.x + aRect.width, - aRect.y + aRect.height / 2 ); + aRect.y + aRect.height / 2 ); } else { @@ -200,7 +200,9 @@ void FOOTPRINT_CHOICE::TryVetoSelect( wxCommandEvent& aEvent, bool aInner ) wxString text = SafeGetString( sel ); if( text == "" ) + { SetSelectionEither( aInner, m_last_selection ); + } else { m_last_selection = sel; diff --git a/common/widgets/footprint_preview_widget.cpp b/common/widgets/footprint_preview_widget.cpp index 34201ae6db..60747646e4 100644 --- a/common/widgets/footprint_preview_widget.cpp +++ b/common/widgets/footprint_preview_widget.cpp @@ -100,16 +100,9 @@ void FOOTPRINT_PREVIEW_WIDGET::OnStatusChange( FOOTPRINT_STATUS aStatus ) { switch( aStatus ) { - case FPS_NOT_FOUND: - SetStatusText( _( "Footprint not found" ) ); - break; - - case FPS_LOADING: - SetStatusText( _( "Loading..." ) ); - break; - - case FPS_READY: - ClearStatus(); + case FPS_NOT_FOUND: SetStatusText( _( "Footprint not found" ) ); break; + case FPS_LOADING: SetStatusText( _( "Loading..." ) ); break; + case FPS_READY: ClearStatus(); break; } Refresh(); diff --git a/common/widgets/progress_reporter.cpp b/common/widgets/progress_reporter.cpp index bb3473fa14..c32679f1b4 100644 --- a/common/widgets/progress_reporter.cpp +++ b/common/widgets/progress_reporter.cpp @@ -144,7 +144,8 @@ WX_PROGRESS_REPORTER::WX_PROGRESS_REPORTER( wxWindow* aParent, const wxString& a ( aCanAbort ? wxPD_CAN_ABORT : 0 ) | wxPD_ELAPSED_TIME ) #if wxCHECK_VERSION( 3, 1, 0 ) - ,m_appProgressIndicator( aParent ) + , + m_appProgressIndicator( aParent ) #endif { #if wxCHECK_VERSION( 3, 1, 0 ) @@ -181,8 +182,8 @@ bool WX_PROGRESS_REPORTER::updateUI() GAUGE_PROGRESS_REPORTER::GAUGE_PROGRESS_REPORTER( wxWindow* aParent, int aNumPhases ) : PROGRESS_REPORTER( aNumPhases ), - wxGauge( aParent, wxID_ANY, 1000, wxDefaultPosition, wxDefaultSize, - wxGA_HORIZONTAL, wxDefaultValidator, wxGaugeNameStr ) + wxGauge( aParent, wxID_ANY, 1000, wxDefaultPosition, wxDefaultSize, wxGA_HORIZONTAL, + wxDefaultValidator, wxGaugeNameStr ) { } diff --git a/common/widgets/split_button.cpp b/common/widgets/split_button.cpp index fd77bc6d3e..34b659f9ba 100644 --- a/common/widgets/split_button.cpp +++ b/common/widgets/split_button.cpp @@ -31,9 +31,9 @@ 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, "DropDownButton" ), - m_label( aLabel ) + const wxPoint& aPos, const wxSize& aSize ) : + wxPanel( aParent, aId, aPos, aSize, wxBORDER_NONE | wxTAB_TRAVERSAL, "DropDownButton" ), + m_label( aLabel ) { m_colorNormal = GetForegroundColour(); m_colorDisabled = GetForegroundColour().MakeDisabled(); @@ -67,7 +67,8 @@ SPLIT_BUTTON::~SPLIT_BUTTON() void SPLIT_BUTTON::SetMinSize( const wxSize& aSize ) { m_unadjustedMinSize = aSize; - wxPanel::SetMinSize( wxSize( aSize.GetWidth() + m_arrowButtonWidth + m_widthPadding, aSize.GetHeight() ) ); + wxPanel::SetMinSize( wxSize( aSize.GetWidth() + m_arrowButtonWidth + m_widthPadding, + aSize.GetHeight() ) ); } @@ -138,11 +139,13 @@ void SPLIT_BUTTON::OnLeftButtonUp( wxMouseEvent& aEvent ) wxEvtHandler* pEventHandler = GetEventHandler(); wxASSERT( pEventHandler ); - pEventHandler->CallAfter( [=]() { - wxCommandEvent evt( wxEVT_BUTTON, this->GetId() ); - evt.SetEventObject( this ); - GetEventHandler()->ProcessEvent( evt ); - } ); + pEventHandler->CallAfter( + [=]() + { + wxCommandEvent evt( wxEVT_BUTTON, this->GetId() ); + evt.SetEventObject( this ); + GetEventHandler()->ProcessEvent( evt ); + } ); } m_bLButtonDown = false; @@ -207,8 +210,10 @@ void SPLIT_BUTTON::OnPaint( wxPaintEvent& WXUNUSED( aEvent ) ) wxMemoryDC mdc( m_bitmap ); r1.x = ( width - m_bitmap.GetWidth() ) / 2; + if( r1.x < 0 ) r1.x = 0; + r1.y += ( size.GetHeight() - m_bitmap.GetHeight() ) / 2; dc.Blit( wxPoint( r1.x, r1.y ), m_bitmap.GetSize(), &mdc, wxPoint( 0, 0 ), wxCOPY, true ); diff --git a/common/widgets/stepped_slider.cpp b/common/widgets/stepped_slider.cpp index c3cc97cdad..620d53e90b 100644 --- a/common/widgets/stepped_slider.cpp +++ b/common/widgets/stepped_slider.cpp @@ -26,20 +26,13 @@ BEGIN_EVENT_TABLE( STEPPED_SLIDER, wxSlider ) END_EVENT_TABLE() -STEPPED_SLIDER::STEPPED_SLIDER( - wxWindow* aParent, - wxWindowID aId, - int aValue, - int aMinValue, - int aMaxValue, - const wxPoint& aPos, - const wxSize& aSize, - long aStyle, - const wxValidator& aValidator, - const wxString& aName ) - :wxSlider( aParent, aId, aValue, aMinValue, aMaxValue, - aPos, aSize, aStyle, aValidator, aName ), - m_step( 1 ) +STEPPED_SLIDER::STEPPED_SLIDER( wxWindow* aParent, wxWindowID aId, int aValue, int aMinValue, + int aMaxValue, const wxPoint& aPos, const wxSize& aSize, + long aStyle, const wxValidator& aValidator, + const wxString& aName ) : + wxSlider( aParent, aId, aValue, aMinValue, aMaxValue, aPos, aSize, aStyle, aValidator, + aName ), + m_step( 1 ) {} diff --git a/common/widgets/text_ctrl_eval.cpp b/common/widgets/text_ctrl_eval.cpp index cf19917dda..4d4a141882 100644 --- a/common/widgets/text_ctrl_eval.cpp +++ b/common/widgets/text_ctrl_eval.cpp @@ -25,11 +25,11 @@ #include TEXT_CTRL_EVAL::TEXT_CTRL_EVAL( wxWindow* aParent, wxWindowID aId, const wxString& aValue, - const wxPoint& aPos, const wxSize& aSize, long aStyle, const wxValidator& aValidator, - const wxString& aName ) - : wxTextCtrl( aParent, aId, aValue, aPos, aSize, aStyle | wxTE_PROCESS_ENTER, aValidator, - aName ), - m_eval( EDA_UNITS::UNSCALED ) + const wxPoint& aPos, const wxSize& aSize, long aStyle, + const wxValidator& aValidator, const wxString& aName ) : + wxTextCtrl( aParent, aId, aValue, aPos, aSize, aStyle | wxTE_PROCESS_ENTER, aValidator, + aName ), + m_eval( EDA_UNITS::UNSCALED ) { Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( TEXT_CTRL_EVAL::onTextFocusGet ), NULL, this ); Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( TEXT_CTRL_EVAL::onTextFocusLost ), NULL, this ); diff --git a/common/widgets/unit_binder.cpp b/common/widgets/unit_binder.cpp index 94da76c1a0..1ca4b8ced8 100644 --- a/common/widgets/unit_binder.cpp +++ b/common/widgets/unit_binder.cpp @@ -35,9 +35,8 @@ wxDEFINE_EVENT( DELAY_FOCUS, wxCommandEvent ); -UNIT_BINDER::UNIT_BINDER( EDA_DRAW_FRAME* aParent, - wxStaticText* aLabel, wxWindow* aValue, wxStaticText* aUnitLabel, - bool allowEval ) : +UNIT_BINDER::UNIT_BINDER( EDA_DRAW_FRAME* aParent, wxStaticText* aLabel, wxWindow* aValue, + wxStaticText* aUnitLabel, bool allowEval ) : m_frame( aParent ), m_label( aLabel ), m_value( aValue ), @@ -315,9 +314,13 @@ double UNIT_BINDER::GetDoubleValue() value = textEntry->GetValue(); } else if( staticText ) + { value = staticText->GetLabel(); + } else + { return 0.0; + } double displayValue = DoubleValueFromString( m_units, value, m_dataType ); return m_originTransforms.FromDisplay( displayValue, m_coordType ); diff --git a/common/widgets/widget_save_restore.cpp b/common/widgets/widget_save_restore.cpp index fef802ed63..5dbc15e581 100644 --- a/common/widgets/widget_save_restore.cpp +++ b/common/widgets/widget_save_restore.cpp @@ -82,7 +82,7 @@ void WIDGET_SAVE_RESTORE::Add( wxNotebook& ctrl, long& dest ) void WIDGET_SAVE_RESTORE::ReadConfigFromControls() { - for( auto& ctrl : m_ctrls ) + for( WIDGET_SAVE_RESTORE::WIDGET_CTRL_T& ctrl : m_ctrls ) { switch( ctrl.m_type ) { @@ -129,7 +129,7 @@ void WIDGET_SAVE_RESTORE::RestoreConfigToControls() if( !m_valid ) return; - for( auto& ctrl : m_ctrls ) + for( WIDGET_SAVE_RESTORE::WIDGET_CTRL_T& ctrl : m_ctrls ) { switch( ctrl.m_type ) { diff --git a/include/widgets/color_swatch.h b/include/widgets/color_swatch.h index d96ae6b39e..c4c245c93a 100644 --- a/include/widgets/color_swatch.h +++ b/include/widgets/color_swatch.h @@ -77,7 +77,7 @@ public: /** * Set the current swatch color directly. */ - void SetSwatchColor( KIGFX::COLOR4D aColor, bool sendEvent ); + void SetSwatchColor( KIGFX::COLOR4D aColor, bool aSendEvent ); /** * Sets the color that will be chosen with the "Reset to Default" button in the chooser @@ -116,7 +116,7 @@ private: /** * Pass unwanted events on to listeners of this object */ - void rePostEvent( wxEvent& aEvt ); + void rePostEvent( wxEvent& aEvent ); KIGFX::COLOR4D m_color; KIGFX::COLOR4D m_background;