KiCad PCB EDA Suite
WORKSHEET_LAYOUT_STRINGIO Class Reference
Inheritance diagram for WORKSHEET_LAYOUT_STRINGIO:
WORKSHEET_LAYOUT_IO

Public Member Functions

 WORKSHEET_LAYOUT_STRINGIO (wxString &aOutputString)
 
 ~WORKSHEET_LAYOUT_STRINGIO ()
 
void Format (WORKSHEET_LAYOUT *aPageLayout) const
 
void Format (WORKSHEET_DATAITEM *aItem, int aNestLevel) const
 

Protected Attributes

OUTPUTFORMATTERm_out
 

Private Attributes

STRING_FORMATTERm_writer
 
wxString & m_output
 

Detailed Description

Definition at line 112 of file page_layout_writer.cpp.

Constructor & Destructor Documentation

WORKSHEET_LAYOUT_STRINGIO::WORKSHEET_LAYOUT_STRINGIO ( wxString &  aOutputString)
inline

Definition at line 118 of file page_layout_writer.cpp.

References IO_ERROR::What().

118  :
119  WORKSHEET_LAYOUT_IO(), m_output( aOutputString )
120  {
121  try
122  {
123  m_writer = new STRING_FORMATTER();
124  m_out = m_writer;
125  }
126  catch( const IO_ERROR& ioe )
127  {
128  wxMessageBox( ioe.What(), _( "Error writing page layout descr file" ) );
129  }
130  }
OUTPUTFORMATTER * m_out
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
Class STRING_FORMATTER implements OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:445
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:47
WORKSHEET_LAYOUT_STRINGIO::~WORKSHEET_LAYOUT_STRINGIO ( )
inline

Definition at line 132 of file page_layout_writer.cpp.

References FROM_UTF8(), and STRING_FORMATTER::GetString().

133  {
134  m_output = FROM_UTF8( m_writer->GetString().c_str() );
135  delete m_writer;
136  }
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes...
Definition: macros.h:53
const std::string & GetString()
Definition: richio.h:475

Member Function Documentation

void WORKSHEET_LAYOUT_IO::Format ( WORKSHEET_LAYOUT aPageLayout) const
inherited

Definition at line 186 of file page_layout_writer.cpp.

References double2Str, Format(), WORKSHEET_LAYOUT::GetBottomMargin(), WORKSHEET_LAYOUT::GetCount(), WORKSHEET_LAYOUT::GetItem(), WORKSHEET_LAYOUT::GetLeftMargin(), WORKSHEET_LAYOUT::GetRightMargin(), getTokenName(), WORKSHEET_LAYOUT::GetTopMargin(), WORKSHEET_DATAITEM::m_DefaultLineWidth, WORKSHEET_DATAITEM::m_DefaultTextSize, WORKSHEET_DATAITEM::m_DefaultTextThickness, TB_READER_T::T_bottom_margin, TB_READER_T::T_left_margin, TB_READER_T::T_right_margin, TB_READER_T::T_setup, and TB_READER_T::T_top_margin.

Referenced by WORKSHEET_LAYOUT::Save(), and WORKSHEET_LAYOUT::SaveInString().

187 {
188  LOCALE_IO toggle; // switch on/off the locale "C" notation
189 
190  m_out->Print( 0, "(page_layout\n" );
191 
192  // Setup
193  int nestLevel = 1;
194  // Write default values:
195  m_out->Print( nestLevel, "(%s ", getTokenName( T_setup ) );
196  m_out->Print( 0, "(textsize %s %s)",
199  m_out->Print( 0, "(linewidth %s)", double2Str( WORKSHEET_DATAITEM::m_DefaultLineWidth ).c_str() );
200  m_out->Print( 0, "(textlinewidth %s)", double2Str( WORKSHEET_DATAITEM::m_DefaultTextThickness ).c_str() );
201  m_out->Print( 0, "\n" );
202 
203  // Write margin values
204  m_out->Print( nestLevel, "(%s %s)", getTokenName( T_left_margin ),
205  double2Str( aPageLayout->GetLeftMargin() ).c_str() );
206  m_out->Print( 0, "(%s %s)", getTokenName( T_right_margin ),
207  double2Str( aPageLayout->GetRightMargin() ).c_str() );
208  m_out->Print( 0, "(%s %s)", getTokenName( T_top_margin ),
209  double2Str( aPageLayout->GetTopMargin() ).c_str() );
210  m_out->Print( 0, "(%s %s)", getTokenName( T_bottom_margin ),
211  double2Str( aPageLayout->GetBottomMargin() ).c_str() );
212  m_out->Print( 0, ")\n" );
213 
214  // Save the graphical items on the page layout
215  for( unsigned ii = 0; ii < aPageLayout->GetCount(); ii++ )
216  {
217  WORKSHEET_DATAITEM* item = aPageLayout->GetItem( ii );
218  Format( item, nestLevel );
219  }
220 
221  m_out->Print( 0, ")\n" );
222 }
#define double2Str
Class LOCALE_IO is a class that can be instantiated within a scope in which you are expecting excepti...
Definition: common.h:166
OUTPUTFORMATTER * m_out
void Format(WORKSHEET_LAYOUT *aPageLayout) const
WORKSHEET_DATAITEM * GetItem(unsigned aIdx) const
unsigned GetCount() const
static double m_DefaultTextThickness
static const char * getTokenName(T aTok)
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:408
void WORKSHEET_LAYOUT_IO::Format ( WORKSHEET_DATAITEM aItem,
int  aNestLevel 
) const
inherited

Definition at line 159 of file page_layout_writer.cpp.

References WORKSHEET_DATAITEM::GetType(), WORKSHEET_DATAITEM::WS_BITMAP, WORKSHEET_DATAITEM::WS_POLYPOLYGON, WORKSHEET_DATAITEM::WS_RECT, WORKSHEET_DATAITEM::WS_SEGMENT, and WORKSHEET_DATAITEM::WS_TEXT.

160 {
161  switch( aItem->GetType() )
162  {
164  format( (WORKSHEET_DATAITEM_TEXT*) aItem, aNestLevel );
165  break;
166 
169  format( aItem, aNestLevel );
170  break;
171 
173  format( (WORKSHEET_DATAITEM_POLYPOLYGON*) aItem, aNestLevel );
174  break;
175 
177  format( (WORKSHEET_DATAITEM_BITMAP*) aItem, aNestLevel );
178  break;
179 
180  default:
181  wxFAIL_MSG( wxT( "Cannot format item" ) );
182  }
183 }
void format(WORKSHEET_LAYOUT *aPageLayout) const
WS_ItemType GetType() const

Member Data Documentation

OUTPUTFORMATTER* WORKSHEET_LAYOUT_IO::m_out
protectedinherited

Definition at line 60 of file page_layout_writer.cpp.

wxString& WORKSHEET_LAYOUT_STRINGIO::m_output
private

Definition at line 115 of file page_layout_writer.cpp.

STRING_FORMATTER* WORKSHEET_LAYOUT_STRINGIO::m_writer
private

Definition at line 114 of file page_layout_writer.cpp.


The documentation for this class was generated from the following file: