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 throw ( IO_ERROR )
 
void Format (WORKSHEET_DATAITEM *aItem, int aNestLevel) const throw ( IO_ERROR )
 

Protected Attributes

OUTPUTFORMATTERm_out
 

Private Attributes

STRING_FORMATTERm_writer
 
wxString & m_output
 

Detailed Description

Definition at line 117 of file page_layout_writer.cpp.

Constructor & Destructor Documentation

WORKSHEET_LAYOUT_STRINGIO::WORKSHEET_LAYOUT_STRINGIO ( wxString &  aOutputString)
inline

Definition at line 123 of file page_layout_writer.cpp.

References IO_ERROR::What().

123  :
124  WORKSHEET_LAYOUT_IO(), m_output( aOutputString )
125  {
126  try
127  {
128  m_writer = new STRING_FORMATTER();
129  m_out = m_writer;
130  }
131  catch( const IO_ERROR& ioe )
132  {
133  wxMessageBox( ioe.What(), _( "Error writing page layout descr file" ) );
134  }
135  }
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 137 of file page_layout_writer.cpp.

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

138  {
139  m_output = FROM_UTF8( m_writer->GetString().c_str() );
140  delete m_writer;
141  }
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
throw (IO_ERROR
)
inherited

Definition at line 192 of file page_layout_writer.cpp.

References double2Str, Format(), getTokenName(), WORKSHEET_DATAITEM::m_DefaultLineWidth, WORKSHEET_DATAITEM::m_DefaultTextSize, WORKSHEET_DATAITEM::m_DefaultTextThickness, OUTPUTFORMATTER::Print(), 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().

194 {
195  LOCALE_IO toggle; // switch on/off the locale "C" notation
196 
197  m_out->Print( 0, "(page_layout\n" );
198 
199  // Setup
200  int nestLevel = 1;
201  // Write default values:
202  m_out->Print( nestLevel, "(%s ", getTokenName( T_setup ) );
203  m_out->Print( 0, "(textsize %s %s)",
206  m_out->Print( 0, "(linewidth %s)", double2Str( WORKSHEET_DATAITEM::m_DefaultLineWidth ).c_str() );
207  m_out->Print( 0, "(textlinewidth %s)", double2Str( WORKSHEET_DATAITEM::m_DefaultTextThickness ).c_str() );
208  m_out->Print( 0, "\n" );
209 
210  // Write margin values
211  m_out->Print( nestLevel, "(%s %s)", getTokenName( T_left_margin ),
212  double2Str( aPageLayout->GetLeftMargin() ).c_str() );
213  m_out->Print( 0, "(%s %s)", getTokenName( T_right_margin ),
214  double2Str( aPageLayout->GetRightMargin() ).c_str() );
215  m_out->Print( 0, "(%s %s)", getTokenName( T_top_margin ),
216  double2Str( aPageLayout->GetTopMargin() ).c_str() );
217  m_out->Print( 0, "(%s %s)", getTokenName( T_bottom_margin ),
218  double2Str( aPageLayout->GetBottomMargin() ).c_str() );
219  m_out->Print( 0, ")\n" );
220 
221  // Save the graphical items on the page layout
222  for( unsigned ii = 0; ii < aPageLayout->GetCount(); ii++ )
223  {
224  WORKSHEET_DATAITEM* item = aPageLayout->GetItem( ii );
225  Format( item, nestLevel );
226  }
227 
228  m_out->Print( 0, ")\n" );
229 }
#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
throw (IO_ERROR
)
inherited

Definition at line 164 of file page_layout_writer.cpp.

References WORKSHEET_DATAITEM::WS_BITMAP, WORKSHEET_DATAITEM::WS_POLYPOLYGON, WORKSHEET_DATAITEM::WS_RECT, WORKSHEET_DATAITEM::WS_SEGMENT, and WORKSHEET_DATAITEM::WS_TEXT.

166 {
167  switch( aItem->GetType() )
168  {
170  format( (WORKSHEET_DATAITEM_TEXT*) aItem, aNestLevel );
171  break;
172 
175  format( aItem, aNestLevel );
176  break;
177 
179  format( (WORKSHEET_DATAITEM_POLYPOLYGON*) aItem, aNestLevel );
180  break;
181 
183  format( (WORKSHEET_DATAITEM_BITMAP*) aItem, aNestLevel );
184  break;
185 
186  default:
187  wxFAIL_MSG( wxT( "Cannot format item" ) );
188  }
189 }
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 120 of file page_layout_writer.cpp.

STRING_FORMATTER* WORKSHEET_LAYOUT_STRINGIO::m_writer
private

Definition at line 119 of file page_layout_writer.cpp.


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