Remove all wxWidgets build dependencies from REPORTER object header.
This commit is contained in:
parent
1a252b4f96
commit
8e1015fcc4
|
@ -201,9 +201,14 @@ bool STATUSBAR_REPORTER::HasMessage() const
|
|||
}
|
||||
|
||||
|
||||
INFOBAR_REPORTER::~INFOBAR_REPORTER()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
REPORTER& INFOBAR_REPORTER::Report( const wxString& aText, SEVERITY aSeverity )
|
||||
{
|
||||
m_message = aText;
|
||||
m_message.reset( new wxString( aText ) );
|
||||
m_severity = aSeverity;
|
||||
m_messageSet = true;
|
||||
|
||||
|
@ -213,7 +218,7 @@ REPORTER& INFOBAR_REPORTER::Report( const wxString& aText, SEVERITY aSeverity )
|
|||
|
||||
bool INFOBAR_REPORTER::HasMessage() const
|
||||
{
|
||||
return !m_message.IsEmpty();
|
||||
return m_message && !m_message->IsEmpty();
|
||||
}
|
||||
|
||||
|
||||
|
@ -240,11 +245,11 @@ void INFOBAR_REPORTER::Finalize()
|
|||
case RPT_SEVERITY_IGNORE: icon = wxICON_INFORMATION; break;
|
||||
}
|
||||
|
||||
if( m_message.EndsWith( "\n" ) )
|
||||
m_message = m_message.Left( m_message.Length() - 1 );
|
||||
if( m_message->EndsWith( "\n" ) )
|
||||
*m_message = m_message->Left( m_message->Length() - 1 );
|
||||
|
||||
if( HasMessage() )
|
||||
m_infoBar->QueueShowMessage( m_message, icon );
|
||||
m_infoBar->QueueShowMessage( *m_message, icon );
|
||||
else
|
||||
m_infoBar->QueueDismiss();
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2013-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 2013-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -25,17 +25,23 @@
|
|||
#ifndef _REPORTER_H_
|
||||
#define _REPORTER_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <eda_units.h>
|
||||
#include <wx/string.h>
|
||||
#include <widgets/ui_common.h>
|
||||
#include <widgets/report_severity.h>
|
||||
|
||||
/**
|
||||
* @file reporter.h
|
||||
* @author Wayne Stambaugh
|
||||
* @note A special thanks to Dick Hollenbeck who came up with the idea that inspired
|
||||
* me to write this.
|
||||
* @warning Do not add any dependencies to wxWidgets (or any other third party UI library )
|
||||
* to the REPORTER object. All wxWidgets objects should be defined by pointer or
|
||||
* reference and forward declared so that using reporters in low level KiCad objects
|
||||
* will not require pulling in wxWidgets to building them.
|
||||
*/
|
||||
|
||||
class wxString;
|
||||
class wxStatusBar;
|
||||
class wxTextCtrl;
|
||||
class WX_HTML_REPORT_PANEL;
|
||||
|
@ -108,9 +114,6 @@ public:
|
|||
REPORTER& Report( const char* aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED );
|
||||
|
||||
REPORTER& operator <<( const wxString& aText ) { return Report( aText ); }
|
||||
REPORTER& operator <<( const wxChar* aText ) { return Report( wxString( aText ) ); }
|
||||
REPORTER& operator <<( wxChar aChar ) { return Report( wxString( aChar ) ); }
|
||||
REPORTER& operator <<( const char* aText ) { return Report( aText ); }
|
||||
|
||||
/**
|
||||
* Returns true if the reporter client is non-empty.
|
||||
|
@ -133,8 +136,6 @@ public:
|
|||
*/
|
||||
class WX_TEXT_CTRL_REPORTER : public REPORTER
|
||||
{
|
||||
wxTextCtrl* m_textCtrl;
|
||||
|
||||
public:
|
||||
WX_TEXT_CTRL_REPORTER( wxTextCtrl* aTextCtrl ) :
|
||||
REPORTER(),
|
||||
|
@ -150,6 +151,9 @@ public:
|
|||
SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
|
||||
|
||||
bool HasMessage() const override;
|
||||
|
||||
private:
|
||||
wxTextCtrl* m_textCtrl;
|
||||
};
|
||||
|
||||
|
||||
|
@ -158,8 +162,6 @@ public:
|
|||
*/
|
||||
class WX_STRING_REPORTER : public REPORTER
|
||||
{
|
||||
wxString* m_string;
|
||||
|
||||
public:
|
||||
WX_STRING_REPORTER( wxString* aString ) :
|
||||
REPORTER(),
|
||||
|
@ -174,6 +176,9 @@ public:
|
|||
REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
|
||||
|
||||
bool HasMessage() const override;
|
||||
|
||||
private:
|
||||
wxString* m_string;
|
||||
};
|
||||
|
||||
|
||||
|
@ -182,8 +187,6 @@ public:
|
|||
*/
|
||||
class WX_HTML_PANEL_REPORTER : public REPORTER
|
||||
{
|
||||
WX_HTML_REPORT_PANEL* m_panel;
|
||||
|
||||
public:
|
||||
WX_HTML_PANEL_REPORTER( WX_HTML_REPORT_PANEL* aPanel ) :
|
||||
REPORTER(),
|
||||
|
@ -205,6 +208,9 @@ public:
|
|||
SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
|
||||
|
||||
bool HasMessage() const override;
|
||||
|
||||
private:
|
||||
WX_HTML_REPORT_PANEL* m_panel;
|
||||
};
|
||||
|
||||
|
||||
|
@ -313,11 +319,12 @@ public:
|
|||
: REPORTER(),
|
||||
m_messageSet( false ),
|
||||
m_infoBar( aInfoBar ),
|
||||
m_message( wxEmptyString ),
|
||||
m_severity( RPT_SEVERITY_UNDEFINED )
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~INFOBAR_REPORTER();
|
||||
|
||||
REPORTER& Report( const wxString& aText,
|
||||
SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
|
||||
|
||||
|
@ -331,7 +338,7 @@ public:
|
|||
private:
|
||||
bool m_messageSet;
|
||||
WX_INFOBAR* m_infoBar;
|
||||
wxString m_message;
|
||||
std::unique_ptr<wxString> m_message;
|
||||
SEVERITY m_severity;
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _REPORT_SEVERITY_H_
|
||||
#define _REPORT_SEVERITY_H_
|
||||
|
||||
// Note: On windows, SEVERITY_ERROR collides with a system declaration,
|
||||
// so we used RPT_SEVERITY _xxx instead of SEVERITY _xxx
|
||||
enum SEVERITY {
|
||||
RPT_SEVERITY_UNDEFINED = 0x00,
|
||||
RPT_SEVERITY_INFO = 0x01,
|
||||
RPT_SEVERITY_EXCLUSION = 0x02,
|
||||
RPT_SEVERITY_ACTION = 0x04,
|
||||
RPT_SEVERITY_WARNING = 0x08,
|
||||
RPT_SEVERITY_ERROR = 0x10,
|
||||
RPT_SEVERITY_IGNORE = 0x20
|
||||
};
|
||||
|
||||
#endif // _REPORT_SEVERITY_H_
|
|
@ -26,6 +26,7 @@
|
|||
#ifndef UI_COMMON_H
|
||||
#define UI_COMMON_H
|
||||
|
||||
#include "report_severity.h" // enum SEVERITY
|
||||
#include <wx/string.h>
|
||||
#include <wx/font.h>
|
||||
|
||||
|
@ -75,17 +76,16 @@ bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString = nullptr )
|
|||
void SelectReferenceNumber( wxTextEntry* aTextEntry );
|
||||
|
||||
/**
|
||||
* Checks if a input control has focus
|
||||
* Check if a input control has focus.
|
||||
*
|
||||
* @param aFocus Control that has focus, if null, wxWidgets will be queried
|
||||
*/
|
||||
bool IsInputControlFocused( wxWindow* aFocus = nullptr );
|
||||
|
||||
/**
|
||||
* Checks if a input control has focus
|
||||
* Check if a input control has focus.
|
||||
*
|
||||
* @param aFocus Control that test if editable
|
||||
*
|
||||
* @return True if control is input and editable OR control is not a input. False if control is
|
||||
* input and not editable.
|
||||
*/
|
||||
|
@ -95,18 +95,6 @@ bool IsModalDialogFocused();
|
|||
|
||||
}
|
||||
|
||||
// Note: On windows, SEVERITY_ERROR collides with a system declaration,
|
||||
// so we used RPT_SEVERITY _xxx instead of SEVERITY _xxx
|
||||
enum SEVERITY {
|
||||
RPT_SEVERITY_UNDEFINED = 0x00,
|
||||
RPT_SEVERITY_INFO = 0x01,
|
||||
RPT_SEVERITY_EXCLUSION = 0x02,
|
||||
RPT_SEVERITY_ACTION = 0x04,
|
||||
RPT_SEVERITY_WARNING = 0x08,
|
||||
RPT_SEVERITY_ERROR = 0x10,
|
||||
RPT_SEVERITY_IGNORE = 0x20
|
||||
};
|
||||
|
||||
SEVERITY SeverityFromString( const wxString& aSeverity );
|
||||
|
||||
wxString SeverityToString( const SEVERITY& aSeverity );
|
||||
|
|
Loading…
Reference in New Issue