KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 * Author: Dick Hollenbeck
5 *
6 * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#ifndef TITLE_BLOCK_H
27#define TITLE_BLOCK_H
28
29#include <wx/string.h>
30#include <wx/arrstr.h>
31#include <ki_exception.h>
32
33class OUTPUTFORMATTER;
34class PROJECT;
35
41{
42 // Texts are stored in wxArraystring.
43 // TEXTS_IDX gives the index of known texts in this array
45 {
50 COMMENT1_IDX // idx of the first comment: one can have more than 1 comment
51 };
52
53public:
55 virtual ~TITLE_BLOCK() {}; // a virtual dtor seems needed to build
56 // python lib without warning
57
58 void SetTitle( const wxString& aTitle )
59 {
60 setTbText( TITLE_IDX, aTitle );
61 }
62
63 const wxString& GetTitle() const
64 {
65 return getTbText( TITLE_IDX );
66 }
67
71 void SetDate( const wxString& aDate )
72 {
73 setTbText( DATE_IDX, aDate );
74 }
75
76 const wxString& GetDate() const
77 {
78 return getTbText( DATE_IDX );
79 }
80
81 void SetRevision( const wxString& aRevision )
82 {
83 setTbText( REVISION_IDX, aRevision );
84 }
85
86 const wxString& GetRevision() const
87 {
88 return getTbText( REVISION_IDX );
89 }
90
91 void SetCompany( const wxString& aCompany )
92 {
93 setTbText( COMPANY_IDX, aCompany );
94 }
95
96 const wxString& GetCompany() const
97 {
98 return getTbText( COMPANY_IDX );
99 }
100
101 void SetComment( int aIdx, const wxString& aComment )
102 {
103 aIdx += COMMENT1_IDX;
104 return setTbText( aIdx, aComment );
105 }
106
107 const wxString& GetComment( int aIdx ) const
108 {
109 aIdx += COMMENT1_IDX;
110 return getTbText( aIdx );
111 }
112
113 void Clear()
114 {
115 m_tbTexts.Clear();
116 }
117
118 static void GetContextualTextVars( wxArrayString* aVars );
119 bool TextVarResolver( wxString* aToken, const PROJECT* aProject, int aFlags = 0 ) const;
120
127 virtual void Format( OUTPUTFORMATTER* aFormatter ) const;
128
129private:
130 wxArrayString m_tbTexts;
131
132 void setTbText( int aIdx, const wxString& aText )
133 {
134 if( (int)m_tbTexts.GetCount() <= aIdx )
135 m_tbTexts.Add( wxEmptyString, aIdx + 1 - m_tbTexts.GetCount() );
136
137 m_tbTexts[aIdx] = aText;
138 }
139
140 const wxString& getTbText( int aIdx ) const
141 {
142 static const wxString m_emptytext;
143
144 if( (int)m_tbTexts.GetCount() > aIdx )
145 return m_tbTexts[aIdx];
146 else
147 return m_emptytext;
148 }
149};
150
151#endif // TITLE_BLOCK_H
An interface used to output 8 bit text in a convenient way.
Definition: richio.h:322
Container for project specific data.
Definition: project.h:64
Hold the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:41
const wxString & GetCompany() const
Definition: title_block.h:96
void SetRevision(const wxString &aRevision)
Definition: title_block.h:81
void SetComment(int aIdx, const wxString &aComment)
Definition: title_block.h:101
const wxString & GetRevision() const
Definition: title_block.h:86
bool TextVarResolver(wxString *aToken, const PROJECT *aProject, int aFlags=0) const
Definition: title_block.cpp:95
void setTbText(int aIdx, const wxString &aText)
Definition: title_block.h:132
void SetTitle(const wxString &aTitle)
Definition: title_block.h:58
const wxString & GetDate() const
Definition: title_block.h:76
const wxString & GetComment(int aIdx) const
Definition: title_block.h:107
void SetCompany(const wxString &aCompany)
Definition: title_block.h:91
virtual ~TITLE_BLOCK()
Definition: title_block.h:55
wxArrayString m_tbTexts
Definition: title_block.h:130
const wxString & GetTitle() const
Definition: title_block.h:63
void SetDate(const wxString &aDate)
Set the date field, and defaults to the current time and date.
Definition: title_block.h:71
const wxString & getTbText(int aIdx) const
Definition: title_block.h:140
void Clear()
Definition: title_block.h:113
virtual void Format(OUTPUTFORMATTER *aFormatter) const
Output the object to aFormatter in s-expression form.
Definition: title_block.cpp:30
static void GetContextualTextVars(wxArrayString *aVars)
Definition: title_block.cpp:73