KiCad PCB EDA Suite
class_title_block.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #ifndef CLASS_TITLE_BLOCK_H_
25 #define CLASS_TITLE_BLOCK_H_
26 
27 #include <wx/string.h>
28 #include <ki_exception.h>
29 
30 class OUTPUTFORMATTER;
31 
40 {
41  // Texts are stored in wxArraystring.
42  // textsIdx gives the index of known texts in
43  // this array
44  enum textsIdx
45  {
46  titleIdx = 0,
51  };
52 
53 public:
54 
56  virtual ~TITLE_BLOCK() {}; // a virtual dtor seems needed to build
57  // python lib without warning
58 
59  void SetTitle( const wxString& aTitle )
60  {
61  setTbText( titleIdx, aTitle );
62  }
63 
64  const wxString& GetTitle() const
65  {
66  return getTbText( titleIdx );
67  }
68 
73  void SetDate( const wxString& aDate )
74  {
75  setTbText( dateIdx, aDate );
76  }
77 
78  const wxString& GetDate() const
79  {
80  return getTbText( dateIdx );
81  }
82 
83  void SetRevision( const wxString& aRevision )
84  {
85  setTbText( revisionIdx, aRevision );
86  }
87 
88  const wxString& GetRevision() const
89  {
90  return getTbText( revisionIdx );
91  }
92 
93  void SetCompany( const wxString& aCompany )
94  {
95  setTbText( companyIdx, aCompany );
96  }
97 
98  const wxString& GetCompany() const
99  {
100  return getTbText( companyIdx );
101  }
102 
103  void SetComment( int aIdx, const wxString& aComment )
104  {
105  aIdx += m_commentIdx;
106  return setTbText( aIdx, aComment );
107  }
108 
109  const wxString& GetComment( int aIdx ) const
110  {
111  aIdx += m_commentIdx;
112  return getTbText( aIdx );
113  }
114 
115  // Only for old code compatibility. Will be removed later
116  void SetComment1( const wxString& aComment ) { SetComment( 0, aComment ); }
117  void SetComment2( const wxString& aComment ) { SetComment( 1, aComment ); }
118  void SetComment3( const wxString& aComment ) { SetComment( 2, aComment ); }
119  void SetComment4( const wxString& aComment ) { SetComment( 3, aComment ); }
120  const wxString& GetComment1( ) const { return GetComment( 0 ); }
121  const wxString& GetComment2( ) const { return GetComment( 1 ); }
122  const wxString& GetComment3( ) const { return GetComment( 2 ); }
123  const wxString& GetComment4( ) const { return GetComment( 3 ); }
124 
125 
126  void Clear()
127  {
128  m_tbTexts.Clear();
129  }
130 
140  virtual void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const;
141 
142 private:
143  wxArrayString m_tbTexts;
144 
145  void setTbText( int aIdx, const wxString& aText )
146  {
147  if( (int)m_tbTexts.GetCount() <= aIdx )
148  m_tbTexts.Add( wxEmptyString, aIdx + 1 - m_tbTexts.GetCount() );
149  m_tbTexts[aIdx] = aText;
150  }
151 
152  const wxString& getTbText( int aIdx ) const
153  {
154  static const wxString m_emptytext;
155 
156  if( (int)m_tbTexts.GetCount() > aIdx )
157  return m_tbTexts[aIdx];
158  else
159  return m_emptytext;
160  }
161 };
162 
163 #endif // CLASS_TITLE_BLOCK_H_
void SetComment1(const wxString &aComment)
const wxString & GetCompany() const
void SetRevision(const wxString &aRevision)
const wxString & GetComment(int aIdx) const
const wxString & GetComment4() const
void SetDate(const wxString &aDate)
Function SetDate sets the date field, and defaults to the current time and date.
Class OUTPUTFORMATTER is an important interface (abstract class) used to output 8 bit text in a conve...
Definition: richio.h:327
const wxString & GetDate() const
Class TITLE_BLOCK holds the information shown in the lower right corner of a plot, printout, or editing view.
void SetComment4(const wxString &aComment)
wxArrayString m_tbTexts
const wxString & GetTitle() const
void SetComment(int aIdx, const wxString &aComment)
const wxString & GetRevision() const
void SetCompany(const wxString &aCompany)
virtual void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Function Format outputs the object to aFormatter in s-expression form.
Definition: worksheet.cpp:245
const wxString & GetComment3() const
void SetTitle(const wxString &aTitle)
const wxString & GetComment2() const
const wxString & getTbText(int aIdx) const
void SetComment2(const wxString &aComment)
const wxString & GetComment1() const
virtual ~TITLE_BLOCK()
void SetComment3(const wxString &aComment)
void setTbText(int aIdx, const wxString &aText)