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 <common.h>
28#include <ki_exception.h>
29
30class OUTPUTFORMATTER;
31class PROJECT;
32
38{
39 // Texts are stored in wxArraystring.
40 // TEXTS_IDX gives the index of known texts in this array
42 {
47 COMMENT1_IDX // idx of the first comment: one can have more than 1 comment
48 };
49
50public:
52 virtual ~TITLE_BLOCK() {}; // a virtual dtor seems needed to build
53 // python lib without warning
54
55 void SetTitle( const wxString& aTitle )
56 {
57 setTbText( TITLE_IDX, aTitle );
58 }
59
60 const wxString& GetTitle() const
61 {
62 return getTbText( TITLE_IDX );
63 }
64
68 void SetDate( const wxString& aDate )
69 {
70 setTbText( DATE_IDX, aDate );
71 }
72
73 const wxString& GetDate() const
74 {
75 return getTbText( DATE_IDX );
76 }
77
78 void SetRevision( const wxString& aRevision )
79 {
80 setTbText( REVISION_IDX, aRevision );
81 }
82
83 const wxString& GetRevision() const
84 {
85 return getTbText( REVISION_IDX );
86 }
87
88 void SetCompany( const wxString& aCompany )
89 {
90 setTbText( COMPANY_IDX, aCompany );
91 }
92
93 const wxString& GetCompany() const
94 {
95 return getTbText( COMPANY_IDX );
96 }
97
98 void SetComment( int aIdx, const wxString& aComment )
99 {
100 aIdx += COMMENT1_IDX;
101 return setTbText( aIdx, aComment );
102 }
103
104 const wxString& GetComment( int aIdx ) const
105 {
106 aIdx += COMMENT1_IDX;
107 return getTbText( aIdx );
108 }
109
110 void Clear()
111 {
112 m_tbTexts.Clear();
113 }
114
115 static void GetContextualTextVars( wxArrayString* aVars );
116 bool TextVarResolver( wxString* aToken, const PROJECT* aProject, RESOLUTION_CONTEXT aContext ) const;
117
124 virtual void Format( OUTPUTFORMATTER* aFormatter ) const;
125
126 static wxString GetCurrentDate();
127 static wxString GetCurrentTimeHHMMSS();
128 static wxString GetCurrentTimeLocale();
129
130private:
131 wxArrayString m_tbTexts;
132
133 void setTbText( int aIdx, const wxString& aText )
134 {
135 if( (int)m_tbTexts.GetCount() <= aIdx )
136 m_tbTexts.Add( wxEmptyString, aIdx + 1 - m_tbTexts.GetCount() );
137
138 m_tbTexts[aIdx] = aText;
139 }
140
141 const wxString& getTbText( int aIdx ) const
142 {
143 static const wxString m_emptytext;
144
145 if( (int)m_tbTexts.GetCount() > aIdx )
146 return m_tbTexts[aIdx];
147 else
148 return m_emptytext;
149 }
150};
151
152#endif // TITLE_BLOCK_H
An interface used to output 8 bit text in a convenient way.
Definition richio.h:294
Container for project specific data.
Definition project.h:63
const wxString & GetCompany() const
Definition title_block.h:93
void SetRevision(const wxString &aRevision)
Definition title_block.h:78
void SetComment(int aIdx, const wxString &aComment)
Definition title_block.h:98
const wxString & GetRevision() const
Definition title_block.h:83
void setTbText(int aIdx, const wxString &aText)
void SetTitle(const wxString &aTitle)
Definition title_block.h:55
const wxString & GetDate() const
Definition title_block.h:73
const wxString & GetComment(int aIdx) const
void SetCompany(const wxString &aCompany)
Definition title_block.h:88
virtual ~TITLE_BLOCK()
Definition title_block.h:52
wxArrayString m_tbTexts
const wxString & GetTitle() const
Definition title_block.h:60
void SetDate(const wxString &aDate)
Set the date field, and defaults to the current time and date.
Definition title_block.h:68
const wxString & getTbText(int aIdx) const
RESOLUTION_CONTEXT
Definition common.h:87
#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