KiCad PCB EDA Suite
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 TITLE_BLOCK_H
25 #define TITLE_BLOCK_H
26 
27 #include <wx/string.h>
28 #include <wx/arrstr.h>
29 #include <ki_exception.h>
30 
31 class OUTPUTFORMATTER;
32 
41 {
42  // Texts are stored in wxArraystring.
43  // textsIdx gives the index of known texts in
44  // this array
45  enum textsIdx
46  {
47  titleIdx = 0,
52  };
53 
54 public:
55 
57  virtual ~TITLE_BLOCK() {}; // a virtual dtor seems needed to build
58  // python lib without warning
59 
60  void SetTitle( const wxString& aTitle )
61  {
62  setTbText( titleIdx, aTitle );
63  }
64 
65  const wxString& GetTitle() const
66  {
67  return getTbText( titleIdx );
68  }
69 
74  void SetDate( const wxString& aDate )
75  {
76  setTbText( dateIdx, aDate );
77  }
78 
79  const wxString& GetDate() const
80  {
81  return getTbText( dateIdx );
82  }
83 
84  void SetRevision( const wxString& aRevision )
85  {
86  setTbText( revisionIdx, aRevision );
87  }
88 
89  const wxString& GetRevision() const
90  {
91  return getTbText( revisionIdx );
92  }
93 
94  void SetCompany( const wxString& aCompany )
95  {
96  setTbText( companyIdx, aCompany );
97  }
98 
99  const wxString& GetCompany() const
100  {
101  return getTbText( companyIdx );
102  }
103 
104  void SetComment( int aIdx, const wxString& aComment )
105  {
106  aIdx += m_commentIdx;
107  return setTbText( aIdx, aComment );
108  }
109 
110  const wxString& GetComment( int aIdx ) const
111  {
112  aIdx += m_commentIdx;
113  return getTbText( aIdx );
114  }
115 
116  // Only for old code compatibility. Will be removed later
117  void SetComment1( const wxString& aComment ) { SetComment( 0, aComment ); }
118  void SetComment2( const wxString& aComment ) { SetComment( 1, aComment ); }
119  void SetComment3( const wxString& aComment ) { SetComment( 2, aComment ); }
120  void SetComment4( const wxString& aComment ) { SetComment( 3, aComment ); }
121  const wxString& GetComment1( ) const { return GetComment( 0 ); }
122  const wxString& GetComment2( ) const { return GetComment( 1 ); }
123  const wxString& GetComment3( ) const { return GetComment( 2 ); }
124  const wxString& GetComment4( ) const { return GetComment( 3 ); }
125 
126 
127  void Clear()
128  {
129  m_tbTexts.Clear();
130  }
131 
141  virtual void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const;
142 
143 private:
144  wxArrayString m_tbTexts;
145 
146  void setTbText( int aIdx, const wxString& aText )
147  {
148  if( (int)m_tbTexts.GetCount() <= aIdx )
149  m_tbTexts.Add( wxEmptyString, aIdx + 1 - m_tbTexts.GetCount() );
150  m_tbTexts[aIdx] = aText;
151  }
152 
153  const wxString& getTbText( int aIdx ) const
154  {
155  static const wxString m_emptytext;
156 
157  if( (int)m_tbTexts.GetCount() > aIdx )
158  return m_tbTexts[aIdx];
159  else
160  return m_emptytext;
161  }
162 };
163 
164 #endif // TITLE_BLOCK_H
void SetComment1(const wxString &aComment)
Definition: title_block.h:117
const wxString & GetCompany() const
Definition: title_block.h:99
void SetRevision(const wxString &aRevision)
Definition: title_block.h:84
const wxString & GetComment(int aIdx) const
Definition: title_block.h:110
const wxString & GetComment4() const
Definition: title_block.h:124
void SetDate(const wxString &aDate)
Function SetDate sets the date field, and defaults to the current time and date.
Definition: title_block.h:74
Class OUTPUTFORMATTER is an important interface (abstract class) used to output 8 bit text in a conve...
Definition: richio.h:327
void Clear()
Definition: title_block.h:127
const wxString & GetDate() const
Definition: title_block.h:79
Class TITLE_BLOCK holds the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:40
void SetComment4(const wxString &aComment)
Definition: title_block.h:120
wxArrayString m_tbTexts
Definition: title_block.h:144
const wxString & GetTitle() const
Definition: title_block.h:65
void SetComment(int aIdx, const wxString &aComment)
Definition: title_block.h:104
const wxString & GetRevision() const
Definition: title_block.h:89
void SetCompany(const wxString &aCompany)
Definition: title_block.h:94
virtual void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Function Format outputs the object to aFormatter in s-expression form.
Definition: worksheet.cpp:168
const wxString & GetComment3() const
Definition: title_block.h:123
void SetTitle(const wxString &aTitle)
Definition: title_block.h:60
const wxString & GetComment2() const
Definition: title_block.h:122
const wxString & getTbText(int aIdx) const
Definition: title_block.h:153
void SetComment2(const wxString &aComment)
Definition: title_block.h:118
const wxString & GetComment1() const
Definition: title_block.h:121
virtual ~TITLE_BLOCK()
Definition: title_block.h:57
void SetComment3(const wxString &aComment)
Definition: title_block.h:119
void setTbText(int aIdx, const wxString &aText)
Definition: title_block.h:146