diff --git a/eeschema/dialog_print_using_printer.cpp b/eeschema/dialog_print_using_printer.cpp index 41fa2fa82a..f2b5168052 100644 --- a/eeschema/dialog_print_using_printer.cpp +++ b/eeschema/dialog_print_using_printer.cpp @@ -2,8 +2,6 @@ /* File: dialog_print_using_printer.cpp */ /****************************************/ -// Set this to 1 if you want to test PostScript printing under MSW. -#define wxTEST_POSTSCRIPT_IN_MSW 1 #include "fctsys.h" #include "appl_wxstruct.h" #include "gr_basic.h" @@ -13,231 +11,185 @@ #include "program.h" #include "general.h" - -#include +#include "eeschema_config.h" #include "dialog_print_using_printer_base.h" -#define DEFAULT_ORIENTATION_PAPER wxLANDSCAPE // other option is wxPORTRAIT -#define WIDTH_MAX_VALUE 100 -#define WIDTH_MIN_VALUE 1 - -#define PRINTMODECOLOR_KEY wxT("PrintModeColor") - -// static print data and page setup data, to remember settings during the -// session -static wxPrintData* g_PrintData; - -// Variables locales -static int s_OptionPrintPage = 0; -static int s_Print_Black_and_White = true; -static bool s_Print_Frame_Ref = true; - - -/* Dialog to print schematic. Class derived from DIALOG_PRINT_USING_PRINTER_base - * created by wxFormBuilder +/** + * Print schematic dialog. + * + * Class derived from DIALOG_PRINT_USING_PRINTER_base created by wxFormBuilder */ -class DIALOG_PRINT_USING_PRINTER : public DIALOG_PRINT_USING_PRINTER_base +class DIALOG_PRINT_USING_PRINTER : public DIALOG_PRINT_USING_PRINTER_BASE { -private: - WinEDA_SchematicFrame* m_Parent; - wxConfig* m_Config; - static wxPoint s_LastPos; - static wxSize s_LastSize; - public: - DIALOG_PRINT_USING_PRINTER( WinEDA_SchematicFrame* parent ); + DIALOG_PRINT_USING_PRINTER( WinEDA_SchematicFrame* aParent ); ~DIALOG_PRINT_USING_PRINTER() {}; + WinEDA_SchematicFrame* GetParent() const; + private: void OnCloseWindow( wxCloseEvent& event ); void OnInitDialog( wxInitDialogEvent& event ); - void OnPrintSetup( wxCommandEvent& event ); + void OnPageSetup( wxCommandEvent& event ); void OnPrintPreview( wxCommandEvent& event ); void OnPrintButtonClick( wxCommandEvent& event ); void OnButtonCancelClick( wxCommandEvent& event ){ Close(); } - void SetPenWidth(); - - bool Show( bool show ); // overload stock function }; -class EDA_Printout : public wxPrintout +/** + * Custom print out for printing schematics. + */ +class SCH_PRINTOUT : public wxPrintout { -public: - bool m_Print_Sheet_Ref; +private: + DIALOG_PRINT_USING_PRINTER* m_Parent; public: - WinEDA_DrawFrame* m_Parent; - DIALOG_PRINT_USING_PRINTER* m_PrintFrame; - - EDA_Printout( DIALOG_PRINT_USING_PRINTER* aPrint_frame, - WinEDA_DrawFrame* aParent, - const wxString& aTitle, - bool aPrint_ref ) : + SCH_PRINTOUT( DIALOG_PRINT_USING_PRINTER* aParent, const wxString& aTitle ) : wxPrintout( aTitle ) { - m_PrintFrame = aPrint_frame; - m_Parent = aParent; - m_Print_Sheet_Ref = aPrint_ref; - } + wxASSERT( aParent != NULL ); + m_Parent = aParent; + } bool OnPrintPage( int page ); bool HasPage( int page ); bool OnBeginDocument( int startPage, int endPage ); - void GetPageInfo( int* minPage, int* maxPage, int* selPageFrom, - int* selPageTo ); - + void GetPageInfo( int* minPage, int* maxPage, int* selPageFrom, int* selPageTo ); void DrawPage(); }; -// We want our dialog to remember its previous screen position -wxPoint DIALOG_PRINT_USING_PRINTER::s_LastPos( -1, -1 ); -wxSize DIALOG_PRINT_USING_PRINTER::s_LastSize; - -/* Virtual function - * Calls the print dialog for Eeschema +/** + * Custom schematic print preview frame. */ -void WinEDA_SchematicFrame::ToPrinter( wxCommandEvent& event ) +class SCH_PREVIEW_FRAME : public wxPreviewFrame { - if( g_PrintData == NULL ) // First call. creates print handlers +public: + SCH_PREVIEW_FRAME( wxPrintPreview* aPreview, DIALOG_PRINT_USING_PRINTER* aParent, + const wxString& aTitle, const wxPoint& aPos = wxDefaultPosition, + const wxSize& aSize = wxDefaultSize ) : + wxPreviewFrame( aPreview, aParent, aTitle, aPos, aSize ) { - g_PrintData = new wxPrintData(); - - if( !g_PrintData->Ok() ) - { - DisplayError( this, - _( "Error initializing printer information." ) ); - } - g_PrintData->SetQuality( wxPRINT_QUALITY_HIGH ); - g_PrintData->SetOrientation( DEFAULT_ORIENTATION_PAPER ); } - DIALOG_PRINT_USING_PRINTER* frame = new DIALOG_PRINT_USING_PRINTER( this ); + DIALOG_PRINT_USING_PRINTER* GetParent() + { + return ( DIALOG_PRINT_USING_PRINTER* )wxWindow::GetParent(); + } - frame->ShowModal(); - frame->Destroy(); + void OnCloseWindow( wxCloseEvent& event ) + { + if( !IsIconized() ) + { + GetParent()->GetParent()->SetPreviewPosition( GetPosition() ); + GetParent()->GetParent()->SetPreviewSize( GetSize() ); + } + + wxPreviewFrame::OnCloseWindow( event ); + } + +private: + DECLARE_CLASS( SCH_PREVIEW_FRAME ) + DECLARE_EVENT_TABLE() + DECLARE_NO_COPY_CLASS( SCH_PREVIEW_FRAME ) +}; + + +IMPLEMENT_CLASS( SCH_PREVIEW_FRAME, wxPreviewFrame ) + +BEGIN_EVENT_TABLE( SCH_PREVIEW_FRAME, wxPreviewFrame ) + EVT_CLOSE( SCH_PREVIEW_FRAME::OnCloseWindow ) +END_EVENT_TABLE() + + +void WinEDA_SchematicFrame::OnPrint( wxCommandEvent& event ) +{ + wxFileName fn; + DIALOG_PRINT_USING_PRINTER dlg( this ); + + dlg.ShowModal(); + + fn = g_RootSheet->m_AssociatedScreen->m_FileName; + + if( fn.GetFullName() != wxT( "noname.sch" ) ) + { + fn.SetExt( ProjectFileExtension ); + wxGetApp().WriteProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters() ); + } } -DIALOG_PRINT_USING_PRINTER::DIALOG_PRINT_USING_PRINTER( WinEDA_SchematicFrame* parent ) : - DIALOG_PRINT_USING_PRINTER_base( parent ) +DIALOG_PRINT_USING_PRINTER::DIALOG_PRINT_USING_PRINTER( WinEDA_SchematicFrame* aParent ) : + DIALOG_PRINT_USING_PRINTER_BASE( aParent ) { - m_Parent = parent; - m_Config = wxGetApp().m_EDA_Config; + wxASSERT( aParent != NULL ); + + m_checkReference->SetValue( aParent->GetShowSheetReference() ); + m_checkMonochrome->SetValue( aParent->GetPrintMonochrome() ); +} + + +WinEDA_SchematicFrame* DIALOG_PRINT_USING_PRINTER::GetParent() const +{ + return ( WinEDA_SchematicFrame* ) wxWindow::GetParent(); } void DIALOG_PRINT_USING_PRINTER::OnInitDialog( wxInitDialogEvent& event ) { - SetFocus(); - - if( m_Config ) - { - m_Config->Read( PRINTMODECOLOR_KEY, &s_Print_Black_and_White ); - } - - AddUnitSymbol( *m_TextPenWidth, g_DrawDefaultLineThickness ); - m_DialogPenWidth->SetValue( - ReturnStringFromValue( g_UnitMetric, g_DrawDefaultLineThickness, - m_Parent->m_InternalUnits ) ); - m_Print_Sheet_Ref->SetValue( s_Print_Frame_Ref ); - - m_ModeColorOption->SetSelection( s_Print_Black_and_White ? 1 : 0 ); - m_Print_Sheet_Ref->SetValue( s_Print_Frame_Ref ); + WinEDA_SchematicFrame* parent = GetParent(); if ( GetSizer() ) - { - GetSizer()->SetSizeHints(this); - } -} + GetSizer()->SetSizeHints( this ); -/*************************************************/ -bool DIALOG_PRINT_USING_PRINTER::Show( bool show ) -/*************************************************/ -{ - bool ret; - - if( show ) + if( parent->GetPrintDialogPosition() == wxDefaultPosition && + parent->GetPrintDialogSize() == wxDefaultSize ) { - if( s_LastPos.x != -1 ) - { - SetSize( s_LastPos.x, s_LastPos.y, s_LastSize.x, s_LastSize.y, 0 ); - } - ret = DIALOG_PRINT_USING_PRINTER_base::Show( show ); + Center(); } else { - // Save the dialog's position before hiding - s_LastPos = GetPosition(); - s_LastSize = GetSize(); - - ret = DIALOG_PRINT_USING_PRINTER_base::Show( show ); + SetPosition( parent->GetPrintDialogPosition() ); + SetSize( parent->GetPrintDialogSize() ); } - return ret; + SetFocus(); } + void DIALOG_PRINT_USING_PRINTER::OnCloseWindow( wxCloseEvent& event ) { - s_Print_Black_and_White = m_ModeColorOption->GetSelection(); - s_Print_Frame_Ref = m_Print_Sheet_Ref->GetValue(); - SetPenWidth(); + WinEDA_SchematicFrame* parent = GetParent(); - if( m_Config ) + if( !IsIconized() ) { - m_Config->Write( PRINTMODECOLOR_KEY, s_Print_Black_and_White ); + parent->SetPrintDialogPosition( GetPosition() ); + parent->SetPrintDialogSize( GetSize() ); } - EndModal( 0 ); -} + parent->SetPrintMonochrome( m_checkMonochrome->IsChecked() ); + parent->SetShowSheetReference( m_checkReference->IsChecked() ); - -/* Get the new pen width value, and verify min et max value - * NOTE: g_PlotLine_Width is in internal units - */ -void DIALOG_PRINT_USING_PRINTER::SetPenWidth() -{ - g_DrawDefaultLineThickness = - ReturnValueFromTextCtrl( *m_DialogPenWidth, m_Parent->m_InternalUnits ); - - if( g_DrawDefaultLineThickness > WIDTH_MAX_VALUE ) - { - g_DrawDefaultLineThickness = WIDTH_MAX_VALUE; - } - - if( g_DrawDefaultLineThickness < WIDTH_MIN_VALUE ) - { - g_DrawDefaultLineThickness = WIDTH_MIN_VALUE; - } - - m_DialogPenWidth->SetValue( - ReturnStringFromValue( g_UnitMetric, g_DrawDefaultLineThickness, - m_Parent->m_InternalUnits ) ); + EndDialog( wxID_CANCEL ); } /* Open a dialog box for printer setup (printer options, page size ...) */ -void DIALOG_PRINT_USING_PRINTER::OnPrintSetup( wxCommandEvent& event ) +void DIALOG_PRINT_USING_PRINTER::OnPageSetup( wxCommandEvent& event ) { - wxPrintDialogData printDialogData( *g_PrintData ); + WinEDA_SchematicFrame* parent = GetParent(); - if( printDialogData.Ok() ) - { - wxPrintDialog printerDialog( this, &printDialogData ); + wxPageSetupDialog pageSetupDialog( this, &parent->GetPageSetupData() ); - printerDialog.ShowModal(); + pageSetupDialog.ShowModal(); - *g_PrintData = printerDialog.GetPrintDialogData().GetPrintData(); - } - else - { - DisplayError( this, _( "Printer error!" ) ); - } + parent->GetPageSetupData() = pageSetupDialog.GetPageSetupDialogData(); } @@ -245,21 +197,16 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintSetup( wxCommandEvent& event ) */ void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event ) { - wxSize WSize; - wxPoint WPos; - bool print_ref = m_Print_Sheet_Ref->GetValue(); + WinEDA_SchematicFrame* parent = GetParent(); - s_Print_Black_and_White = m_ModeColorOption->GetSelection(); - SetPenWidth(); - - s_OptionPrintPage = m_PagesOption->GetSelection(); + parent->SetPrintMonochrome( m_checkMonochrome->IsChecked() ); + parent->SetShowSheetReference( m_checkReference->IsChecked() ); // Pass two printout objects: for preview, and possible printing. - wxString title = _("Preview"); - wxPrintPreview* preview = - new wxPrintPreview( new EDA_Printout( this, m_Parent, title, print_ref ), - new EDA_Printout( this, m_Parent, title, print_ref ), - g_PrintData ); + wxString title = _( "Preview" ); + wxPrintPreview* preview = new wxPrintPreview( new SCH_PRINTOUT( this, title ), + new SCH_PRINTOUT( this, title ), + &parent->GetPageSetupData().GetPrintData() ); if( preview == NULL ) { @@ -267,12 +214,11 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event ) return; } - WPos = m_Parent->GetPosition( ); - WSize = m_Parent->GetSize(); - - wxPreviewFrame* frame = new wxPreviewFrame( preview, this, - title, WPos, WSize ); + preview->SetZoom( 100 ); + SCH_PREVIEW_FRAME* frame = new SCH_PREVIEW_FRAME( preview, this, title, + parent->GetPreviewPosition(), + parent->GetPreviewSize() ); frame->Initialize(); frame->Show( true ); } @@ -280,107 +226,83 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event ) void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event ) { - bool print_ref = m_Print_Sheet_Ref->GetValue(); + WinEDA_SchematicFrame* parent = GetParent(); - s_Print_Black_and_White = m_ModeColorOption->GetSelection(); + parent->SetPrintMonochrome( m_checkMonochrome->IsChecked() ); + parent->SetShowSheetReference( m_checkReference->IsChecked() ); - s_OptionPrintPage = 0; - if( m_PagesOption ) - s_OptionPrintPage = m_PagesOption->GetSelection(); + wxPrintDialogData printDialogData( parent->GetPageSetupData().GetPrintData() ); + printDialogData.SetMaxPage( g_RootSheet->CountSheets() ); - SetPenWidth(); + if( g_RootSheet->CountSheets() > 1 ) + printDialogData.EnablePageNumbers( true ); - wxPrintDialogData printDialogData( *g_PrintData ); - - wxPrinter printer( &printDialogData ); - - wxString title = _("Preview"); - EDA_Printout printout( this, m_Parent, title, print_ref ); - -#if !defined(__WINDOWS__) && !wxCHECK_VERSION(2,9,0) - wxDC* dc = printout.GetDC(); - ( (wxPostScriptDC*) dc )->SetResolution( 600 ); -#endif + wxPrinter printer( &printDialogData ); + SCH_PRINTOUT printout( this, _( "Print Schematic" ) ); if( !printer.Print( this, &printout, true ) ) { if( wxPrinter::GetLastError() == wxPRINTER_ERROR ) - DisplayError( this, _( "There was a problem printing." ) ); - return; + wxMessageBox( _( "An error occurred attempting to print the schematic." ), + _( "Printing" ), wxOK ); } else { - *g_PrintData = printer.GetPrintDialogData().GetPrintData(); + parent->GetPageSetupData() = printer.GetPrintDialogData().GetPrintData(); } } -bool EDA_Printout::OnPrintPage( int page ) +bool SCH_PRINTOUT::OnPrintPage( int page ) { wxString msg; - + WinEDA_SchematicFrame* parent = m_Parent->GetParent(); msg.Printf( _( "Print page %d" ), page ); - m_Parent->AppendMsgPanel( msg, wxEmptyString, CYAN ); + parent->ClearMsgPanel(); + parent->AppendMsgPanel( msg, wxEmptyString, CYAN ); - WinEDA_SchematicFrame* schframe = (WinEDA_SchematicFrame*) m_Parent; - SCH_SCREEN* screen = schframe->GetScreen(); - SCH_SCREEN* oldscreen = screen; - SCH_SHEET_PATH* oldsheetpath = schframe->GetSheet(); + SCH_SCREEN* screen = parent->GetScreen(); + SCH_SCREEN* oldscreen = screen; + SCH_SHEET_PATH* oldsheetpath = parent->GetSheet(); + SCH_SHEET_PATH list; + SCH_SHEET_LIST SheetList( NULL ); + SCH_SHEET_PATH* sheetpath = SheetList.GetSheet( page - 1 ); - - SCH_SHEET_PATH list; - if( s_OptionPrintPage == 1 ) + if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) ) { - /* Print all pages, so when called, the page is not the current page. - * We must select it and setup references and others parameters - * because in complex hierarchies a SCH_SCREEN (a schematic drawings) - * is shared between many sheets - */ - SCH_SHEET_LIST SheetList( NULL ); - SCH_SHEET_PATH* sheetpath = SheetList.GetSheet( page - 1 ); - if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) ) - { - schframe->m_CurrentSheet = &list; - schframe->m_CurrentSheet->UpdateAllScreenReferences(); - schframe->SetSheetNumberAndCount(); - screen = schframe->m_CurrentSheet->LastScreen(); - } - else - screen = NULL; + parent->m_CurrentSheet = &list; + parent->m_CurrentSheet->UpdateAllScreenReferences(); + parent->SetSheetNumberAndCount(); + screen = parent->m_CurrentSheet->LastScreen(); + } + else + { + screen = NULL; } if( screen == NULL ) return false; + ActiveScreen = screen; DrawPage(); ActiveScreen = oldscreen; - schframe->m_CurrentSheet = oldsheetpath; - schframe->m_CurrentSheet->UpdateAllScreenReferences(); - schframe->SetSheetNumberAndCount(); + parent->m_CurrentSheet = oldsheetpath; + parent->m_CurrentSheet->UpdateAllScreenReferences(); + parent->SetSheetNumberAndCount(); return true; } -void EDA_Printout::GetPageInfo( int* minPage, int* maxPage, +void SCH_PRINTOUT::GetPageInfo( int* minPage, int* maxPage, int* selPageFrom, int* selPageTo ) { - int ii = 1; - - *minPage = 1; - *selPageFrom = 1; - - if( s_OptionPrintPage == 1 ) - { - ii = g_RootSheet->CountSheets(); - } - - *maxPage = ii; - *selPageTo = ii; + *minPage = *selPageFrom = 1; + *maxPage = *selPageTo = g_RootSheet->CountSheets(); } -bool EDA_Printout::HasPage( int pageNum ) +bool SCH_PRINTOUT::HasPage( int pageNum ) { int pageCount; @@ -392,11 +314,24 @@ bool EDA_Printout::HasPage( int pageNum ) } -bool EDA_Printout::OnBeginDocument( int startPage, int endPage ) +bool SCH_PRINTOUT::OnBeginDocument( int startPage, int endPage ) { if( !wxPrintout::OnBeginDocument( startPage, endPage ) ) return false; + WinEDA_SchematicFrame* parent = m_Parent->GetParent(); + wxLogDebug( wxT( "Printer name: " ) + + parent->GetPageSetupData().GetPrintData().GetPrinterName() ); + wxLogDebug( wxT( "Paper ID: %d" ), + parent->GetPageSetupData().GetPrintData().GetPaperId() ); + wxLogDebug( wxT( "Color: %d" ), + (int) parent->GetPageSetupData().GetPrintData().GetColour() ); + wxLogDebug( wxT( "Monochrome: %d" ), parent->GetPrintMonochrome() ); + wxLogDebug( wxT( "Orientation: %d:" ), + parent->GetPageSetupData().GetPrintData().GetOrientation() ); + wxLogDebug( wxT( "Quality: %d"), + parent->GetPageSetupData().GetPrintData().GetQuality() ); + return true; } @@ -404,77 +339,80 @@ bool EDA_Printout::OnBeginDocument( int startPage, int endPage ) /* * This is the real print function: print the active screen */ -void EDA_Printout::DrawPage() +void SCH_PRINTOUT::DrawPage() { - int tmpzoom; - wxPoint tmp_startvisu; - wxSize PageSize_in_mm; - wxSize SheetSize; // Page size in internal units - wxSize PlotAreaSize; // plot area size in pixels - double scaleX, scaleY, scale; - wxPoint old_org; - wxPoint DrawOffset; - double DrawZoom = 1; - wxDC* dc = GetDC(); + int oldZoom; + wxPoint tmp_startvisu; + wxSize SheetSize; // Page size in internal units + wxPoint old_org; + EDA_Rect oldClipBox; + wxRect fitRect; + wxDC* dc = GetDC(); + WinEDA_SchematicFrame* parent = m_Parent->GetParent(); + WinEDA_DrawPanel* panel = parent->DrawPanel; wxBusyCursor dummy; - GetPageSizeMM( &PageSize_in_mm.x, &PageSize_in_mm.y ); - - /* Save old draw scale and draw offset */ + /* Save current scale factor, offsets, and clip box. */ tmp_startvisu = ActiveScreen->m_StartVisu; - tmpzoom = ActiveScreen->GetZoom(); + oldZoom = ActiveScreen->GetZoom(); old_org = ActiveScreen->m_DrawOrg; - /* Change draw scale and offset to draw the whole page */ - ActiveScreen->SetScalingFactor( DrawZoom ); + oldClipBox = panel->m_ClipBox; + + /* Change scale factor, offsets, and clip box to print the whole page. */ + ActiveScreen->SetScalingFactor( 1.0 ); ActiveScreen->m_DrawOrg.x = ActiveScreen->m_DrawOrg.y = 0; ActiveScreen->m_StartVisu.x = ActiveScreen->m_StartVisu.y = 0; - - SheetSize = ActiveScreen->m_CurrentSheetDesc->m_Size; // size in 1/1000 inch - SheetSize.x *= m_Parent->m_InternalUnits / 1000; - SheetSize.y *= m_Parent->m_InternalUnits / 1000; // size in pixels - - // Get the size of the DC in pixels - dc->GetSize( &PlotAreaSize.x, &PlotAreaSize.y ); - - // Calculate a suitable scaling factor - scaleX = (double) SheetSize.x / PlotAreaSize.x; - scaleY = (double) SheetSize.y / PlotAreaSize.y; - scale = wxMax( scaleX, scaleY ); // Use x or y scaling factor, whichever - // fits on the DC - - // adjust the real draw scale - dc->SetUserScale( DrawZoom / scale, DrawZoom / scale ); - - ActiveScreen->m_DrawOrg = DrawOffset; - - GRResetPenAndBrush( dc ); - if( s_Print_Black_and_White ) - GRForceBlackPen( true ); - - /* set Pen min width (not used now) */ - SetPenMinWidth( 1 ); - - WinEDA_DrawPanel* panel = m_Parent->DrawPanel; - BASE_SCREEN* screen = panel->GetScreen(); - EDA_Rect tmp = panel->m_ClipBox; - panel->m_ClipBox.SetOrigin( wxPoint( 0, 0 ) ); panel->m_ClipBox.SetSize( wxSize( 0x7FFFFF0, 0x7FFFFF0 ) ); - screen->m_IsPrinting = true; + bool printReference = parent->GetShowSheetReference(); + + if( printReference ) + { + /* Draw the page to a memory and let the dc calculate the drawing + * limits. + */ + wxBitmap psuedoBitmap( 1, 1 ); + wxMemoryDC memDC; + memDC.SelectObject( psuedoBitmap ); + panel->PrintPage( &memDC, true, 0xFFFFFFFF, false, NULL ); + wxLogDebug( wxT( "MinX = %d, MaxX = %d, MinY = %d, MaxY = %d" ), + memDC.MinX(), memDC.MaxX(), memDC.MinY(), memDC.MaxY() ); + + SheetSize.x = memDC.MaxX() - memDC.MinX(); + SheetSize.y = memDC.MaxY() - memDC.MinY(); + + FitThisSizeToPageMargins( SheetSize, parent->GetPageSetupData() ); + fitRect = GetLogicalPageMarginsRect( parent->GetPageSetupData() ); + } + else + { + SheetSize = ActiveScreen->m_CurrentSheetDesc->m_Size; + FitThisSizeToPaper( SheetSize ); + fitRect = GetLogicalPaperRect(); + } + + wxLogDebug( wxT( "Fit rectangle: %d, %d, %d, %d" ), + fitRect.x, fitRect.y, fitRect.width, fitRect.height ); + + GRResetPenAndBrush( dc ); + + if( parent->GetPrintMonochrome() ) + GRForceBlackPen( true ); + + ActiveScreen->m_IsPrinting = true; int bg_color = g_DrawBgColor; - panel->PrintPage( dc, m_Print_Sheet_Ref, 0xFFFFFFFF, false, NULL ); + panel->PrintPage( dc, printReference, 0xFFFFFFFF, false, NULL ); - g_DrawBgColor = bg_color; - screen->m_IsPrinting = false; - panel->m_ClipBox = tmp; + g_DrawBgColor = bg_color; + ActiveScreen->m_IsPrinting = false; + panel->m_ClipBox = oldClipBox; - SetPenMinWidth( 1 ); GRForceBlackPen( false ); ActiveScreen->m_StartVisu = tmp_startvisu; ActiveScreen->m_DrawOrg = old_org; - ActiveScreen->SetZoom( tmpzoom ); + ActiveScreen->SetZoom( oldZoom ); } diff --git a/eeschema/dialog_print_using_printer_base.cpp b/eeschema/dialog_print_using_printer_base.cpp index 9381cc809a..c82aa00310 100644 --- a/eeschema/dialog_print_using_printer_base.cpp +++ b/eeschema/dialog_print_using_printer_base.cpp @@ -9,7 +9,7 @@ /////////////////////////////////////////////////////////////////////////// -DIALOG_PRINT_USING_PRINTER_base::DIALOG_PRINT_USING_PRINTER_base( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) +DIALOG_PRINT_USING_PRINTER_BASE::DIALOG_PRINT_USING_PRINTER_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) { this->SetSizeHints( wxSize( -1,-1 ), wxDefaultSize ); @@ -19,80 +19,56 @@ DIALOG_PRINT_USING_PRINTER_base::DIALOG_PRINT_USING_PRINTER_base( wxWindow* pare wxBoxSizer* bleftSizer; bleftSizer = new wxBoxSizer( wxVERTICAL ); - wxStaticBoxSizer* sbOptionsSizer; - sbOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Options:") ), wxVERTICAL ); + m_checkReference = new wxCheckBox( this, wxID_ANY, _("Print sheet &reference and title block"), wxDefaultPosition, wxDefaultSize, 0 ); + m_checkReference->SetValue(true); - m_TextPenWidth = new wxStaticText( this, wxID_ANY, _("Default Pen Size"), wxDefaultPosition, wxDefaultSize, 0 ); - m_TextPenWidth->Wrap( -1 ); - sbOptionsSizer->Add( m_TextPenWidth, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + m_checkReference->SetToolTip( _("Print (or not) the Frame references.") ); - m_DialogPenWidth = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_DialogPenWidth->SetToolTip( _("Selection of the default pen thickness used to draw items, when their thickness is set to 0.") ); - m_DialogPenWidth->SetMinSize( wxSize( 200,-1 ) ); + bleftSizer->Add( m_checkReference, 0, wxALL, 5 ); - sbOptionsSizer->Add( m_DialogPenWidth, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + m_checkMonochrome = new wxCheckBox( this, wxID_ANY, _("Print in &black and white only"), wxDefaultPosition, wxDefaultSize, 0 ); - m_Print_Sheet_Ref = new wxCheckBox( this, wxID_FRAME_SEL, _("Print frame ref"), wxDefaultPosition, wxDefaultSize, 0 ); - m_Print_Sheet_Ref->SetValue(true); + bleftSizer->Add( m_checkMonochrome, 0, wxALL, 5 ); - m_Print_Sheet_Ref->SetToolTip( _("Print (or not) the Frame references.") ); - - sbOptionsSizer->Add( m_Print_Sheet_Ref, 0, wxALL, 5 ); - - bleftSizer->Add( sbOptionsSizer, 1, wxEXPAND|wxALL, 5 ); - - wxString m_ModeColorOptionChoices[] = { _("Color"), _("Black and white") }; - int m_ModeColorOptionNChoices = sizeof( m_ModeColorOptionChoices ) / sizeof( wxString ); - m_ModeColorOption = new wxRadioBox( this, wxID_PRINT_MODE, _("Print Mode"), wxDefaultPosition, wxDefaultSize, m_ModeColorOptionNChoices, m_ModeColorOptionChoices, 1, wxRA_SPECIFY_COLS ); - m_ModeColorOption->SetSelection( 1 ); - m_ModeColorOption->SetToolTip( _("Choose if you wand to draw the sheet like it appears on screen,\nor in black and white mode, better to print it when using black and white printers") ); - - bleftSizer->Add( m_ModeColorOption, 0, wxALL|wxEXPAND, 5 ); - - wxString m_PagesOptionChoices[] = { _("Current"), _("All") }; - int m_PagesOptionNChoices = sizeof( m_PagesOptionChoices ) / sizeof( wxString ); - m_PagesOption = new wxRadioBox( this, wxID_PAGE_MODE, _("Page Print"), wxDefaultPosition, wxDefaultSize, m_PagesOptionNChoices, m_PagesOptionChoices, 1, wxRA_SPECIFY_COLS ); - m_PagesOption->SetSelection( 0 ); - bleftSizer->Add( m_PagesOption, 0, wxALL|wxEXPAND, 5 ); - - bMainSizer->Add( bleftSizer, 1, wxEXPAND, 5 ); + bMainSizer->Add( bleftSizer, 1, wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 12 ); wxBoxSizer* bbuttonsSizer; bbuttonsSizer = new wxBoxSizer( wxVERTICAL ); - m_buttonOption = new wxButton( this, wxID_PRINT_OPTIONS, _("Page Options"), wxDefaultPosition, wxDefaultSize, 0 ); - bbuttonsSizer->Add( m_buttonOption, 0, wxALL, 5 ); + m_buttonPageSetup = new wxButton( this, wxID_ANY, _("Page Setup"), wxDefaultPosition, wxDefaultSize, 0 ); + bbuttonsSizer->Add( m_buttonPageSetup, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 ); - m_buttonPreview = new wxButton( this, wxID_PREVIEW, _("Preview"), wxDefaultPosition, wxDefaultSize, 0 ); + m_buttonPreview = new wxButton( this, wxID_ANY, _("Preview"), wxDefaultPosition, wxDefaultSize, 0 ); bbuttonsSizer->Add( m_buttonPreview, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); - m_buttonPrint = new wxButton( this, wxID_PRINT_ALL, _("Print"), wxDefaultPosition, wxDefaultSize, 0 ); + m_buttonPrint = new wxButton( this, wxID_ANY, _("Print"), wxDefaultPosition, wxDefaultSize, 0 ); bbuttonsSizer->Add( m_buttonPrint, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); m_buttonQuit = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 ); bbuttonsSizer->Add( m_buttonQuit, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); - bMainSizer->Add( bbuttonsSizer, 0, wxALIGN_CENTER_VERTICAL, 5 ); + bMainSizer->Add( bbuttonsSizer, 0, wxALL, 12 ); this->SetSizer( bMainSizer ); this->Layout(); + bMainSizer->Fit( this ); // Connect Events - this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnCloseWindow ) ); - this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnInitDialog ) ); - m_buttonOption->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPrintSetup ), NULL, this ); - m_buttonPreview->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPrintPreview ), NULL, this ); - m_buttonPrint->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPrintButtonClick ), NULL, this ); - m_buttonQuit->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnButtonCancelClick ), NULL, this ); + this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnCloseWindow ) ); + this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnInitDialog ) ); + m_buttonPageSetup->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPageSetup ), NULL, this ); + m_buttonPreview->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPrintPreview ), NULL, this ); + m_buttonPrint->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPrintButtonClick ), NULL, this ); + m_buttonQuit->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnButtonCancelClick ), NULL, this ); } -DIALOG_PRINT_USING_PRINTER_base::~DIALOG_PRINT_USING_PRINTER_base() +DIALOG_PRINT_USING_PRINTER_BASE::~DIALOG_PRINT_USING_PRINTER_BASE() { // Disconnect Events - this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnCloseWindow ) ); - this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnInitDialog ) ); - m_buttonOption->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPrintSetup ), NULL, this ); - m_buttonPreview->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPrintPreview ), NULL, this ); - m_buttonPrint->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPrintButtonClick ), NULL, this ); - m_buttonQuit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnButtonCancelClick ), NULL, this ); + this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnCloseWindow ) ); + this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnInitDialog ) ); + m_buttonPageSetup->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPageSetup ), NULL, this ); + m_buttonPreview->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPrintPreview ), NULL, this ); + m_buttonPrint->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPrintButtonClick ), NULL, this ); + m_buttonQuit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnButtonCancelClick ), NULL, this ); } diff --git a/eeschema/dialog_print_using_printer_base.fbp b/eeschema/dialog_print_using_printer_base.fbp index 42c8745619..5eab5f393b 100644 --- a/eeschema/dialog_print_using_printer_base.fbp +++ b/eeschema/dialog_print_using_printer_base.fbp @@ -11,7 +11,7 @@ 1000 none 1 - DialogSVGPrint_base + dialog_print_schematic . @@ -30,9 +30,9 @@ wxID_ANY -1,-1 - DIALOG_PRINT_USING_PRINTER_base + DIALOG_PRINT_USING_PRINTER_BASE - 336,268 + -1,-1 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER Print @@ -76,8 +76,8 @@ wxHORIZONTAL none - 5 - wxEXPAND + 12 + wxBOTTOM|wxEXPAND|wxLEFT|wxTOP 1 @@ -86,205 +86,32 @@ none 5 - wxEXPAND|wxALL - 1 - - wxID_ANY - Options: - - sbOptionsSizer - wxVERTICAL - none - - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - - - 1 - - - 0 - wxID_ANY - Default Pen Size - - - m_TextPenWidth - protected - - - - - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND - 0 - - - - 1 - - - 0 - wxID_ANY - - 0 - 200,-1 - m_DialogPenWidth - protected - - - - - Selection of the default pen thickness used to draw items, when their thickness is set to 0. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - - 1 - - 1 - - - 0 - wxID_FRAME_SEL - Print frame ref - - - m_Print_Sheet_Ref - protected - - - - - Print (or not) the Frame references. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND + wxALL 0 - + - "Color" "Black and white" + 1 1 0 - wxID_PRINT_MODE - Print Mode - 1 + wxID_ANY + Print sheet &reference and title block - m_ModeColorOption + m_checkReference protected - 1 - wxRA_SPECIFY_COLS + - Choose if you wand to draw the sheet like it appears on screen, or in black and white mode, better to print it when using black and white printers + Print (or not) the Frame references. + @@ -301,7 +128,6 @@ - @@ -312,33 +138,32 @@ 5 - wxALL|wxEXPAND + wxALL 0 - + - "Current" "All" + 0 1 0 - wxID_PAGE_MODE - Page Print - 1 + wxID_ANY + Print in &black and white only - m_PagesOption + m_checkMonochrome protected - 0 - wxRA_SPECIFY_COLS + + @@ -355,7 +180,6 @@ - @@ -367,8 +191,8 @@ - 5 - wxALIGN_CENTER_VERTICAL + 12 + wxALL 0 @@ -377,7 +201,7 @@ none 5 - wxALL + wxALIGN_CENTER_HORIZONTAL|wxALL 0 @@ -387,11 +211,11 @@ 0 - wxID_PRINT_OPTIONS - Page Options + wxID_ANY + Page Setup - m_buttonOption + m_buttonPageSetup protected @@ -401,7 +225,7 @@ - OnPrintSetup + OnPageSetup @@ -439,7 +263,7 @@ 0 - wxID_PREVIEW + wxID_ANY Preview @@ -491,7 +315,7 @@ 0 - wxID_PRINT_ALL + wxID_ANY Print diff --git a/eeschema/dialog_print_using_printer_base.h b/eeschema/dialog_print_using_printer_base.h index 5c0267ffd5..ba4150fbb3 100644 --- a/eeschema/dialog_print_using_printer_base.h +++ b/eeschema/dialog_print_using_printer_base.h @@ -11,44 +11,28 @@ #include #include -#include +#include #include #include #include #include -#include -#include #include -#include -#include #include #include /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_PRINT_USING_PRINTER_base +/// Class DIALOG_PRINT_USING_PRINTER_BASE /////////////////////////////////////////////////////////////////////////////// -class DIALOG_PRINT_USING_PRINTER_base : public wxDialog +class DIALOG_PRINT_USING_PRINTER_BASE : public wxDialog { private: protected: - enum - { - wxID_FRAME_SEL = 1000, - wxID_PRINT_MODE, - wxID_PAGE_MODE, - wxID_PRINT_OPTIONS, - wxID_PRINT_ALL, - }; - - wxStaticText* m_TextPenWidth; - wxTextCtrl* m_DialogPenWidth; - wxCheckBox* m_Print_Sheet_Ref; - wxRadioBox* m_ModeColorOption; - wxRadioBox* m_PagesOption; - wxButton* m_buttonOption; + wxCheckBox* m_checkReference; + wxCheckBox* m_checkMonochrome; + wxButton* m_buttonPageSetup; wxButton* m_buttonPreview; wxButton* m_buttonPrint; wxButton* m_buttonQuit; @@ -56,15 +40,15 @@ class DIALOG_PRINT_USING_PRINTER_base : public wxDialog // Virtual event handlers, overide them in your derived class virtual void OnCloseWindow( wxCloseEvent& event ){ event.Skip(); } virtual void OnInitDialog( wxInitDialogEvent& event ){ event.Skip(); } - virtual void OnPrintSetup( wxCommandEvent& event ){ event.Skip(); } + virtual void OnPageSetup( wxCommandEvent& event ){ event.Skip(); } virtual void OnPrintPreview( wxCommandEvent& event ){ event.Skip(); } virtual void OnPrintButtonClick( wxCommandEvent& event ){ event.Skip(); } virtual void OnButtonCancelClick( wxCommandEvent& event ){ event.Skip(); } public: - DIALOG_PRINT_USING_PRINTER_base( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Print"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 336,268 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); - ~DIALOG_PRINT_USING_PRINTER_base(); + DIALOG_PRINT_USING_PRINTER_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Print"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~DIALOG_PRINT_USING_PRINTER_BASE(); }; diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 2ac6a8426a..f35bcd9c14 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -261,6 +261,10 @@ PARAM_CFG_ARRAY& WinEDA_SchematicFrame::GetProjectFileParameters( void ) &g_DefaultTextLabelSize, DEFAULT_SIZE_TEXT, 0, 1000 ) ); + m_projectFileParams.push_back( new PARAM_CFG_BOOL( wxT( "PrintMonochrome" ), + &m_printMonochrome, true ) ); + m_projectFileParams.push_back( new PARAM_CFG_BOOL( wxT( "ShowSheetReferenceAndTitleBlock" ), + &m_showSheetReference, true ) ); return m_projectFileParams; } @@ -280,6 +284,7 @@ bool WinEDA_SchematicFrame::LoadProjectFile( const wxString& CfgFileName, fn = g_RootSheet->m_AssociatedScreen->m_FileName; else fn = CfgFileName; + m_ComponentLibFiles.Clear(); /* Change the schematic file extension (.sch) to the project file @@ -339,6 +344,14 @@ void WinEDA_SchematicFrame::SaveProjectFile( wxWindow* displayframe, bool askove static const wxString DefaultDrawLineWidthEntry( wxT( "DefaultDrawLineWidth" ) ); static const wxString ShowHiddenPinsEntry( wxT( "ShowHiddenPins" ) ); static const wxString HorzVertLinesOnlyEntry( wxT( "HorizVertLinesOnly" ) ); +static const wxString PreviewFramePositionXEntry( wxT( "PreviewFramePositionX" ) ); +static const wxString PreviewFramePositionYEntry( wxT( "PreviewFramePositionY" ) ); +static const wxString PreviewFrameWidthEntry( wxT( "PreviewFrameWidth" ) ); +static const wxString PreviewFrameHeightEntry( wxT( "PreviewFrameHeight" ) ); +static const wxString PrintDialogPositionXEntry( wxT( "PrintDialogPositionX" ) ); +static const wxString PrintDialogPositionYEntry( wxT( "PrintDialogPositionY" ) ); +static const wxString PrintDialogWidthEntry( wxT( "PrintDialogWidth" ) ); +static const wxString PrintDialogHeightEntry( wxT( "PrintDialogHeight" ) ); /* @@ -437,6 +450,7 @@ PARAM_CFG_ARRAY& WinEDA_SchematicFrame::GetConfigurationSettings( void ) m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorErcE" ), &g_LayerDescr.LayerColor[LAYER_ERC_ERR], RED ) ); + return m_configSettings; } @@ -448,6 +462,8 @@ void WinEDA_SchematicFrame::LoadSettings() { wxASSERT( wxGetApp().m_EDA_Config != NULL ); + long tmp; + wxConfig* cfg = wxGetApp().m_EDA_Config; WinEDA_DrawFrame::LoadSettings(); @@ -458,6 +474,23 @@ void WinEDA_SchematicFrame::LoadSettings() (long) 6 ); cfg->Read( ShowHiddenPinsEntry, &m_ShowAllPins, false ); cfg->Read( HorzVertLinesOnlyEntry, &g_HVLines, true ); + cfg->Read( PreviewFramePositionXEntry, &tmp, -1 ); + m_previewPosition.x = (int) tmp; + cfg->Read( PreviewFramePositionYEntry, &tmp, -1 ); + m_previewPosition.y = (int) tmp; + cfg->Read( PreviewFrameWidthEntry, &tmp, -1 ); + m_previewSize.SetWidth( (int) tmp ); + cfg->Read( PreviewFrameHeightEntry, &tmp, -1 ); + m_previewSize.SetHeight( (int) tmp ); + + cfg->Read( PrintDialogPositionXEntry, &tmp, -1 ); + m_printDialogPosition.x = (int) tmp; + cfg->Read( PrintDialogPositionYEntry, &tmp, -1 ); + m_printDialogPosition.y = (int) tmp; + cfg->Read( PrintDialogWidthEntry, &tmp, -1 ); + m_printDialogSize.SetWidth( (int) tmp ); + cfg->Read( PrintDialogHeightEntry, &tmp, -1 ); + m_printDialogSize.SetHeight( (int) tmp ); } @@ -477,4 +510,14 @@ void WinEDA_SchematicFrame::SaveSettings() cfg->Write( DefaultDrawLineWidthEntry, (long) g_DrawDefaultLineThickness ); cfg->Write( ShowHiddenPinsEntry, m_ShowAllPins ); cfg->Write( HorzVertLinesOnlyEntry, g_HVLines ); + + cfg->Write( PreviewFramePositionXEntry, m_previewPosition.x ); + cfg->Write( PreviewFramePositionYEntry, m_previewPosition.y ); + cfg->Write( PreviewFrameWidthEntry, m_previewSize.GetWidth() ); + cfg->Write( PreviewFrameHeightEntry, m_previewSize.GetHeight() ); + + cfg->Write( PrintDialogPositionXEntry, m_printDialogPosition.x ); + cfg->Write( PrintDialogPositionYEntry, m_printDialogPosition.y ); + cfg->Write( PrintDialogWidthEntry, m_printDialogSize.GetWidth() ); + cfg->Write( PrintDialogHeightEntry, m_printDialogSize.GetHeight() ); } diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index a24fcdbd90..eef17917e2 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -57,21 +57,22 @@ void WinEDA_SchematicFrame::ReCreateMenuBar() wxMenu* openRecentMenu = new wxMenu(); wxGetApp().m_fileHistory.AddFilesToMenu( openRecentMenu ); ADD_MENUITEM_WITH_HELP_AND_SUBMENU( filesMenu, openRecentMenu, - -1, _( "Open &Recent" ), - _("Open a recent opened schematic project" ), - open_project_xpm ); + -1, _( "Open &Recent" ), + _("Open a recent opened schematic project" ), + open_project_xpm ); /* Separator */ filesMenu->AppendSeparator(); /* Save */ /* Save Project */ - item = new wxMenuItem( filesMenu, ID_SAVE_PROJECT, _( "&Save Whole Schematic Project\tCtrl+S" ), + item = new wxMenuItem( filesMenu, ID_SAVE_PROJECT, + _( "&Save Whole Schematic Project\tCtrl+S" ), _( "Save all sheets in the schematic project" ) ); item->SetBitmap( save_project_xpm ); filesMenu->Append( item ); - item = new wxMenuItem( filesMenu, ID_SAVE_ONE_SHEET, _( "&Save Current Sheet Only" ), + item = new wxMenuItem( filesMenu, ID_SAVE_ONE_SHEET, _( "Save &Current Sheet Only" ), _( "Save only current schematic sheet" ) ); item->SetBitmap( save_xpm ); filesMenu->Append( item ); @@ -87,8 +88,8 @@ void WinEDA_SchematicFrame::ReCreateMenuBar() filesMenu->AppendSeparator(); /* Print */ - item = new wxMenuItem( filesMenu, ID_GEN_PRINT, _( "P&rint\tCtrl+P" ), - _( "Print schematic sheet" ) ); + item = new wxMenuItem( filesMenu, wxID_PRINT, _( "P&rint\tCtrl+P" ), + _( "Print schematic" ) ); item->SetBitmap( print_button ); filesMenu->Append( item ); @@ -131,7 +132,8 @@ void WinEDA_SchematicFrame::ReCreateMenuBar() ADD_MENUITEM_WITH_HELP_AND_SUBMENU( filesMenu, choice_plot_fmt, ID_GEN_PLOT, _( "&Plot" ), - _( "Plot schematic sheet in HPGL, PostScript or SVG format" ), plot_xpm ); + _( "Plot schematic sheet in HPGL, PostScript or SVG format" ), + plot_xpm ); /* Quit on all platforms except WXMAC */ #if !defined(__WXMAC__) @@ -216,7 +218,7 @@ void WinEDA_SchematicFrame::ReCreateMenuBar() /* Zoom out */ #if !defined( __WXMAC__) text = AddHotkeyName( _( "Zoom Out" ), s_Schematic_Hokeys_Descr, - HK_ZOOM_OUT ); + HK_ZOOM_OUT ); #else text = _( "Zoom Out\tCtrl+-" ); #endif /* !defined( __WXMAC__) */ @@ -229,7 +231,7 @@ void WinEDA_SchematicFrame::ReCreateMenuBar() /* Fit on screen */ #if !defined( __WXMAC__) text = AddHotkeyName( _( "Fit on Screen" ), s_Schematic_Hokeys_Descr, - HK_ZOOM_AUTO ); + HK_ZOOM_AUTO ); #else text = _( "Fit on Screen\tCtrl+0" ); #endif @@ -245,7 +247,7 @@ void WinEDA_SchematicFrame::ReCreateMenuBar() /* Redraw view */ #if !defined( __WXMAC__) text = AddHotkeyName( _( "Redraw" ), s_Schematic_Hokeys_Descr, - HK_ZOOM_REDRAW ); + HK_ZOOM_REDRAW ); #else text = _( "Redraw\tCtrl+R" ); #endif @@ -323,7 +325,7 @@ void WinEDA_SchematicFrame::ReCreateMenuBar() /* Junction */ item = new wxMenuItem( placeMenu, ID_JUNCTION_BUTT, _( "Junction" ), - _( "Place junction" ), wxITEM_NORMAL ); + _( "Place junction" ), wxITEM_NORMAL ); item->SetBitmap( add_junction_xpm ); placeMenu->Append( item ); @@ -461,4 +463,3 @@ void WinEDA_SchematicFrame::ReCreateMenuBar() /* Associate the menu bar with the frame */ SetMenuBar( menuBar ); } - diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index f8dbef74e5..1f02e7fe01 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -49,7 +49,7 @@ BEGIN_EVENT_TABLE( WinEDA_SchematicFrame, WinEDA_DrawFrame ) EVT_MENU( ID_SAVE_ONE_SHEET, WinEDA_SchematicFrame::Save_File ) EVT_MENU( ID_SAVE_ONE_SHEET_AS, WinEDA_SchematicFrame::Save_File ) EVT_TOOL( ID_SAVE_PROJECT, WinEDA_SchematicFrame::Save_File ) - EVT_MENU( ID_GEN_PRINT, WinEDA_SchematicFrame::ToPrinter ) + EVT_MENU( wxID_PRINT, WinEDA_SchematicFrame::OnPrint ) EVT_MENU( ID_GEN_PLOT_PS, WinEDA_SchematicFrame::ToPlot_PS ) EVT_MENU( ID_GEN_PLOT_HPGL, WinEDA_SchematicFrame::ToPlot_HPGL ) EVT_MENU( ID_GEN_PLOT_SVG, WinEDA_DrawFrame::SVG_Print ) @@ -87,7 +87,7 @@ BEGIN_EVENT_TABLE( WinEDA_SchematicFrame, WinEDA_DrawFrame ) EVT_TOOL( wxID_REDO, WinEDA_SchematicFrame::GetSchematicFromRedoList ) EVT_TOOL( ID_GET_ANNOTATE, WinEDA_SchematicFrame::OnAnnotate ) - EVT_TOOL( ID_GEN_PRINT, WinEDA_SchematicFrame::ToPrinter ) + EVT_TOOL( wxID_PRINT, WinEDA_SchematicFrame::OnPrint ) EVT_TOOL( ID_GET_ERC, WinEDA_SchematicFrame::OnErc ) EVT_TOOL( ID_GET_NETLIST, WinEDA_SchematicFrame::OnCreateNetlist ) EVT_TOOL( ID_GET_TOOLS, WinEDA_SchematicFrame::OnCreateBillOfMaterials ) @@ -156,6 +156,10 @@ WinEDA_SchematicFrame::WinEDA_SchematicFrame( wxWindow* father, m_ViewlibFrame = NULL; // Frame for browsing component libraries m_DefaultSchematicFileName = wxT( "noname.sch" ); m_ShowAllPins = false; + m_previewPosition = wxDefaultPosition; + m_previewSize = wxDefaultSize; + m_printMonochrome = true; + m_showSheetReference = true; CreateScreens(); @@ -186,6 +190,10 @@ WinEDA_SchematicFrame::WinEDA_SchematicFrame( wxWindow* father, ReCreateVToolbar(); ReCreateOptToolbar(); + /* Initialize print and page setup dialog settings. */ + m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_HIGH ); + m_pageSetupData.GetPrintData().SetOrientation( wxLANDSCAPE ); + #if defined(KICAD_AUIMANAGER) m_auimgr.SetManagedWindow( this ); diff --git a/eeschema/tool_sch.cpp b/eeschema/tool_sch.cpp index c25d8a1c21..586c50cd06 100644 --- a/eeschema/tool_sch.cpp +++ b/eeschema/tool_sch.cpp @@ -80,7 +80,7 @@ void WinEDA_SchematicFrame::ReCreateHToolbar() wxBitmap( redo_xpm ), msg ); m_HToolBar->AddSeparator(); - m_HToolBar->AddTool( ID_GEN_PRINT, wxEmptyString, wxBitmap( print_button ), + m_HToolBar->AddTool( wxID_PRINT, wxEmptyString, wxBitmap( print_button ), _( "Print schematic" ) ); m_HToolBar->AddSeparator(); diff --git a/include/wxEeschemaStruct.h b/include/wxEeschemaStruct.h index 0f40566679..b06a57320d 100644 --- a/include/wxEeschemaStruct.h +++ b/include/wxEeschemaStruct.h @@ -53,25 +53,32 @@ enum fl_rot_cmp class WinEDA_SchematicFrame : public WinEDA_DrawFrame { public: - WinEDAChoiceBox* m_SelPartBox; - SCH_SHEET_PATH* m_CurrentSheet; ///< which sheet we are presently working on. - int m_Multiflag; - int m_NetlistFormat; - bool m_ShowAllPins; - wxPoint m_OldPos; - WinEDA_LibeditFrame* m_LibeditFrame; - WinEDA_ViewlibFrame* m_ViewlibFrame; - wxString m_UserLibraryPath; - wxArrayString m_ComponentLibFiles; + WinEDAChoiceBox* m_SelPartBox; + SCH_SHEET_PATH* m_CurrentSheet; ///< which sheet we are presently working on. + int m_Multiflag; + int m_NetlistFormat; + bool m_ShowAllPins; + wxPoint m_OldPos; + WinEDA_LibeditFrame* m_LibeditFrame; + WinEDA_ViewlibFrame* m_ViewlibFrame; + wxString m_UserLibraryPath; + wxArrayString m_ComponentLibFiles; private: - wxString m_DefaultSchematicFileName; - SCH_FIELD* m_CurrentField; - int m_TextFieldSize; - bool m_ShowGrid; - PARAM_CFG_ARRAY m_projectFileParams; - PARAM_CFG_ARRAY m_configSettings; + wxString m_DefaultSchematicFileName; + SCH_FIELD* m_CurrentField; + int m_TextFieldSize; + bool m_ShowGrid; + PARAM_CFG_ARRAY m_projectFileParams; + PARAM_CFG_ARRAY m_configSettings; + wxPageSetupDialogData m_pageSetupData; + wxPoint m_previewPosition; + wxSize m_previewSize; + wxPoint m_printDialogPosition; + wxSize m_printDialogSize; + bool m_printMonochrome; ///< Print monochrome instead of grey scale. + bool m_showSheetReference; public: WinEDA_SchematicFrame( wxWindow* father, @@ -201,10 +208,30 @@ public: */ void SetSheetNumberAndCount(); - /** function ToPrinter - * Install the print dialog + /** + * Show the print dialog */ - void ToPrinter( wxCommandEvent& event ); + void OnPrint( wxCommandEvent& event ); + + wxPageSetupDialogData& GetPageSetupData() { return m_pageSetupData; } + + void SetPreviewPosition( const wxPoint& aPoint ) { m_previewPosition = aPoint; } + void SetPreviewSize( const wxSize& aSize ) { m_previewSize = aSize; } + const wxPoint& GetPreviewPosition() { return m_previewPosition; } + const wxSize& GetPreviewSize() { return m_previewSize; } + + void SetPrintDialogPosition( const wxPoint& aPoint ) + { + m_printDialogPosition = aPoint; + } + void SetPrintDialogSize( const wxSize& aSize ) { m_printDialogSize = aSize; } + const wxPoint& GetPrintDialogPosition() { return m_printDialogPosition; } + const wxSize& GetPrintDialogSize() { return m_printDialogSize; } + + bool GetPrintMonochrome() { return m_printMonochrome; } + void SetPrintMonochrome( bool aMonochrome ) { m_printMonochrome = aMonochrome; } + bool GetShowSheetReference() { return m_showSheetReference; } + void SetShowSheetReference( bool aShow ) { m_showSheetReference = aShow; } // Plot functions: void ToPlot_PS( wxCommandEvent& event );