2013-05-26 04:36:44 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
2021-06-03 15:41:26 +00:00
|
|
|
* Copyright (C) 2011-2012 Wayne Stambaugh <stambaughw@gmail.com>
|
|
|
|
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2013-05-26 04:36:44 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file msgpanel.h
|
|
|
|
* @brief Message panel definition file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _MSGPANEL_H_
|
|
|
|
#define _MSGPANEL_H_
|
|
|
|
|
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
#include <gal/color4d.h>
|
2013-05-26 04:36:44 +00:00
|
|
|
|
|
|
|
#include <wx/window.h>
|
2020-10-18 11:31:07 +00:00
|
|
|
#include <wx/panel.h>
|
2013-05-26 04:36:44 +00:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
using KIGFX::COLOR4D;
|
2013-05-26 04:36:44 +00:00
|
|
|
|
|
|
|
#define MSG_PANEL_DEFAULT_PAD 6 ///< The default number of spaces between each text string.
|
|
|
|
|
|
|
|
|
|
|
|
class EDA_MSG_PANEL;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-06-03 15:41:26 +00:00
|
|
|
* #EDA_MSG_PANEL items for displaying messages.
|
2013-05-26 04:36:44 +00:00
|
|
|
*/
|
|
|
|
class MSG_PANEL_ITEM
|
|
|
|
{
|
|
|
|
public:
|
2020-11-18 15:36:47 +00:00
|
|
|
MSG_PANEL_ITEM( const wxString& aUpperText, const wxString& aLowerText,
|
|
|
|
int aPadding = MSG_PANEL_DEFAULT_PAD ) :
|
|
|
|
m_UpperText( aUpperText ),
|
|
|
|
m_LowerText( aLowerText ),
|
|
|
|
m_Padding( aPadding )
|
2013-05-26 04:36:44 +00:00
|
|
|
{
|
2015-02-28 20:50:35 +00:00
|
|
|
m_X = 0;
|
|
|
|
m_UpperY = 0;
|
|
|
|
m_LowerY = 0;
|
2013-05-26 04:36:44 +00:00
|
|
|
}
|
|
|
|
|
2015-02-16 00:04:48 +00:00
|
|
|
MSG_PANEL_ITEM() :
|
2020-11-18 15:36:47 +00:00
|
|
|
m_Padding( MSG_PANEL_DEFAULT_PAD )
|
2015-02-28 20:50:35 +00:00
|
|
|
|
2013-05-26 04:36:44 +00:00
|
|
|
{
|
2015-02-28 20:50:35 +00:00
|
|
|
m_X = 0;
|
|
|
|
m_UpperY = 0;
|
|
|
|
m_LowerY = 0;
|
2013-05-26 04:36:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetUpperText( const wxString& aUpperText ) { m_UpperText = aUpperText; }
|
|
|
|
const wxString& GetUpperText() const { return m_UpperText; }
|
|
|
|
|
|
|
|
void SetLowerText( const wxString& aLowerText ) { m_LowerText = aLowerText; }
|
|
|
|
const wxString& GetLowerText() const { return m_LowerText; }
|
|
|
|
|
2020-11-18 15:36:47 +00:00
|
|
|
void SetPadding( int aPadding ) { m_Padding = aPadding; }
|
|
|
|
int GetPadding() const { return m_Padding; }
|
2021-06-03 15:41:26 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class EDA_MSG_PANEL;
|
|
|
|
|
|
|
|
int m_X;
|
|
|
|
int m_UpperY;
|
|
|
|
int m_LowerY;
|
|
|
|
wxString m_UpperText;
|
|
|
|
wxString m_LowerText;
|
|
|
|
int m_Padding;
|
2013-05-26 04:36:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-06-03 15:41:26 +00:00
|
|
|
* A panel to display various information messages.
|
2013-05-26 04:36:44 +00:00
|
|
|
*/
|
|
|
|
class EDA_MSG_PANEL : public wxPanel
|
|
|
|
{
|
|
|
|
public:
|
2014-05-15 06:32:24 +00:00
|
|
|
EDA_MSG_PANEL( wxWindow* aParent, int aId,
|
|
|
|
const wxPoint& aPosition, const wxSize& aSize,
|
2021-07-27 12:22:27 +00:00
|
|
|
long style=wxTAB_TRAVERSAL, const wxString& name=wxPanelNameStr);
|
2013-05-26 04:36:44 +00:00
|
|
|
~EDA_MSG_PANEL();
|
|
|
|
|
|
|
|
/**
|
2021-06-03 15:41:26 +00:00
|
|
|
* Return the required height (in pixels) of a EDA_MSG_PANEL.
|
|
|
|
*
|
|
|
|
* This takes into consideration the system gui font, wxSYS_DEFAULT_GUI_FONT.
|
2013-05-26 04:36:44 +00:00
|
|
|
*/
|
2021-09-12 11:17:22 +00:00
|
|
|
static int GetRequiredHeight( wxWindow* aWindow );
|
2013-05-26 04:36:44 +00:00
|
|
|
|
|
|
|
void OnPaint( wxPaintEvent& aEvent );
|
|
|
|
void EraseMsgBox();
|
|
|
|
|
|
|
|
/**
|
2021-06-03 15:41:26 +00:00
|
|
|
* Set a message at \a aXPosition to \a aUpperText and \a aLowerText in the message panel.
|
2013-05-26 04:36:44 +00:00
|
|
|
*
|
|
|
|
* @param aXPosition The horizontal position to display the message or less than zero
|
|
|
|
* to set the message using the last message position.
|
|
|
|
* @param aUpperText The text to be displayed in top line.
|
|
|
|
* @param aLowerText The text to be displayed in bottom line.
|
|
|
|
*/
|
2020-11-18 15:36:47 +00:00
|
|
|
void SetMessage( int aXPosition, const wxString& aUpperText, const wxString& aLowerText );
|
2013-05-26 04:36:44 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-03 15:41:26 +00:00
|
|
|
* Append a message to the message panel.
|
2013-05-26 04:36:44 +00:00
|
|
|
*
|
|
|
|
* This method automatically adjusts for the width of the text string.
|
|
|
|
* Making consecutive calls to AppendMessage will append each message
|
|
|
|
* to the right of the last message. This message is not compatible
|
|
|
|
* with Affiche_1_Parametre.
|
|
|
|
*
|
|
|
|
* @param aUpperText The message upper text.
|
|
|
|
* @param aLowerText The message lower text.
|
2020-11-18 15:36:47 +00:00
|
|
|
* @param aPadding Number of spaces to pad between messages (default = 4).
|
2013-05-26 04:36:44 +00:00
|
|
|
*/
|
2020-11-18 15:36:47 +00:00
|
|
|
void AppendMessage( const wxString& aUpperText, const wxString& aLowerText, int aPadding = 6 );
|
2013-05-26 04:36:44 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-03 15:41:26 +00:00
|
|
|
* Append \a aMessageItem to the message panel.
|
2013-05-26 04:36:44 +00:00
|
|
|
*
|
|
|
|
* @param aMessageItem is a reference to an #MSG_PANEL_ITEM containing the message to
|
|
|
|
* append to the panel.
|
|
|
|
*/
|
|
|
|
void AppendMessage( const MSG_PANEL_ITEM& aMessageItem )
|
|
|
|
{
|
|
|
|
AppendMessage( aMessageItem.GetUpperText(), aMessageItem.GetLowerText(),
|
2020-11-18 15:36:47 +00:00
|
|
|
aMessageItem.GetPadding() );
|
2013-05-26 04:36:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
2021-06-03 15:41:26 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void showItem( wxDC& dc, const MSG_PANEL_ITEM& aItem );
|
|
|
|
|
|
|
|
void erase( wxDC* DC );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculate the width and height of a text string using the system UI font.
|
|
|
|
*/
|
|
|
|
wxSize computeTextSize( const wxString& text ) const;
|
|
|
|
|
2021-09-26 23:22:32 +00:00
|
|
|
protected:
|
|
|
|
std::vector<MSG_PANEL_ITEM> m_Items;
|
|
|
|
int m_last_x; ///< the last used x coordinate
|
|
|
|
wxSize m_fontSize;
|
2013-05-26 04:36:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _MSGPANEL_H_
|