2012-01-09 08:35:06 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2021-02-21 17:27:28 +00:00
|
|
|
* Author: Dick Hollenbeck
|
|
|
|
*
|
|
|
|
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-01-09 08:35:06 +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
|
|
|
|
*/
|
|
|
|
|
2018-01-29 10:37:29 +00:00
|
|
|
#ifndef TITLE_BLOCK_H
|
|
|
|
#define TITLE_BLOCK_H
|
2016-01-12 16:33:33 +00:00
|
|
|
|
2012-01-09 08:35:06 +00:00
|
|
|
#include <wx/string.h>
|
2018-10-05 16:17:54 +00:00
|
|
|
#include <wx/arrstr.h>
|
2017-02-22 16:54:01 +00:00
|
|
|
#include <ki_exception.h>
|
2012-01-09 08:35:06 +00:00
|
|
|
|
2012-04-01 20:51:56 +00:00
|
|
|
class OUTPUTFORMATTER;
|
2021-01-15 15:40:35 +00:00
|
|
|
class PROJECT;
|
2012-04-01 20:51:56 +00:00
|
|
|
|
2012-01-09 08:35:06 +00:00
|
|
|
/**
|
2020-12-21 15:17:52 +00:00
|
|
|
* Hold the information shown in the lower right corner of a plot, printout, or
|
2012-01-09 08:35:06 +00:00
|
|
|
* editing view.
|
|
|
|
*/
|
|
|
|
class TITLE_BLOCK
|
|
|
|
{
|
2013-06-05 12:03:16 +00:00
|
|
|
// Texts are stored in wxArraystring.
|
2021-02-21 17:27:28 +00:00
|
|
|
// TEXTS_IDX gives the index of known texts in this array
|
|
|
|
enum TEXTS_IDX
|
2013-06-05 12:03:16 +00:00
|
|
|
{
|
2021-02-21 17:27:28 +00:00
|
|
|
TITLE_IDX = 0,
|
|
|
|
DATE_IDX,
|
|
|
|
REVISION_IDX,
|
|
|
|
COMPANY_IDX,
|
|
|
|
COMMENT1_IDX // idx of the first comment: one can have more than 1 comment
|
2013-06-05 12:03:16 +00:00
|
|
|
};
|
|
|
|
|
2012-01-09 08:35:06 +00:00
|
|
|
public:
|
2013-06-05 12:03:16 +00:00
|
|
|
TITLE_BLOCK() {};
|
2013-02-06 11:54:51 +00:00
|
|
|
virtual ~TITLE_BLOCK() {}; // a virtual dtor seems needed to build
|
|
|
|
// python lib without warning
|
2012-01-09 08:35:06 +00:00
|
|
|
|
2013-06-05 12:03:16 +00:00
|
|
|
void SetTitle( const wxString& aTitle )
|
|
|
|
{
|
2021-02-21 17:27:28 +00:00
|
|
|
setTbText( TITLE_IDX, aTitle );
|
2013-06-05 12:03:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const wxString& GetTitle() const
|
|
|
|
{
|
2021-02-21 17:27:28 +00:00
|
|
|
return getTbText( TITLE_IDX );
|
2013-06-05 12:03:16 +00:00
|
|
|
}
|
2012-01-09 08:35:06 +00:00
|
|
|
|
|
|
|
/**
|
2020-12-21 15:17:52 +00:00
|
|
|
* Set the date field, and defaults to the current time and date.
|
2012-01-09 08:35:06 +00:00
|
|
|
*/
|
2013-06-05 12:03:16 +00:00
|
|
|
void SetDate( const wxString& aDate )
|
|
|
|
{
|
2021-02-21 17:27:28 +00:00
|
|
|
setTbText( DATE_IDX, aDate );
|
2013-06-05 12:03:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const wxString& GetDate() const
|
|
|
|
{
|
2021-02-21 17:27:28 +00:00
|
|
|
return getTbText( DATE_IDX );
|
2013-06-05 12:03:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetRevision( const wxString& aRevision )
|
|
|
|
{
|
2021-02-21 17:27:28 +00:00
|
|
|
setTbText( REVISION_IDX, aRevision );
|
2013-06-05 12:03:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const wxString& GetRevision() const
|
|
|
|
{
|
2021-02-21 17:27:28 +00:00
|
|
|
return getTbText( REVISION_IDX );
|
2013-06-05 12:03:16 +00:00
|
|
|
}
|
2012-01-09 08:35:06 +00:00
|
|
|
|
2013-06-05 12:03:16 +00:00
|
|
|
void SetCompany( const wxString& aCompany )
|
|
|
|
{
|
2021-02-21 17:27:28 +00:00
|
|
|
setTbText( COMPANY_IDX, aCompany );
|
2013-06-05 12:03:16 +00:00
|
|
|
}
|
2012-01-09 08:35:06 +00:00
|
|
|
|
2013-06-05 12:03:16 +00:00
|
|
|
const wxString& GetCompany() const
|
|
|
|
{
|
2021-02-21 17:27:28 +00:00
|
|
|
return getTbText( COMPANY_IDX );
|
2013-06-05 12:03:16 +00:00
|
|
|
}
|
2012-01-09 08:35:06 +00:00
|
|
|
|
2019-08-21 16:58:29 +00:00
|
|
|
void SetComment( int aIdx, const wxString& aComment )
|
2013-06-05 12:03:16 +00:00
|
|
|
{
|
2021-02-21 17:27:28 +00:00
|
|
|
aIdx += COMMENT1_IDX;
|
2013-06-05 12:03:16 +00:00
|
|
|
return setTbText( aIdx, aComment );
|
|
|
|
}
|
2012-01-09 08:35:06 +00:00
|
|
|
|
2013-06-05 12:03:16 +00:00
|
|
|
const wxString& GetComment( int aIdx ) const
|
|
|
|
{
|
2021-02-21 17:27:28 +00:00
|
|
|
aIdx += COMMENT1_IDX;
|
2013-06-05 12:03:16 +00:00
|
|
|
return getTbText( aIdx );
|
|
|
|
}
|
2012-01-09 08:35:06 +00:00
|
|
|
|
|
|
|
void Clear()
|
|
|
|
{
|
2013-06-05 12:03:16 +00:00
|
|
|
m_tbTexts.Clear();
|
2012-01-09 08:35:06 +00:00
|
|
|
}
|
|
|
|
|
2021-02-12 16:23:24 +00:00
|
|
|
static void GetContextualTextVars( wxArrayString* aVars );
|
2021-01-15 15:40:35 +00:00
|
|
|
bool TextVarResolver( wxString* aToken, const PROJECT* aProject ) const;
|
|
|
|
|
2012-04-01 20:51:56 +00:00
|
|
|
/**
|
2020-12-21 15:17:52 +00:00
|
|
|
* Output the object to \a aFormatter in s-expression form.
|
2012-04-01 20:51:56 +00:00
|
|
|
*
|
|
|
|
* @param aFormatter The #OUTPUTFORMATTER object to write to.
|
|
|
|
* @param aNestLevel The indentation next level.
|
|
|
|
* @param aControlBits The control bit definition for object specific formatting.
|
|
|
|
* @throw IO_ERROR on write error.
|
|
|
|
*/
|
2017-06-08 21:47:21 +00:00
|
|
|
virtual void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const;
|
2012-04-01 20:51:56 +00:00
|
|
|
|
2012-01-09 08:35:06 +00:00
|
|
|
private:
|
2013-06-05 12:03:16 +00:00
|
|
|
wxArrayString m_tbTexts;
|
|
|
|
|
|
|
|
void setTbText( int aIdx, const wxString& aText )
|
|
|
|
{
|
|
|
|
if( (int)m_tbTexts.GetCount() <= aIdx )
|
|
|
|
m_tbTexts.Add( wxEmptyString, aIdx + 1 - m_tbTexts.GetCount() );
|
2020-12-21 15:17:52 +00:00
|
|
|
|
2013-06-05 12:03:16 +00:00
|
|
|
m_tbTexts[aIdx] = aText;
|
|
|
|
}
|
|
|
|
|
|
|
|
const wxString& getTbText( int aIdx ) const
|
|
|
|
{
|
|
|
|
static const wxString m_emptytext;
|
|
|
|
|
|
|
|
if( (int)m_tbTexts.GetCount() > aIdx )
|
|
|
|
return m_tbTexts[aIdx];
|
|
|
|
else
|
|
|
|
return m_emptytext;
|
|
|
|
}
|
2012-01-09 08:35:06 +00:00
|
|
|
};
|
|
|
|
|
2018-01-29 10:37:29 +00:00
|
|
|
#endif // TITLE_BLOCK_H
|