KiCad PCB EDA Suite
PAGE_INFO Class Reference

Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or plot. More...

#include <class_page_info.h>

Public Member Functions

 PAGE_INFO (const wxString &aType=PAGE_INFO::A3, bool IsPortrait=false)
 
bool SetType (const wxString &aStandardPageDescriptionName, bool IsPortrait=false)
 Function SetType sets the name of the page type and also the sizes and margins commonly associated with that type name. More...
 
const wxString & GetType () const
 
bool IsDefault () const
 Function IsDefault. More...
 
bool IsCustom () const
 Function IsCustom returns true if the type is Custom. More...
 
void SetPortrait (bool isPortrait)
 Function SetPortrait will rotate the paper page 90 degrees. More...
 
bool IsPortrait () const
 
wxPrintOrientation GetWxOrientation () const
 Function GetWxOrientation. More...
 
wxPaperSize GetPaperId () const
 Function GetPaperId. More...
 
void SetWidthMils (int aWidthInMils)
 
int GetWidthMils () const
 
void SetHeightMils (int aHeightInMils)
 
int GetHeightMils () const
 
const wxSize & GetSizeMils () const
 
void Format (OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
 Function GetStandardSizes returns the standard page types, such as "A4", "A3", etc. More...
 

Static Public Member Functions

static void SetCustomWidthMils (int aWidthInMils)
 Function SetCustomWidthMils sets the width of Custom page in mils, for any custom page constructed or made via SetType() after making this call. More...
 
static void SetCustomHeightMils (int aHeightInMils)
 Function SetCustomHeightMils sets the height of Custom page in mils, for any custom page constructed or made via SetType() after making this call. More...
 
static int GetCustomWidthMils ()
 Function GetCustomWidthMils. More...
 
static int GetCustomHeightMils ()
 Function GetCustomHeightMils. More...
 

Static Public Attributes

static const wxChar A4 [] = wxT( "A4" )
 
static const wxChar A3 [] = wxT( "A3" )
 
static const wxChar A2 [] = wxT( "A2" )
 
static const wxChar A1 [] = wxT( "A1" )
 
static const wxChar A0 [] = wxT( "A0" )
 
static const wxChar A [] = wxT( "A" )
 
static const wxChar B [] = wxT( "B" )
 
static const wxChar C [] = wxT( "C" )
 
static const wxChar D [] = wxT( "D" )
 
static const wxChar E [] = wxT( "E" )
 
static const wxChar GERBER [] = wxT( "GERBER" )
 
static const wxChar USLetter [] = wxT( "USLetter" )
 
static const wxChar USLegal [] = wxT( "USLegal" )
 
static const wxChar USLedger [] = wxT( "USLedger" )
 
static const wxChar Custom [] = wxT( "User" )
 "User" defined page type More...
 

Protected Member Functions

 PAGE_INFO (const wxSize &aSizeMils, const wxString &aName, wxPaperSize aPaperId)
 

Private Member Functions

void updatePortrait ()
 
void setMargins ()
 

Private Attributes

wxString m_type
 paper type: A4, A3, etc. More...
 
wxSize m_size
 mils More...
 
bool m_portrait
 true if portrait, false if landscape More...
 
wxPaperSize m_paper_id
 wx' style paper id. More...
 

Static Private Attributes

static const PAGE_INFO pageA4
 
static const PAGE_INFO pageA3
 
static const PAGE_INFO pageA2
 
static const PAGE_INFO pageA1
 
static const PAGE_INFO pageA0
 
static const PAGE_INFO pageA
 
static const PAGE_INFO pageB
 
static const PAGE_INFO pageC
 
static const PAGE_INFO pageD
 
static const PAGE_INFO pageE
 
static const PAGE_INFO pageGERBER
 
static const PAGE_INFO pageUSLetter
 
static const PAGE_INFO pageUSLegal
 
static const PAGE_INFO pageUSLedger
 
static const PAGE_INFO pageUser
 
static int s_user_height = 11000
 
static int s_user_width = 17000
 

Detailed Description

Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or plot.

Paper sizes are often described in inches. Here paper is described in 1/1000th of an inch (mils). For convenience there are some read only accessors for internal units (IU), which is a compile time calculation, not runtime.

Author
Dick Hollenbeck

Definition at line 49 of file class_page_info.h.

Constructor & Destructor Documentation

PAGE_INFO::PAGE_INFO ( const wxString &  aType = PAGE_INFO::A3,
bool  IsPortrait = false 
)

Definition at line 111 of file class_page_info.cpp.

References SetType().

112 {
113  SetType( aType, IsPortrait );
114 }
bool IsPortrait() const
bool SetType(const wxString &aStandardPageDescriptionName, bool IsPortrait=false)
Function SetType sets the name of the page type and also the sizes and margins commonly associated wi...
PAGE_INFO::PAGE_INFO ( const wxSize &  aSizeMils,
const wxString &  aName,
wxPaperSize  aPaperId 
)
protected

Definition at line 100 of file class_page_info.cpp.

References updatePortrait().

100  :
101  m_type( aType ), m_size( aSizeMils ), m_paper_id( aPaperId )
102 {
103  updatePortrait();
104 
105  // This constructor is protected, and only used by const PAGE_INFO's known
106  // only to class implementation, so no further changes to "this" object are
107  // expected.
108 }
void updatePortrait()
wxSize m_size
mils
wxString m_type
paper type: A4, A3, etc.
wxPaperSize m_paper_id
wx' style paper id.

Member Function Documentation

void PAGE_INFO::Format ( OUTPUTFORMATTER aFormatter,
int  aNestLevel,
int  aControlBits 
) const

Function GetStandardSizes returns the standard page types, such as "A4", "A3", etc.

static wxArrayString GetStandardSizes(); Function Format outputs the page class to aFormatter in s-expression form.

Parameters
aFormatterThe OUTPUTFORMATTER object to write to.
aNestLevelThe indentation next level.
aControlBitsThe control bit definition for object specific formatting.
Exceptions
IO_ERRORon write error.

Definition at line 267 of file class_page_info.cpp.

References Custom, GetHeightMils(), GetType(), GetWidthMils(), IsCustom(), IsPortrait(), OUTPUTFORMATTER::Print(), and OUTPUTFORMATTER::Quotew().

Referenced by PCB_IO::formatGeneral().

268 {
269  aFormatter->Print( aNestLevel, "(page %s", aFormatter->Quotew( GetType() ).c_str() );
270 
271  // The page dimensions are only required for user defined page sizes.
272  // Internally, the page size is in mils
273  if( GetType() == PAGE_INFO::Custom )
274  aFormatter->Print( 0, " %g %g",
275  GetWidthMils() * 25.4 / 1000.0,
276  GetHeightMils() * 25.4 / 1000.0 );
277 
278  if( !IsCustom() && IsPortrait() )
279  aFormatter->Print( 0, " portrait" );
280 
281  aFormatter->Print( 0, ")\n" );
282 }
static const wxChar Custom[]
"User" defined page type
bool IsPortrait() const
std::string Quotew(const wxString &aWrapee)
Definition: richio.cpp:482
int GetWidthMils() const
bool IsCustom() const
Function IsCustom returns true if the type is Custom.
const wxString & GetType() const
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
int GetHeightMils() const
static int PAGE_INFO::GetCustomHeightMils ( )
inlinestatic

Function GetCustomHeightMils.

Returns
int - custom paper height in mils.

Definition at line 171 of file class_page_info.h.

References s_user_height.

Referenced by DIALOG_PAGES_SETTINGS::initDialog().

171 { return s_user_height; }
static int s_user_height
static int PAGE_INFO::GetCustomWidthMils ( )
inlinestatic

Function GetCustomWidthMils.

Returns
int - custom paper width in mils.

Definition at line 165 of file class_page_info.h.

References s_user_width.

Referenced by DIALOG_PAGES_SETTINGS::initDialog().

165 { return s_user_width; }
static int s_user_width
wxPaperSize PAGE_INFO::GetPaperId ( ) const
inline

Function GetPaperId.

Returns
wxPaperSize - wxPrintData's style paper id associated with page type name.

Definition at line 129 of file class_page_info.h.

References m_paper_id.

Referenced by DIALOG_PRINT_USING_PRINTER::initDialog(), FOOTPRINT_EDIT_FRAME::ToPrinter(), PCB_EDIT_FRAME::ToPrinter(), and PL_EDITOR_FRAME::ToPrinter().

129 { return m_paper_id; }
wxPaperSize m_paper_id
wx' style paper id.
wxPrintOrientation PAGE_INFO::GetWxOrientation ( ) const
inline

Function GetWxOrientation.

Returns
ws' style printing orientation (wxPORTRAIT or wxLANDSCAPE).

Definition at line 122 of file class_page_info.h.

References IsPortrait().

Referenced by DIALOG_PRINT_USING_PRINTER::initDialog(), FOOTPRINT_EDIT_FRAME::ToPrinter(), PCB_EDIT_FRAME::ToPrinter(), and PL_EDITOR_FRAME::ToPrinter().

122 { return IsPortrait() ? wxPORTRAIT : wxLANDSCAPE; }
bool IsPortrait() const
bool PAGE_INFO::IsCustom ( ) const

Function IsCustom returns true if the type is Custom.

Definition at line 176 of file class_page_info.cpp.

References Custom, and m_type.

Referenced by SCH_LEGACY_PLUGIN::Format(), Format(), DIALOG_PRINT_USING_PRINTER::initDialog(), PS_PLOTTER::StartPlot(), PCB_EDIT_FRAME::ToPrinter(), and PL_EDITOR_FRAME::ToPrinter().

177 {
178  return m_type == Custom;
179 }
static const wxChar Custom[]
"User" defined page type
wxString m_type
paper type: A4, A3, etc.
bool PAGE_INFO::IsDefault ( ) const
inline

Function IsDefault.

Returns
True if the object has the default page settings which are A3, landscape.

Definition at line 98 of file class_page_info.h.

References A3, m_portrait, and m_type.

98 { return m_type == PAGE_INFO::A3 && !m_portrait; }
static const wxChar A3[]
wxString m_type
paper type: A4, A3, etc.
bool m_portrait
true if portrait, false if landscape
void PAGE_INFO::SetCustomHeightMils ( int  aHeightInMils)
static

Function SetCustomHeightMils sets the height of Custom page in mils, for any custom page constructed or made via SetType() after making this call.

Definition at line 233 of file class_page_info.cpp.

References clampHeight(), and s_user_height.

Referenced by DIALOG_PAGES_SETTINGS::SavePageSettings().

234 {
235  s_user_height = clampHeight( aHeightInMils );
236 }
static int clampHeight(int aHeightInMils)
static int s_user_height
void PAGE_INFO::SetCustomWidthMils ( int  aWidthInMils)
static

Function SetCustomWidthMils sets the width of Custom page in mils, for any custom page constructed or made via SetType() after making this call.

Definition at line 227 of file class_page_info.cpp.

References clampWidth(), and s_user_width.

Referenced by DIALOG_PAGES_SETTINGS::SavePageSettings().

228 {
229  s_user_width = clampWidth( aWidthInMils );
230 }
static int clampWidth(int aWidthInMils)
static int s_user_width
void PAGE_INFO::SetHeightMils ( int  aHeightInMils)

Definition at line 253 of file class_page_info.cpp.

References clampHeight(), Custom, m_paper_id, m_size, m_type, and updatePortrait().

Referenced by DIALOG_SVG_PRINT::CreateSVGFile(), SCH_LEGACY_PLUGIN::loadPageSettings(), SCH_EAGLE_PLUGIN::loadSheet(), LEGACY_PLUGIN::loadSHEET(), LIB_EDIT_FRAME::OnPlotCurrentComponent(), PCB_PARSER::parsePAGE_INFO(), DIALOG_PAGES_SETTINGS::SavePageSettings(), and DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample().

254 {
255  if( m_size.y != aHeightInMils )
256  {
257  m_size.y = clampHeight( aHeightInMils );
258 
259  m_type = Custom;
260  m_paper_id = wxPAPER_NONE;
261 
262  updatePortrait();
263  }
264 }
void updatePortrait()
wxSize m_size
mils
static const wxChar Custom[]
"User" defined page type
wxString m_type
paper type: A4, A3, etc.
static int clampHeight(int aHeightInMils)
wxPaperSize m_paper_id
wx' style paper id.
void PAGE_INFO::setMargins ( )
private
void PAGE_INFO::SetPortrait ( bool  isPortrait)

Function SetPortrait will rotate the paper page 90 degrees.

This PAGE_INFO may either be in portrait or landscape mode. Use this function to change from one to the other mode.

Parameters
isPortraitif true and not already in portrait mode, will change this PAGE_INFO to portrait mode. Or if false and not already in landscape mode, will change this PAGE_INFO to landscape mode.

Definition at line 182 of file class_page_info.cpp.

References m_portrait, and m_size.

Referenced by DIALOG_PLOT_SCHEMATIC::createPSFile(), SCH_LEGACY_PLUGIN::loadPageSettings(), LEGACY_PLUGIN::loadSHEET(), PCB_PARSER::parsePAGE_INFO(), DIALOG_PAGES_SETTINGS::SavePageSettings(), and DIALOG_PLOT_SCHEMATIC::setupPlotPagePDF().

183 {
184  if( m_portrait != isPortrait )
185  {
186  // swap x and y in m_size
187  m_size = wxSize( m_size.y, m_size.x );
188 
189  m_portrait = isPortrait;
190 
191  // margins are not touched, do that if you want
192  }
193 }
wxSize m_size
mils
bool m_portrait
true if portrait, false if landscape
bool PAGE_INFO::SetType ( const wxString &  aStandardPageDescriptionName,
bool  IsPortrait = false 
)

Function SetType sets the name of the page type and also the sizes and margins commonly associated with that type name.

Parameters
aStandardPageDescriptionNameis a wxString constant giving one of: "A4" "A3" "A2" "A1" "A0" "A" "B" "C" "D" "E" "GERBER", "USLetter", "USLegal", "USLedger", or "User". If "User" then the width and height are custom, and will be set according to previous calls to static PAGE_INFO::SetUserWidthMils() and static PAGE_INFO::SetUserHeightMils();
IsPortraitSet to true to set page orientation to portrait mode.
Returns
bool - true if aStandarePageDescription was a recognized type.

Definition at line 117 of file class_page_info.cpp.

References GetType(), m_size, pageA, pageA0, pageA1, pageA2, pageA3, pageA4, pageB, pageC, pageD, pageE, pageGERBER, pageUser, pageUSLedger, pageUSLegal, pageUSLetter, s_user_height, s_user_width, and updatePortrait().

Referenced by DIALOG_PLOT_SCHEMATIC::createHPGLFile(), DIALOG_PLOT_SCHEMATIC::createPSFile(), DIALOG_PAGES_SETTINGS::GetPageLayoutInfoFromDialog(), SCH_LEGACY_PLUGIN::loadPageSettings(), GERBVIEW_FRAME::LoadSettings(), LEGACY_PLUGIN::loadSHEET(), PAGE_INFO(), PCB_PARSER::parsePAGE_INFO(), DIALOG_PAGES_SETTINGS::SavePageSettings(), DIALOG_PLOT_SCHEMATIC::setupPlotPagePDF(), and DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample().

118 {
119  bool rc = true;
120 
121  // all are landscape initially
122  if( aType == pageA4.GetType() )
123  *this = pageA4;
124  else if( aType == pageA3.GetType() )
125  *this = pageA3;
126  else if( aType == pageA2.GetType() )
127  *this = pageA2;
128  else if( aType == pageA1.GetType() )
129  *this = pageA1;
130  else if( aType == pageA0.GetType() )
131  *this = pageA0;
132  else if( aType == pageA.GetType() )
133  *this = pageA;
134  else if( aType == pageB.GetType() )
135  *this = pageB;
136  else if( aType == pageC.GetType() )
137  *this = pageC;
138  else if( aType == pageD.GetType() )
139  *this = pageD;
140  else if( aType == pageE.GetType() )
141  *this = pageE;
142  else if( aType == pageGERBER.GetType() )
143  *this = pageGERBER;
144  else if( aType == pageUSLetter.GetType() )
145  *this = pageUSLetter;
146  else if( aType == pageUSLegal.GetType() )
147  *this = pageUSLegal;
148  else if( aType == pageUSLedger.GetType() )
149  *this = pageUSLedger;
150  else if( aType == pageUser.GetType() )
151  {
152  // pageUser is const, and may not and does not hold the custom size,
153  // so customize *this later
154  *this = pageUser;
155 
156  // customize:
157  m_size.x = s_user_width;
158  m_size.y = s_user_height;
159 
160  updatePortrait();
161  }
162  else
163  rc = false;
164 
165  if( IsPortrait )
166  {
167  // all private PAGE_INFOs are landscape, must swap x and y
168  m_size = wxSize( m_size.y, m_size.x );
169  updatePortrait();
170  }
171 
172  return rc;
173 }
static const PAGE_INFO pageA4
static const PAGE_INFO pageGERBER
void updatePortrait()
wxSize m_size
mils
static const PAGE_INFO pageA1
static const PAGE_INFO pageA2
static const PAGE_INFO pageUSLetter
static const PAGE_INFO pageC
static const PAGE_INFO pageUser
static const PAGE_INFO pageA
static const PAGE_INFO pageB
static const PAGE_INFO pageE
bool IsPortrait() const
static const PAGE_INFO pageUSLedger
static const PAGE_INFO pageUSLegal
static int s_user_height
const wxString & GetType() const
static int s_user_width
static const PAGE_INFO pageA3
static const PAGE_INFO pageA0
static const PAGE_INFO pageD
void PAGE_INFO::SetWidthMils ( int  aWidthInMils)

Definition at line 239 of file class_page_info.cpp.

References clampWidth(), Custom, m_paper_id, m_size, m_type, and updatePortrait().

Referenced by DIALOG_SVG_PRINT::CreateSVGFile(), SCH_LEGACY_PLUGIN::loadPageSettings(), SCH_EAGLE_PLUGIN::loadSheet(), LEGACY_PLUGIN::loadSHEET(), LIB_EDIT_FRAME::OnPlotCurrentComponent(), PCB_PARSER::parsePAGE_INFO(), DIALOG_PAGES_SETTINGS::SavePageSettings(), and DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample().

240 {
241  if( m_size.x != aWidthInMils )
242  {
243  m_size.x = clampWidth( aWidthInMils );
244 
245  m_type = Custom;
246  m_paper_id = wxPAPER_NONE;
247 
248  updatePortrait();
249  }
250 }
void updatePortrait()
wxSize m_size
mils
static const wxChar Custom[]
"User" defined page type
wxString m_type
paper type: A4, A3, etc.
static int clampWidth(int aWidthInMils)
wxPaperSize m_paper_id
wx' style paper id.
void PAGE_INFO::updatePortrait ( )
inlineprivate

Definition at line 93 of file class_page_info.cpp.

References m_portrait, and m_size.

Referenced by PAGE_INFO(), SetHeightMils(), SetType(), and SetWidthMils().

94 {
95  // update m_portrait based on orientation of m_size.x and m_size.y
96  m_portrait = ( m_size.y > m_size.x );
97 }
wxSize m_size
mils
bool m_portrait
true if portrait, false if landscape

Member Data Documentation

const wxChar PAGE_INFO::A = wxT( "A" )
static
const wxChar PAGE_INFO::A0 = wxT( "A0" )
static
const wxChar PAGE_INFO::A1 = wxT( "A1" )
static
const wxChar PAGE_INFO::A2 = wxT( "A2" )
static
const wxChar PAGE_INFO::A3 = wxT( "A3" )
static
const wxChar PAGE_INFO::B = wxT( "B" )
static
const wxChar PAGE_INFO::C = wxT( "C" )
static
const wxChar PAGE_INFO::D = wxT( "D" )
static
const wxChar PAGE_INFO::E = wxT( "E" )
static
const wxChar PAGE_INFO::GERBER = wxT( "GERBER" )
static

Definition at line 69 of file class_page_info.h.

Referenced by DIALOG_PAGES_SETTINGS::SavePageSettings().

wxPaperSize PAGE_INFO::m_paper_id
private

wx' style paper id.

Definition at line 227 of file class_page_info.h.

Referenced by GetPaperId(), SetHeightMils(), and SetWidthMils().

bool PAGE_INFO::m_portrait
private

true if portrait, false if landscape

Definition at line 225 of file class_page_info.h.

Referenced by IsDefault(), IsPortrait(), SetPortrait(), and updatePortrait().

wxSize PAGE_INFO::m_size
private
wxString PAGE_INFO::m_type
private

paper type: A4, A3, etc.

Definition at line 218 of file class_page_info.h.

Referenced by GetType(), IsCustom(), IsDefault(), SetHeightMils(), and SetWidthMils().

const PAGE_INFO PAGE_INFO::pageA
staticprivate

Definition at line 203 of file class_page_info.h.

Referenced by SetType().

const PAGE_INFO PAGE_INFO::pageA0
staticprivate

Definition at line 202 of file class_page_info.h.

Referenced by SetType().

const PAGE_INFO PAGE_INFO::pageA1
staticprivate

Definition at line 201 of file class_page_info.h.

Referenced by SetType().

const PAGE_INFO PAGE_INFO::pageA2
staticprivate

Definition at line 200 of file class_page_info.h.

Referenced by SetType().

const PAGE_INFO PAGE_INFO::pageA3
staticprivate

Definition at line 199 of file class_page_info.h.

Referenced by SetType().

const PAGE_INFO PAGE_INFO::pageA4
staticprivate

Definition at line 198 of file class_page_info.h.

Referenced by SetType().

const PAGE_INFO PAGE_INFO::pageB
staticprivate

Definition at line 204 of file class_page_info.h.

Referenced by SetType().

const PAGE_INFO PAGE_INFO::pageC
staticprivate

Definition at line 205 of file class_page_info.h.

Referenced by SetType().

const PAGE_INFO PAGE_INFO::pageD
staticprivate

Definition at line 206 of file class_page_info.h.

Referenced by SetType().

const PAGE_INFO PAGE_INFO::pageE
staticprivate

Definition at line 207 of file class_page_info.h.

Referenced by SetType().

const PAGE_INFO PAGE_INFO::pageGERBER
staticprivate

Definition at line 208 of file class_page_info.h.

Referenced by SetType().

const PAGE_INFO PAGE_INFO::pageUser
staticprivate

Definition at line 214 of file class_page_info.h.

Referenced by SetType().

const PAGE_INFO PAGE_INFO::pageUSLedger
staticprivate

Definition at line 212 of file class_page_info.h.

Referenced by SetType().

const PAGE_INFO PAGE_INFO::pageUSLegal
staticprivate

Definition at line 211 of file class_page_info.h.

Referenced by SetType().

const PAGE_INFO PAGE_INFO::pageUSLetter
staticprivate

Definition at line 210 of file class_page_info.h.

Referenced by SetType().

int PAGE_INFO::s_user_height = 11000
staticprivate

Definition at line 229 of file class_page_info.h.

Referenced by GetCustomHeightMils(), SetCustomHeightMils(), and SetType().

int PAGE_INFO::s_user_width = 17000
staticprivate

Definition at line 230 of file class_page_info.h.

Referenced by GetCustomWidthMils(), SetCustomWidthMils(), and SetType().

const wxChar PAGE_INFO::USLedger = wxT( "USLedger" )
static
const wxChar PAGE_INFO::USLegal = wxT( "USLegal" )
static
const wxChar PAGE_INFO::USLetter = wxT( "USLetter" )
static

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