KiCad PCB EDA Suite
TITLE_BLOCK Class Reference

Hold the information shown in the lower right corner of a plot, printout, or editing view. More...

#include <title_block.h>

Public Member Functions

 TITLE_BLOCK ()
 
virtual ~TITLE_BLOCK ()
 
void SetTitle (const wxString &aTitle)
 
const wxString & GetTitle () const
 
void SetDate (const wxString &aDate)
 Set the date field, and defaults to the current time and date. More...
 
const wxString & GetDate () const
 
void SetRevision (const wxString &aRevision)
 
const wxString & GetRevision () const
 
void SetCompany (const wxString &aCompany)
 
const wxString & GetCompany () const
 
void SetComment (int aIdx, const wxString &aComment)
 
const wxString & GetComment (int aIdx) const
 
void Clear ()
 
bool TextVarResolver (wxString *aToken, const PROJECT *aProject) const
 
virtual void Format (OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
 Output the object to aFormatter in s-expression form. More...
 

Static Public Member Functions

static void GetContextualTextVars (wxArrayString *aVars)
 

Private Types

enum  TEXTS_IDX {
  TITLE_IDX = 0, DATE_IDX, REVISION_IDX, COMPANY_IDX,
  COMMENT1_IDX
}
 

Private Member Functions

void setTbText (int aIdx, const wxString &aText)
 
const wxString & getTbText (int aIdx) const
 

Private Attributes

wxArrayString m_tbTexts
 

Detailed Description

Hold the information shown in the lower right corner of a plot, printout, or editing view.

Definition at line 40 of file title_block.h.

Member Enumeration Documentation

◆ TEXTS_IDX

enum TITLE_BLOCK::TEXTS_IDX
private
Enumerator
TITLE_IDX 
DATE_IDX 
REVISION_IDX 
COMPANY_IDX 
COMMENT1_IDX 

Definition at line 44 of file title_block.h.

45  {
46  TITLE_IDX = 0,
47  DATE_IDX,
50  COMMENT1_IDX // idx of the first comment: one can have more than 1 comment
51  };

Constructor & Destructor Documentation

◆ TITLE_BLOCK()

TITLE_BLOCK::TITLE_BLOCK ( )
inline

Definition at line 54 of file title_block.h.

54 {};

◆ ~TITLE_BLOCK()

virtual TITLE_BLOCK::~TITLE_BLOCK ( )
inlinevirtual

Definition at line 55 of file title_block.h.

55 {}; // a virtual dtor seems needed to build

Member Function Documentation

◆ Clear()

void TITLE_BLOCK::Clear ( )
inline

Definition at line 113 of file title_block.h.

114  {
115  m_tbTexts.Clear();
116  }
wxArrayString m_tbTexts
Definition: title_block.h:132

References m_tbTexts.

Referenced by SCH_SCREEN::Clear().

◆ Format()

void TITLE_BLOCK::Format ( OUTPUTFORMATTER aFormatter,
int  aNestLevel,
int  aControlBits 
) const
virtual

Output the object to aFormatter in s-expression form.

Parameters
aFormatterThe OUTPUTFORMATTER object to write to.
aNestLevelThe indentation next level.
aControlBitsThe control bit definition for object specific formatting.
Exceptions
IO_ERRORon write error.

Definition at line 29 of file title_block.cpp.

30 {
31  // Don't write the title block information if there is nothing to write.
32  bool isempty = true;
33  for( unsigned idx = 0; idx < m_tbTexts.GetCount(); idx++ )
34  {
35  if( ! m_tbTexts[idx].IsEmpty() )
36  {
37  isempty = false;
38  break;
39  }
40  }
41 
42  if( !isempty )
43  {
44  aFormatter->Print( aNestLevel, "(title_block\n" );
45 
46  if( !GetTitle().IsEmpty() )
47  aFormatter->Print( aNestLevel+1, "(title %s)\n",
48  aFormatter->Quotew( GetTitle() ).c_str() );
49 
50  if( !GetDate().IsEmpty() )
51  aFormatter->Print( aNestLevel+1, "(date %s)\n",
52  aFormatter->Quotew( GetDate() ).c_str() );
53 
54  if( !GetRevision().IsEmpty() )
55  aFormatter->Print( aNestLevel+1, "(rev %s)\n",
56  aFormatter->Quotew( GetRevision() ).c_str() );
57 
58  if( !GetCompany().IsEmpty() )
59  aFormatter->Print( aNestLevel+1, "(company %s)\n",
60  aFormatter->Quotew( GetCompany() ).c_str() );
61 
62  for( int ii = 0; ii < 9; ii++ )
63  {
64  if( !GetComment(ii).IsEmpty() )
65  aFormatter->Print( aNestLevel+1, "(comment %d %s)\n", ii+1,
66  aFormatter->Quotew( GetComment(ii) ).c_str() );
67  }
68 
69  aFormatter->Print( aNestLevel, ")\n\n" );
70  }
71 }
const wxString & GetComment(int aIdx) const
Definition: title_block.h:107
wxArrayString m_tbTexts
Definition: title_block.h:132
const wxString & GetRevision() const
Definition: title_block.h:86
const wxString & GetCompany() const
Definition: title_block.h:96
const wxString & GetDate() const
Definition: title_block.h:76
const wxString & GetTitle() const
Definition: title_block.h:63
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:408
std::string Quotew(const wxString &aWrapee) const
Definition: richio.cpp:476

References GetComment(), GetCompany(), GetDate(), GetRevision(), GetTitle(), m_tbTexts, OUTPUTFORMATTER::Print(), and OUTPUTFORMATTER::Quotew().

Referenced by SCH_SEXPR_PLUGIN::Format(), and PCB_IO::formatGeneral().

◆ GetComment()

const wxString& TITLE_BLOCK::GetComment ( int  aIdx) const
inline

◆ GetCompany()

const wxString& TITLE_BLOCK::GetCompany ( ) const
inline

◆ GetContextualTextVars()

void TITLE_BLOCK::GetContextualTextVars ( wxArrayString *  aVars)
static

Definition at line 73 of file title_block.cpp.

74 {
75  aVars->push_back( wxT( "ISSUE_DATE" ) );
76  aVars->push_back( wxT( "REVISION" ) );
77  aVars->push_back( wxT( "TITLE" ) );
78  aVars->push_back( wxT( "COMPANY" ) );
79  aVars->push_back( wxT( "COMMENT1" ) );
80  aVars->push_back( wxT( "COMMENT2" ) );
81  aVars->push_back( wxT( "COMMENT3" ) );
82  aVars->push_back( wxT( "COMMENT4" ) );
83  aVars->push_back( wxT( "COMMENT5" ) );
84  aVars->push_back( wxT( "COMMENT6" ) );
85  aVars->push_back( wxT( "COMMENT7" ) );
86  aVars->push_back( wxT( "COMMENT8" ) );
87  aVars->push_back( wxT( "COMMENT9" ) );
88 }

Referenced by SCH_SHEET::GetContextualTextVars(), and DS_DRAW_ITEM_LIST::GetTextVars().

◆ GetDate()

const wxString& TITLE_BLOCK::GetDate ( ) const
inline

◆ GetRevision()

◆ getTbText()

const wxString& TITLE_BLOCK::getTbText ( int  aIdx) const
inlineprivate

Definition at line 142 of file title_block.h.

143  {
144  static const wxString m_emptytext;
145 
146  if( (int)m_tbTexts.GetCount() > aIdx )
147  return m_tbTexts[aIdx];
148  else
149  return m_emptytext;
150  }
wxArrayString m_tbTexts
Definition: title_block.h:132

References m_tbTexts.

Referenced by GetComment(), GetCompany(), GetDate(), GetRevision(), and GetTitle().

◆ GetTitle()

◆ SetComment()

◆ SetCompany()

◆ SetDate()

◆ SetRevision()

◆ setTbText()

void TITLE_BLOCK::setTbText ( int  aIdx,
const wxString &  aText 
)
inlineprivate

Definition at line 134 of file title_block.h.

135  {
136  if( (int)m_tbTexts.GetCount() <= aIdx )
137  m_tbTexts.Add( wxEmptyString, aIdx + 1 - m_tbTexts.GetCount() );
138 
139  m_tbTexts[aIdx] = aText;
140  }
wxArrayString m_tbTexts
Definition: title_block.h:132

References m_tbTexts.

Referenced by SetComment(), SetCompany(), SetDate(), SetRevision(), and SetTitle().

◆ SetTitle()

◆ TextVarResolver()

bool TITLE_BLOCK::TextVarResolver ( wxString *  aToken,
const PROJECT aProject 
) const

Definition at line 91 of file title_block.cpp.

92 {
93  bool tokenUpdated = false;
94 
95  if( aToken->IsSameAs( wxT( "ISSUE_DATE" ) ) )
96  {
97  *aToken = GetDate();
98  tokenUpdated = true;
99  }
100  else if( aToken->IsSameAs( wxT( "REVISION" ) ) )
101  {
102  *aToken = GetRevision();
103  tokenUpdated = true;
104  }
105  else if( aToken->IsSameAs( wxT( "TITLE" ) ) )
106  {
107  *aToken = GetTitle();
108  tokenUpdated = true;
109  }
110  else if( aToken->IsSameAs( wxT( "COMPANY" ) ) )
111  {
112  *aToken = GetCompany();
113  tokenUpdated = true;
114  }
115  else if( aToken->Left( aToken->Len() - 1 ).IsSameAs( wxT( "COMMENT" ) ) )
116  {
117  wxChar c = aToken->Last();
118 
119  switch( c )
120  {
121  case '1':
122  case '2':
123  case '3':
124  case '4':
125  case '5':
126  case '6':
127  case '7':
128  case '8':
129  case '9':
130  *aToken = GetComment( c - '1' );
131  tokenUpdated = true;
132  }
133  }
134 
135  if( tokenUpdated )
136  {
137  *aToken = ExpandTextVars( *aToken, aProject );
138  return true;
139  }
140 
141  return false;
142 }
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject)
Definition: common.cpp:64
const wxString & GetComment(int aIdx) const
Definition: title_block.h:107
const wxString & GetRevision() const
Definition: title_block.h:86
const wxString & GetCompany() const
Definition: title_block.h:96
const wxString & GetDate() const
Definition: title_block.h:76
const wxString & GetTitle() const
Definition: title_block.h:63

References ExpandTextVars(), GetComment(), GetCompany(), GetDate(), GetRevision(), and GetTitle().

Referenced by SCH_SHEET::ResolveTextVar().

Member Data Documentation

◆ m_tbTexts

wxArrayString TITLE_BLOCK::m_tbTexts
private

Definition at line 132 of file title_block.h.

Referenced by Clear(), Format(), getTbText(), and setTbText().


The documentation for this class was generated from the following files: