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 The 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, see <https://www.gnu.org/licenses/>.
20 */
21
22#ifndef TITLE_BLOCK_H
23#define TITLE_BLOCK_H
24
25#include <wx/string.h>
26#include <wx/arrstr.h>
27#include <ki_exception.h>
28
29class OUTPUTFORMATTER;
30class PROJECT;
31
37{
38 // Texts are stored in wxArraystring.
39 // TEXTS_IDX gives the index of known texts in this array
41 {
46 COMMENT1_IDX // idx of the first comment: one can have more than 1 comment
47 };
48
49public:
51 virtual ~TITLE_BLOCK() {}; // a virtual dtor seems needed to build
52 // python lib without warning
53
54 void SetTitle( const wxString& aTitle )
55 {
56 setTbText( TITLE_IDX, aTitle );
57 }
58
59 const wxString& GetTitle() const
60 {
61 return getTbText( TITLE_IDX );
62 }
63
67 void SetDate( const wxString& aDate )
68 {
69 setTbText( DATE_IDX, aDate );
70 }
71
72 const wxString& GetDate() const
73 {
74 return getTbText( DATE_IDX );
75 }
76
77 void SetRevision( const wxString& aRevision )
78 {
79 setTbText( REVISION_IDX, aRevision );
80 }
81
82 const wxString& GetRevision() const
83 {
84 return getTbText( REVISION_IDX );
85 }
86
87 void SetCompany( const wxString& aCompany )
88 {
89 setTbText( COMPANY_IDX, aCompany );
90 }
91
92 const wxString& GetCompany() const
93 {
94 return getTbText( COMPANY_IDX );
95 }
96
97 void SetComment( int aIdx, const wxString& aComment )
98 {
99 aIdx += COMMENT1_IDX;
100 return setTbText( aIdx, aComment );
101 }
102
103 const wxString& GetComment( int aIdx ) const
104 {
105 aIdx += COMMENT1_IDX;
106 return getTbText( aIdx );
107 }
108
109 void Clear()
110 {
111 m_tbTexts.Clear();
112 }
113
114 static void GetContextualTextVars( wxArrayString* aVars );
115 bool TextVarResolver( wxString* aToken, const PROJECT* aProject, int aFlags = 0 ) const;
116
123 virtual void Format( OUTPUTFORMATTER* aFormatter ) const;
124
125 static wxString GetCurrentDate();
126 static wxString GetCurrentTimeHHMMSS();
127 static wxString GetCurrentTimeLocale();
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:291
Container for project specific data.
Definition project.h:62
const wxString & GetCompany() const
Definition title_block.h:92
void SetRevision(const wxString &aRevision)
Definition title_block.h:77
void SetComment(int aIdx, const wxString &aComment)
Definition title_block.h:97
const wxString & GetRevision() const
Definition title_block.h:82
void setTbText(int aIdx, const wxString &aText)
void SetTitle(const wxString &aTitle)
Definition title_block.h:54
const wxString & GetDate() const
Definition title_block.h:72
const wxString & GetComment(int aIdx) const
void SetCompany(const wxString &aCompany)
Definition title_block.h:87
virtual ~TITLE_BLOCK()
Definition title_block.h:51
wxArrayString m_tbTexts
const wxString & GetTitle() const
Definition title_block.h:59
void SetDate(const wxString &aDate)
Set the date field, and defaults to the current time and date.
Definition title_block.h:67
const wxString & getTbText(int aIdx) const
#define KICOMMON_API
Definition kicommon.h:27
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition ptree.cpp:194