← Back to team overview

kicad-developers team mailing list archive

[PATCH] Save and load buttons in print dialog

 

Hi everybody,

Attached there is a patch to add the save function for the configuration of the print dialog. Often I need to generate prints from combined layers to have documents for production and selecting every time the right combination of layers and features is error prone and cumbersome, so I added the save and load functions to that dialog in order to save a 'configuration file' with the status of all the commands in the print dialog.

In this patch .ini files are used, but every comment is welcome about a better extension name. In this patch no default path is used for configuration files to give maximum flexibility, but may be a default path is better since an user tends to use the same configuration for all his works..

Bye,
Dino.

>From 40aeec58639f8c0b6f7681097ee53ffec76aa8b7 Mon Sep 17 00:00:00 2001
From: dino <dino.ghilardi@xxxxxxxx>
Date: Mon, 3 Oct 2016 22:02:24 +0200
Subject: [PATCH 1/9] Added file dialogs to load/save print configuration.
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------2.1.4"

This is a multi-part message in MIME format.
--------------2.1.4
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit

---
 pcbnew/dialogs/dialog_print_using_printer.cpp      |  51 ++++
 pcbnew/dialogs/dialog_print_using_printer_base.cpp |  15 +-
 pcbnew/dialogs/dialog_print_using_printer_base.fbp | 259 ++++++++++++++++++++-
 pcbnew/dialogs/dialog_print_using_printer_base.h   |  10 +-
 4 files changed, 331 insertions(+), 4 deletions(-)


--------------2.1.4
Content-Type: text/x-patch; name="0001-Added-file-dialogs-to-load-save-print-configuration.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0001-Added-file-dialogs-to-load-save-print-configuration.patch"

diff --git a/pcbnew/dialogs/dialog_print_using_printer.cpp b/pcbnew/dialogs/dialog_print_using_printer.cpp
index 93f1eb4..fde0a14 100644
--- a/pcbnew/dialogs/dialog_print_using_printer.cpp
+++ b/pcbnew/dialogs/dialog_print_using_printer.cpp
@@ -40,6 +40,9 @@
 
 #include <dialog_print_using_printer_base.h>
 
+#include <iostream>
+#include <fstream>
+
 
 #define PEN_WIDTH_MAX_VALUE ( KiROUND( 5 * IU_PER_MM ) )
 #define PEN_WIDTH_MIN_VALUE ( KiROUND( 0.005 * IU_PER_MM ) )
@@ -86,6 +89,8 @@ private:
     std::pair<wxCheckListBox*, int> m_boxSelectLayer[LAYER_ID_COUNT];
     static bool     m_ExcludeEdgeLayer;
 
+    void OnSaveConfigClick( wxCommandEvent& event ) override;
+    void OnLoadConfigClick( wxCommandEvent& event ) override;
     void OnCloseWindow( wxCloseEvent& event ) override;
     void OnPageSetup( wxCommandEvent& event ) override;
     void OnPrintPreview( wxCommandEvent& event ) override;
@@ -507,3 +512,49 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event )
         *s_PrintData = printer.GetPrintDialogData().GetPrintData();
     }
 }
+
+
+void DIALOG_PRINT_USING_PRINTER::OnSaveConfigClick( wxCommandEvent& event )
+{
+	wxFileDialog *SaveDialog = new wxFileDialog(
+		this, _("Save File As _?"), wxEmptyString, wxEmptyString,_("Text files (*.txt)|*.txt|C++ Source Files (*.cpp)|*.cpp|C Source files (*.c)|*.c|C header files (*.h)|*.h"),
+wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition);
+ 
+	// Creates a Save Dialog with 4 file types
+	if (SaveDialog->ShowModal() == wxID_OK) // If the user clicked "OK"
+	{	wxString CurrentDocPath;
+		std::ofstream confFile;
+		CurrentDocPath = SaveDialog->GetPath();
+		confFile.open (CurrentDocPath);
+		confFile << "[pcnbew]\n";
+
+		confFile.close();
+
+
+
+	}
+ 
+	// Clean up after ourselves
+	SaveDialog->Destroy();
+
+}
+
+void DIALOG_PRINT_USING_PRINTER::OnLoadConfigClick( wxCommandEvent& event )
+{	wxString CurrentDocPath;
+	wxFileDialog *OpenDialog = new wxFileDialog(
+	this, _("Choose a file to open"), wxEmptyString, wxEmptyString,
+		_("Text files (*.txt)|*.txt|C++ Source Files (*.cpp, *.cxx)|*.cpp;*.cxx|C Source files (*.c)|*.c|C header files (*.h)|*.h"),
+		wxFD_OPEN, wxDefaultPosition);
+ 
+	// Creates a "open file" dialog with 4 file types
+	if (OpenDialog->ShowModal() == wxID_OK) // if the user click "Open" instead of "cancel"
+	{
+		CurrentDocPath = OpenDialog->GetPath();
+ 
+		// Sets our current document to the file the user selected
+		//MainEditBox->LoadFile(CurrentDocPath); //Opens that file
+		// Set the Title to reflect the  file open
+		//SetTitle(wxString("Edit - ") << OpenDialog->GetFilename());
+	}
+
+}
diff --git a/pcbnew/dialogs/dialog_print_using_printer_base.cpp b/pcbnew/dialogs/dialog_print_using_printer_base.cpp
index ea69a09..248e941 100644
--- a/pcbnew/dialogs/dialog_print_using_printer_base.cpp
+++ b/pcbnew/dialogs/dialog_print_using_printer_base.cpp
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////
-// C++ code generated with wxFormBuilder (version May 21 2016)
+// C++ code generated with wxFormBuilder (version Oct  1 2016)
 // http://www.wxformbuilder.org/
 //
 // PLEASE DO "NOT" EDIT THIS FILE!
@@ -147,6 +147,15 @@ DIALOG_PRINT_USING_PRINTER_BASE::DIALOG_PRINT_USING_PRINTER_BASE( wxWindow* pare
 	
 	bbuttonsSizer->Add( 0, 0, 1, wxEXPAND, 5 );
 	
+	m_buttonConfigSave = new wxButton( this, wxID_PRINT_OPTIONS, _("Save config"), wxDefaultPosition, wxDefaultSize, 0 );
+	bbuttonsSizer->Add( m_buttonConfigSave, 0, wxALL|wxEXPAND, 5 );
+	
+	m_buttonConfigLoad = new wxButton( this, wxID_PRINT_OPTIONS, _("Load Config"), wxDefaultPosition, wxDefaultSize, 0 );
+	bbuttonsSizer->Add( m_buttonConfigLoad, 0, wxALL|wxEXPAND, 5 );
+	
+	m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
+	bbuttonsSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 );
+	
 	m_buttonOption = new wxButton( this, wxID_PRINT_OPTIONS, _("Page Options"), wxDefaultPosition, wxDefaultSize, 0 );
 	bbuttonsSizer->Add( m_buttonOption, 0, wxALL|wxEXPAND, 5 );
 	
@@ -176,6 +185,8 @@ DIALOG_PRINT_USING_PRINTER_BASE::DIALOG_PRINT_USING_PRINTER_BASE( wxWindow* pare
 	this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnCloseWindow ) );
 	this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnInitDlg ) );
 	m_ScaleOption->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnScaleSelectionClick ), NULL, this );
+	m_buttonConfigSave->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnSaveConfigClick ), NULL, this );
+	m_buttonConfigLoad->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnLoadConfigClick ), NULL, this );
 	m_buttonOption->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 );
@@ -188,6 +199,8 @@ DIALOG_PRINT_USING_PRINTER_BASE::~DIALOG_PRINT_USING_PRINTER_BASE()
 	this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnCloseWindow ) );
 	this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnInitDlg ) );
 	m_ScaleOption->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnScaleSelectionClick ), NULL, this );
+	m_buttonConfigSave->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnSaveConfigClick ), NULL, this );
+	m_buttonConfigLoad->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnLoadConfigClick ), NULL, this );
 	m_buttonOption->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 );
diff --git a/pcbnew/dialogs/dialog_print_using_printer_base.fbp b/pcbnew/dialogs/dialog_print_using_printer_base.fbp
index 7aab94e..e37bfb6 100644
--- a/pcbnew/dialogs/dialog_print_using_printer_base.fbp
+++ b/pcbnew/dialogs/dialog_print_using_printer_base.fbp
@@ -44,7 +44,7 @@
             <property name="minimum_size">-1,-1</property>
             <property name="name">DIALOG_PRINT_USING_PRINTER_BASE</property>
             <property name="pos"></property>
-            <property name="size">739,373</property>
+            <property name="size">739,441</property>
             <property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
             <property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
             <property name="title">Print</property>
@@ -1720,6 +1720,263 @@
                                 <property name="gripper">0</property>
                                 <property name="hidden">0</property>
                                 <property name="id">wxID_PRINT_OPTIONS</property>
+                                <property name="label">Save config</property>
+                                <property name="max_size"></property>
+                                <property name="maximize_button">0</property>
+                                <property name="maximum_size"></property>
+                                <property name="min_size"></property>
+                                <property name="minimize_button">0</property>
+                                <property name="minimum_size"></property>
+                                <property name="moveable">1</property>
+                                <property name="name">m_buttonConfigSave</property>
+                                <property name="pane_border">1</property>
+                                <property name="pane_position"></property>
+                                <property name="pane_size"></property>
+                                <property name="permission">protected</property>
+                                <property name="pin_button">1</property>
+                                <property name="pos"></property>
+                                <property name="resize">Resizable</property>
+                                <property name="show">1</property>
+                                <property name="size"></property>
+                                <property name="style"></property>
+                                <property name="subclass"></property>
+                                <property name="toolbar_pane">0</property>
+                                <property name="tooltip"></property>
+                                <property name="validator_data_type"></property>
+                                <property name="validator_style">wxFILTER_NONE</property>
+                                <property name="validator_type">wxDefaultValidator</property>
+                                <property name="validator_variable"></property>
+                                <property name="window_extra_style"></property>
+                                <property name="window_name"></property>
+                                <property name="window_style"></property>
+                                <event name="OnButtonClick">OnSaveConfigClick</event>
+                                <event name="OnChar"></event>
+                                <event name="OnEnterWindow"></event>
+                                <event name="OnEraseBackground"></event>
+                                <event name="OnKeyDown"></event>
+                                <event name="OnKeyUp"></event>
+                                <event name="OnKillFocus"></event>
+                                <event name="OnLeaveWindow"></event>
+                                <event name="OnLeftDClick"></event>
+                                <event name="OnLeftDown"></event>
+                                <event name="OnLeftUp"></event>
+                                <event name="OnMiddleDClick"></event>
+                                <event name="OnMiddleDown"></event>
+                                <event name="OnMiddleUp"></event>
+                                <event name="OnMotion"></event>
+                                <event name="OnMouseEvents"></event>
+                                <event name="OnMouseWheel"></event>
+                                <event name="OnPaint"></event>
+                                <event name="OnRightDClick"></event>
+                                <event name="OnRightDown"></event>
+                                <event name="OnRightUp"></event>
+                                <event name="OnSetFocus"></event>
+                                <event name="OnSize"></event>
+                                <event name="OnUpdateUI"></event>
+                            </object>
+                        </object>
+                        <object class="sizeritem" expanded="1">
+                            <property name="border">5</property>
+                            <property name="flag">wxALL|wxEXPAND</property>
+                            <property name="proportion">0</property>
+                            <object class="wxButton" expanded="1">
+                                <property name="BottomDockable">1</property>
+                                <property name="LeftDockable">1</property>
+                                <property name="RightDockable">1</property>
+                                <property name="TopDockable">1</property>
+                                <property name="aui_layer"></property>
+                                <property name="aui_name"></property>
+                                <property name="aui_position"></property>
+                                <property name="aui_row"></property>
+                                <property name="best_size"></property>
+                                <property name="bg"></property>
+                                <property name="caption"></property>
+                                <property name="caption_visible">1</property>
+                                <property name="center_pane">0</property>
+                                <property name="close_button">1</property>
+                                <property name="context_help"></property>
+                                <property name="context_menu">1</property>
+                                <property name="default">0</property>
+                                <property name="default_pane">0</property>
+                                <property name="dock">Dock</property>
+                                <property name="dock_fixed">0</property>
+                                <property name="docking">Left</property>
+                                <property name="enabled">1</property>
+                                <property name="fg"></property>
+                                <property name="floatable">1</property>
+                                <property name="font"></property>
+                                <property name="gripper">0</property>
+                                <property name="hidden">0</property>
+                                <property name="id">wxID_PRINT_OPTIONS</property>
+                                <property name="label">Load Config</property>
+                                <property name="max_size"></property>
+                                <property name="maximize_button">0</property>
+                                <property name="maximum_size"></property>
+                                <property name="min_size"></property>
+                                <property name="minimize_button">0</property>
+                                <property name="minimum_size"></property>
+                                <property name="moveable">1</property>
+                                <property name="name">m_buttonConfigLoad</property>
+                                <property name="pane_border">1</property>
+                                <property name="pane_position"></property>
+                                <property name="pane_size"></property>
+                                <property name="permission">protected</property>
+                                <property name="pin_button">1</property>
+                                <property name="pos"></property>
+                                <property name="resize">Resizable</property>
+                                <property name="show">1</property>
+                                <property name="size"></property>
+                                <property name="style"></property>
+                                <property name="subclass"></property>
+                                <property name="toolbar_pane">0</property>
+                                <property name="tooltip"></property>
+                                <property name="validator_data_type"></property>
+                                <property name="validator_style">wxFILTER_NONE</property>
+                                <property name="validator_type">wxDefaultValidator</property>
+                                <property name="validator_variable"></property>
+                                <property name="window_extra_style"></property>
+                                <property name="window_name"></property>
+                                <property name="window_style"></property>
+                                <event name="OnButtonClick">OnLoadConfigClick</event>
+                                <event name="OnChar"></event>
+                                <event name="OnEnterWindow"></event>
+                                <event name="OnEraseBackground"></event>
+                                <event name="OnKeyDown"></event>
+                                <event name="OnKeyUp"></event>
+                                <event name="OnKillFocus"></event>
+                                <event name="OnLeaveWindow"></event>
+                                <event name="OnLeftDClick"></event>
+                                <event name="OnLeftDown"></event>
+                                <event name="OnLeftUp"></event>
+                                <event name="OnMiddleDClick"></event>
+                                <event name="OnMiddleDown"></event>
+                                <event name="OnMiddleUp"></event>
+                                <event name="OnMotion"></event>
+                                <event name="OnMouseEvents"></event>
+                                <event name="OnMouseWheel"></event>
+                                <event name="OnPaint"></event>
+                                <event name="OnRightDClick"></event>
+                                <event name="OnRightDown"></event>
+                                <event name="OnRightUp"></event>
+                                <event name="OnSetFocus"></event>
+                                <event name="OnSize"></event>
+                                <event name="OnUpdateUI"></event>
+                            </object>
+                        </object>
+                        <object class="sizeritem" expanded="1">
+                            <property name="border">5</property>
+                            <property name="flag">wxEXPAND | wxALL</property>
+                            <property name="proportion">0</property>
+                            <object class="wxStaticLine" expanded="1">
+                                <property name="BottomDockable">1</property>
+                                <property name="LeftDockable">1</property>
+                                <property name="RightDockable">1</property>
+                                <property name="TopDockable">1</property>
+                                <property name="aui_layer"></property>
+                                <property name="aui_name"></property>
+                                <property name="aui_position"></property>
+                                <property name="aui_row"></property>
+                                <property name="best_size"></property>
+                                <property name="bg"></property>
+                                <property name="caption"></property>
+                                <property name="caption_visible">1</property>
+                                <property name="center_pane">0</property>
+                                <property name="close_button">1</property>
+                                <property name="context_help"></property>
+                                <property name="context_menu">1</property>
+                                <property name="default_pane">0</property>
+                                <property name="dock">Dock</property>
+                                <property name="dock_fixed">0</property>
+                                <property name="docking">Left</property>
+                                <property name="enabled">1</property>
+                                <property name="fg"></property>
+                                <property name="floatable">1</property>
+                                <property name="font"></property>
+                                <property name="gripper">0</property>
+                                <property name="hidden">0</property>
+                                <property name="id">wxID_ANY</property>
+                                <property name="max_size"></property>
+                                <property name="maximize_button">0</property>
+                                <property name="maximum_size"></property>
+                                <property name="min_size"></property>
+                                <property name="minimize_button">0</property>
+                                <property name="minimum_size"></property>
+                                <property name="moveable">1</property>
+                                <property name="name">m_staticline1</property>
+                                <property name="pane_border">1</property>
+                                <property name="pane_position"></property>
+                                <property name="pane_size"></property>
+                                <property name="permission">protected</property>
+                                <property name="pin_button">1</property>
+                                <property name="pos"></property>
+                                <property name="resize">Resizable</property>
+                                <property name="show">1</property>
+                                <property name="size"></property>
+                                <property name="style">wxLI_HORIZONTAL</property>
+                                <property name="subclass"></property>
+                                <property name="toolbar_pane">0</property>
+                                <property name="tooltip"></property>
+                                <property name="window_extra_style"></property>
+                                <property name="window_name"></property>
+                                <property name="window_style"></property>
+                                <event name="OnChar"></event>
+                                <event name="OnEnterWindow"></event>
+                                <event name="OnEraseBackground"></event>
+                                <event name="OnKeyDown"></event>
+                                <event name="OnKeyUp"></event>
+                                <event name="OnKillFocus"></event>
+                                <event name="OnLeaveWindow"></event>
+                                <event name="OnLeftDClick"></event>
+                                <event name="OnLeftDown"></event>
+                                <event name="OnLeftUp"></event>
+                                <event name="OnMiddleDClick"></event>
+                                <event name="OnMiddleDown"></event>
+                                <event name="OnMiddleUp"></event>
+                                <event name="OnMotion"></event>
+                                <event name="OnMouseEvents"></event>
+                                <event name="OnMouseWheel"></event>
+                                <event name="OnPaint"></event>
+                                <event name="OnRightDClick"></event>
+                                <event name="OnRightDown"></event>
+                                <event name="OnRightUp"></event>
+                                <event name="OnSetFocus"></event>
+                                <event name="OnSize"></event>
+                                <event name="OnUpdateUI"></event>
+                            </object>
+                        </object>
+                        <object class="sizeritem" expanded="1">
+                            <property name="border">5</property>
+                            <property name="flag">wxALL|wxEXPAND</property>
+                            <property name="proportion">0</property>
+                            <object class="wxButton" expanded="1">
+                                <property name="BottomDockable">1</property>
+                                <property name="LeftDockable">1</property>
+                                <property name="RightDockable">1</property>
+                                <property name="TopDockable">1</property>
+                                <property name="aui_layer"></property>
+                                <property name="aui_name"></property>
+                                <property name="aui_position"></property>
+                                <property name="aui_row"></property>
+                                <property name="best_size"></property>
+                                <property name="bg"></property>
+                                <property name="caption"></property>
+                                <property name="caption_visible">1</property>
+                                <property name="center_pane">0</property>
+                                <property name="close_button">1</property>
+                                <property name="context_help"></property>
+                                <property name="context_menu">1</property>
+                                <property name="default">0</property>
+                                <property name="default_pane">0</property>
+                                <property name="dock">Dock</property>
+                                <property name="dock_fixed">0</property>
+                                <property name="docking">Left</property>
+                                <property name="enabled">1</property>
+                                <property name="fg"></property>
+                                <property name="floatable">1</property>
+                                <property name="font"></property>
+                                <property name="gripper">0</property>
+                                <property name="hidden">0</property>
+                                <property name="id">wxID_PRINT_OPTIONS</property>
                                 <property name="label">Page Options</property>
                                 <property name="max_size"></property>
                                 <property name="maximize_button">0</property>
diff --git a/pcbnew/dialogs/dialog_print_using_printer_base.h b/pcbnew/dialogs/dialog_print_using_printer_base.h
index cb4e9bc..0ea7dff 100644
--- a/pcbnew/dialogs/dialog_print_using_printer_base.h
+++ b/pcbnew/dialogs/dialog_print_using_printer_base.h
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////
-// C++ code generated with wxFormBuilder (version May 21 2016)
+// C++ code generated with wxFormBuilder (version Oct  1 2016)
 // http://www.wxformbuilder.org/
 //
 // PLEASE DO "NOT" EDIT THIS FILE!
@@ -27,6 +27,7 @@ class DIALOG_SHIM;
 #include <wx/radiobox.h>
 #include <wx/textctrl.h>
 #include <wx/button.h>
+#include <wx/statline.h>
 #include <wx/dialog.h>
 
 ///////////////////////////////////////////////////////////////////////////
@@ -65,6 +66,9 @@ class DIALOG_PRINT_USING_PRINTER_BASE : public DIALOG_SHIM
 		wxRadioBox* m_Drill_Shape_Opt;
 		wxRadioBox* m_ModeColorOption;
 		wxRadioBox* m_PagesOption;
+		wxButton* m_buttonConfigSave;
+		wxButton* m_buttonConfigLoad;
+		wxStaticLine* m_staticline1;
 		wxButton* m_buttonOption;
 		wxButton* m_buttonPreview;
 		wxButton* m_buttonPrint;
@@ -74,6 +78,8 @@ class DIALOG_PRINT_USING_PRINTER_BASE : public DIALOG_SHIM
 		virtual void OnCloseWindow( wxCloseEvent& event ) { event.Skip(); }
 		virtual void OnInitDlg( wxInitDialogEvent& event ) { event.Skip(); }
 		virtual void OnScaleSelectionClick( wxCommandEvent& event ) { event.Skip(); }
+		virtual void OnSaveConfigClick( wxCommandEvent& event ) { event.Skip(); }
+		virtual void OnLoadConfigClick( 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(); }
@@ -82,7 +88,7 @@ class DIALOG_PRINT_USING_PRINTER_BASE : public DIALOG_SHIM
 	
 	public:
 		
-		DIALOG_PRINT_USING_PRINTER_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Print"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 739,373 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); 
+		DIALOG_PRINT_USING_PRINTER_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Print"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 739,441 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); 
 		~DIALOG_PRINT_USING_PRINTER_BASE();
 	
 };

--------------2.1.4--


>From a213faa734229b4edd3c45810d87dddf5f3d6ef6 Mon Sep 17 00:00:00 2001
From: dino <dino.ghilardi@xxxxxxxx>
Date: Mon, 3 Oct 2016 22:51:05 +0200
Subject: [PATCH 2/9] Saving print conf data.
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------2.1.4"

This is a multi-part message in MIME format.
--------------2.1.4
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit


Loading still to be written.
---
 pcbnew/dialogs/dialog_print_using_printer.cpp | 38 ++++++++++++++++++++++++---
 1 file changed, 34 insertions(+), 4 deletions(-)


--------------2.1.4
Content-Type: text/x-patch; name="0002-Saving-print-conf-data.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0002-Saving-print-conf-data.patch"

diff --git a/pcbnew/dialogs/dialog_print_using_printer.cpp b/pcbnew/dialogs/dialog_print_using_printer.cpp
index fde0a14..1b28c55 100644
--- a/pcbnew/dialogs/dialog_print_using_printer.cpp
+++ b/pcbnew/dialogs/dialog_print_using_printer.cpp
@@ -526,17 +526,47 @@ wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition);
 		std::ofstream confFile;
 		CurrentDocPath = SaveDialog->GetPath();
 		confFile.open (CurrentDocPath);
-		confFile << "[pcnbew]\n";
+		confFile << "[pcnbewPrintConfig]\n";
 
-		confFile.close();
 
+                { 
+                  confFile << "PrintMirror=" << m_Print_Mirror->GetValue()<<"\n";
+                  confFile << "PrintSheetRef="<< m_Print_Sheet_Ref->GetValue()<<"\n";
+                  confFile << "PrintBW="<< (m_ModeColorOption->GetSelection() != 0)<<"\n";
+                  confFile << "DrillShapeOpt=" << m_Drill_Shape_Opt->GetSelection()<<"\n";
+                  confFile << "OptionPrintPage ="<< (m_PagesOption->GetSelection() != 0)<<"\n";
+                  
+                   //SetLayerSetFromListSelection();
 
+                   int idx = m_ScaleOption->GetSelection();
+                   confFile<< "PrintScale="<< s_ScaleList[idx]<<"\n";
+                   confFile<< "XFineScaleAdjust="<<m_FineAdjustXscaleOpt->GetValue()<< "\n";
+                   confFile<< "YScaleAdjust=" <<m_FineAdjustYscaleOpt->GetValue()<<"\n";
 
-	}
+
+  for( unsigned ii = 0; ii < DIM(m_boxSelectLayer); ++ii )
+    {
+        if( !m_boxSelectLayer[ii].first )
+            continue;
+
+        confFile <<"LayerSelected("<<ii<<")=";
+        if( m_boxSelectLayer[ii].first->IsChecked( m_boxSelectLayer[ii].second ) )
+        {
+               confFile<<"1";
+        }
+        else
+                confFile<<"0";
+                confFile<<"\n";
+                }
+        //m_parent->SetPlotSettings( plot_opts );
+        }
+
+		confFile.close();
+
+	} //OK clicked.
  
 	// Clean up after ourselves
 	SaveDialog->Destroy();
-
 }
 
 void DIALOG_PRINT_USING_PRINTER::OnLoadConfigClick( wxCommandEvent& event )

--------------2.1.4--


>From fa975fd01093db77b99378106004c01c52de0f2a Mon Sep 17 00:00:00 2001
From: dino <dino.ghilardi@xxxxxxxx>
Date: Thu, 6 Oct 2016 13:06:14 +0200
Subject: [PATCH 3/9] Test writing and readin, not complete using wxWidgets.
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------2.1.4"

This is a multi-part message in MIME format.
--------------2.1.4
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit

---
 pcbnew/dialogs/dialog_print_using_printer.cpp | 83 ++++++++++++++++-----------
 1 file changed, 48 insertions(+), 35 deletions(-)


--------------2.1.4
Content-Type: text/x-patch; name="0003-Test-writing-and-readin-not-complete-using-wxWidgets.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0003-Test-writing-and-readin-not-complete-using-wxWidgets.patch"

diff --git a/pcbnew/dialogs/dialog_print_using_printer.cpp b/pcbnew/dialogs/dialog_print_using_printer.cpp
index 1b28c55..f6f9dc2 100644
--- a/pcbnew/dialogs/dialog_print_using_printer.cpp
+++ b/pcbnew/dialogs/dialog_print_using_printer.cpp
@@ -516,26 +516,25 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event )
 
 void DIALOG_PRINT_USING_PRINTER::OnSaveConfigClick( wxCommandEvent& event )
 {
-	wxFileDialog *SaveDialog = new wxFileDialog(
-		this, _("Save File As _?"), wxEmptyString, wxEmptyString,_("Text files (*.txt)|*.txt|C++ Source Files (*.cpp)|*.cpp|C Source files (*.c)|*.c|C header files (*.h)|*.h"),
+        wxFileDialog *SaveDialog = new wxFileDialog(
+                this, _("Save File As _?"), wxEmptyString, wxEmptyString,_("Text files (*.txt)|*.txt|C++ Source Files (*.cpp)|*.cpp|C Source files (*.c)|*.c|C header files (*.h)|*.h"),
 wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition);
  
-	// Creates a Save Dialog with 4 file types
-	if (SaveDialog->ShowModal() == wxID_OK) // If the user clicked "OK"
-	{	wxString CurrentDocPath;
-		std::ofstream confFile;
-		CurrentDocPath = SaveDialog->GetPath();
-		confFile.open (CurrentDocPath);
-		confFile << "[pcnbewPrintConfig]\n";
-
-
-                { 
+        // Creates a Save Dialog with 4 file types
+        if (SaveDialog->ShowModal() == wxID_OK) // If the user clicked "OK"
+        {       wxString CurrentDocPath;
+                std::ofstream confFile;
+                CurrentDocPath = SaveDialog->GetPath();
+                confFile.open (CurrentDocPath);
+                confFile << "[pcnbewPrintConfig]\n";
+
+                {
                   confFile << "PrintMirror=" << m_Print_Mirror->GetValue()<<"\n";
                   confFile << "PrintSheetRef="<< m_Print_Sheet_Ref->GetValue()<<"\n";
                   confFile << "PrintBW="<< (m_ModeColorOption->GetSelection() != 0)<<"\n";
                   confFile << "DrillShapeOpt=" << m_Drill_Shape_Opt->GetSelection()<<"\n";
                   confFile << "OptionPrintPage ="<< (m_PagesOption->GetSelection() != 0)<<"\n";
-                  
+
                    //SetLayerSetFromListSelection();
 
                    int idx = m_ScaleOption->GetSelection();
@@ -558,33 +557,47 @@ wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition);
                 confFile<<"0";
                 confFile<<"\n";
                 }
+
+        confFile<< "PenWidth=" << ValueFromTextCtrl( *m_DialogPenWidth );
+
         //m_parent->SetPlotSettings( plot_opts );
         }
+                confFile.close();
 
-		confFile.close();
-
-	} //OK clicked.
- 
-	// Clean up after ourselves
-	SaveDialog->Destroy();
+        } //OK clicked.
+        // Clean up after ourselves
+        SaveDialog->Destroy();
 }
 
 void DIALOG_PRINT_USING_PRINTER::OnLoadConfigClick( wxCommandEvent& event )
-{	wxString CurrentDocPath;
-	wxFileDialog *OpenDialog = new wxFileDialog(
-	this, _("Choose a file to open"), wxEmptyString, wxEmptyString,
-		_("Text files (*.txt)|*.txt|C++ Source Files (*.cpp, *.cxx)|*.cpp;*.cxx|C Source files (*.c)|*.c|C header files (*.h)|*.h"),
-		wxFD_OPEN, wxDefaultPosition);
- 
-	// Creates a "open file" dialog with 4 file types
-	if (OpenDialog->ShowModal() == wxID_OK) // if the user click "Open" instead of "cancel"
-	{
-		CurrentDocPath = OpenDialog->GetPath();
- 
-		// Sets our current document to the file the user selected
-		//MainEditBox->LoadFile(CurrentDocPath); //Opens that file
-		// Set the Title to reflect the  file open
-		//SetTitle(wxString("Edit - ") << OpenDialog->GetFilename());
-	}
+{       wxString CurrentDocPath;
+        wxFileDialog *OpenDialog = new wxFileDialog(
+        this, _("Choose a file to open"), wxEmptyString, wxEmptyString,
+                _("Text files (*.txt)|*.txt|C++ Source Files (*.cpp, *.cxx)|*.cpp;*.cxx|C Source files (*.c)|*.c|C header files (*.h)|*.h"),
+                wxFD_OPEN, wxDefaultPosition);
+
+        // Creates a "open file" dialog with 4 file types
+        if (OpenDialog->ShowModal() == wxID_OK) // if the user click "Open" instead of "cancel"
+        {
+                CurrentDocPath = OpenDialog->GetPath();
+
+                wxString ReadString;
+                 long lngRet=-1;
+                 wxFileConfig* PrintConfigFile = new wxFileConfig("", "",CurrentDocPath, "",    wxCONFIG_USE_RELATIVE_PATH);
+
+                PrintConfigFile->Read("PrintMirror", &lngRet);
+                if (lngRet==0) DisplayError( this, _( "PrintMirror=0" ) );
+                else  DisplayError( this, _( "PrintMirror=1" ) );
+
+                //AppConfig.Version = lngRet;
+                //AppConfigFile->Read(wxT("APP/CurrentRangeMap"), &ReadString);
+                //AppConfig.CurrentRangeMap = ReadString;
+
+                delete PrintConfigFile;
+                
+                }
+
+
+        } //OK clicked on file selection dialog.
 
 }

--------------2.1.4--


>From d45b4428819a9d31279b226198855f4acede0a67 Mon Sep 17 00:00:00 2001
From: dino <dino.ghilardi@xxxxxxxx>
Date: Thu, 6 Oct 2016 22:49:02 +0200
Subject: [PATCH 4/9] Test con wxWidget per config file.
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------2.1.4"

This is a multi-part message in MIME format.
--------------2.1.4
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit

---
 pcbnew/dialogs/dialog_print_using_printer.cpp | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)


--------------2.1.4
Content-Type: text/x-patch; name="0004-Test-con-wxWidget-per-config-file.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0004-Test-con-wxWidget-per-config-file.patch"

diff --git a/pcbnew/dialogs/dialog_print_using_printer.cpp b/pcbnew/dialogs/dialog_print_using_printer.cpp
index f6f9dc2..ded4f9d 100644
--- a/pcbnew/dialogs/dialog_print_using_printer.cpp
+++ b/pcbnew/dialogs/dialog_print_using_printer.cpp
@@ -584,19 +584,15 @@ void DIALOG_PRINT_USING_PRINTER::OnLoadConfigClick( wxCommandEvent& event )
                 wxString ReadString;
                  long lngRet=-1;
                  wxFileConfig* PrintConfigFile = new wxFileConfig("", "",CurrentDocPath, "",    wxCONFIG_USE_RELATIVE_PATH);
-
+		cout<< "Prova";
                 PrintConfigFile->Read("PrintMirror", &lngRet);
-                if (lngRet==0) DisplayError( this, _( "PrintMirror=0" ) );
-                else  DisplayError( this, _( "PrintMirror=1" ) );
-
-                //AppConfig.Version = lngRet;
-                //AppConfigFile->Read(wxT("APP/CurrentRangeMap"), &ReadString);
-                //AppConfig.CurrentRangeMap = ReadString;
+                if (lngRet==0) 
+			DisplayError( this, "PrintMirror=0");
+                else  
+			DisplayError( this, "PrintMirror=1");
 
                 delete PrintConfigFile;
                 
-                }
-
 
         } //OK clicked on file selection dialog.
 

--------------2.1.4--


>From 4a549571ac484146e9087685e7e10ca00ff6b4ee Mon Sep 17 00:00:00 2001
From: dino <dino.ghilardi@xxxxxxxx>
Date: Fri, 7 Oct 2016 00:25:02 +0200
Subject: [PATCH 5/9] Config save using wxWidget working.
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------2.1.4"

This is a multi-part message in MIME format.
--------------2.1.4
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit

---
 pcbnew/dialogs/dialog_print_using_printer.cpp | 53 ++++++++++++++++++++-------
 1 file changed, 39 insertions(+), 14 deletions(-)


--------------2.1.4
Content-Type: text/x-patch; name="0005-Config-save-using-wxWidget-working.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0005-Config-save-using-wxWidget-working.patch"

diff --git a/pcbnew/dialogs/dialog_print_using_printer.cpp b/pcbnew/dialogs/dialog_print_using_printer.cpp
index ded4f9d..3f185fc 100644
--- a/pcbnew/dialogs/dialog_print_using_printer.cpp
+++ b/pcbnew/dialogs/dialog_print_using_printer.cpp
@@ -517,12 +517,43 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event )
 void DIALOG_PRINT_USING_PRINTER::OnSaveConfigClick( wxCommandEvent& event )
 {
         wxFileDialog *SaveDialog = new wxFileDialog(
-                this, _("Save File As _?"), wxEmptyString, wxEmptyString,_("Text files (*.txt)|*.txt|C++ Source Files (*.cpp)|*.cpp|C Source files (*.c)|*.c|C header files (*.h)|*.h"),
+                this, _("Save File As _?"), wxEmptyString, wxEmptyString,_("Ini files (*.ini)|*.ini"),
 wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition);
  
         // Creates a Save Dialog with 4 file types
         if (SaveDialog->ShowModal() == wxID_OK) // If the user clicked "OK"
         {       wxString CurrentDocPath;
+
+                CurrentDocPath = SaveDialog->GetPath();
+                wxFileConfig* PrintConfigFile = new wxFileConfig("", "",CurrentDocPath);
+                wxLogMessage( wxT("creating inifile: %s"), CurrentDocPath );
+		PrintConfigFile->Write(wxT("PrintConfig/PrintMirror"), m_Print_Mirror->GetValue());
+                PrintConfigFile->Write(wxT("PrintConfig/PrintSheetRef"), m_Print_Sheet_Ref->GetValue());
+                PrintConfigFile->Write(wxT("PrintConfig/PrintBW"),  (m_ModeColorOption->GetSelection() != 0));
+                PrintConfigFile->Write(wxT("PrintConfig/DrillShapeOpt"), m_Drill_Shape_Opt->GetSelection());
+                PrintConfigFile->Write(wxT("PrintConfig/OptionPrintPage"),  (m_PagesOption->GetSelection() != 0));
+
+                int idx = m_ScaleOption->GetSelection();
+                PrintConfigFile->Write(wxT("PrintConfig/PrintScale"), s_ScaleList[idx]); 
+                PrintConfigFile->Write(wxT("PrintConfig/XFineScaleAdjust"),m_FineAdjustXscaleOpt->GetValue());
+                PrintConfigFile->Write(wxT("PrintConfig/YFineScaleAdjust"),m_FineAdjustYscaleOpt->GetValue());
+
+                for( unsigned ii = 0; ii < DIM(m_boxSelectLayer); ++ii )
+                {       wxString s1=wxT("PrintConfig/Layer");
+                        wxString s3=wxT("Selected");
+                        wxString s2= std::to_string(ii);
+                        if( !m_boxSelectLayer[ii].first )
+                            continue;
+                        PrintConfigFile->Write(s1+s2+s3,
+                                                m_boxSelectLayer[ii].first->IsChecked( m_boxSelectLayer[ii].second ) );
+                }
+
+                PrintConfigFile->Flush();
+                delete PrintConfigFile;
+
+
+                /*
+                 long lngRet=-1;
                 std::ofstream confFile;
                 CurrentDocPath = SaveDialog->GetPath();
                 confFile.open (CurrentDocPath);
@@ -561,9 +592,9 @@ wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition);
         confFile<< "PenWidth=" << ValueFromTextCtrl( *m_DialogPenWidth );
 
         //m_parent->SetPlotSettings( plot_opts );
-        }
+         }
                 confFile.close();
-
+*/
         } //OK clicked.
         // Clean up after ourselves
         SaveDialog->Destroy();
@@ -573,27 +604,21 @@ void DIALOG_PRINT_USING_PRINTER::OnLoadConfigClick( wxCommandEvent& event )
 {       wxString CurrentDocPath;
         wxFileDialog *OpenDialog = new wxFileDialog(
         this, _("Choose a file to open"), wxEmptyString, wxEmptyString,
-                _("Text files (*.txt)|*.txt|C++ Source Files (*.cpp, *.cxx)|*.cpp;*.cxx|C Source files (*.c)|*.c|C header files (*.h)|*.h"),
+                _("Ini (*.ini)|*.ini"),
                 wxFD_OPEN, wxDefaultPosition);
 
         // Creates a "open file" dialog with 4 file types
         if (OpenDialog->ShowModal() == wxID_OK) // if the user click "Open" instead of "cancel"
         {
                 CurrentDocPath = OpenDialog->GetPath();
-
                 wxString ReadString;
-                 long lngRet=-1;
+                 bool val;
                  wxFileConfig* PrintConfigFile = new wxFileConfig("", "",CurrentDocPath, "",    wxCONFIG_USE_RELATIVE_PATH);
-		cout<< "Prova";
-                PrintConfigFile->Read("PrintMirror", &lngRet);
-                if (lngRet==0) 
-			DisplayError( this, "PrintMirror=0");
-                else  
-			DisplayError( this, "PrintMirror=1");
+                PrintConfigFile->Read("Printconfig/PrintMirror", &val);
 
-                delete PrintConfigFile;
-                
+                //FIXME: Terminare inserimento
 
+                delete PrintConfigFile;
         } //OK clicked on file selection dialog.
 
 }

--------------2.1.4--


>From d541a5a86d67a7ffcb3cca5c20082700898289ce Mon Sep 17 00:00:00 2001
From: dino <dino.ghilardi@xxxxxxxx>
Date: Sun, 9 Oct 2016 23:45:48 +0200
Subject: [PATCH 6/9] Load partially implemented.
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------2.1.4"

This is a multi-part message in MIME format.
--------------2.1.4
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit

---
 pcbnew/dialogs/dialog_print_using_printer.cpp | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)


--------------2.1.4
Content-Type: text/x-patch; name="0006-Load-partially-implemented.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0006-Load-partially-implemented.patch"

diff --git a/pcbnew/dialogs/dialog_print_using_printer.cpp b/pcbnew/dialogs/dialog_print_using_printer.cpp
index 3f185fc..83a0a26 100644
--- a/pcbnew/dialogs/dialog_print_using_printer.cpp
+++ b/pcbnew/dialogs/dialog_print_using_printer.cpp
@@ -613,8 +613,28 @@ void DIALOG_PRINT_USING_PRINTER::OnLoadConfigClick( wxCommandEvent& event )
                 CurrentDocPath = OpenDialog->GetPath();
                 wxString ReadString;
                  bool val;
-                 wxFileConfig* PrintConfigFile = new wxFileConfig("", "",CurrentDocPath, "",    wxCONFIG_USE_RELATIVE_PATH);
+                 wxFileConfig* PrintConfigFile = new wxFileConfig("", "",
+                                                        CurrentDocPath, "",    
+                                                        wxCONFIG_USE_RELATIVE_PATH);
                 PrintConfigFile->Read("Printconfig/PrintMirror", &val);
+                m_Print_Mirror->SetValue(val);
+
+                PrintConfigFile->Read("PrintConfig/PrintSheetRef", &val);
+                m_Print_Sheet_Ref->SetValue(val);
+        
+                PrintConfigFile->Read("PrintConfig/PrintBW",&val);
+                
+                if (val) m_ModeColorOption->SetSelection(0);
+                        else
+                         m_ModeColorOption->SetSelection(1);
+
+                //("PrintConfig/DrillShapeOpt"), m_Drill_Shape_Opt->GetSelection());
+                //("PrintConfig/OptionPrintPage"),  (m_PagesOption->GetSelection() != 0));
+
+                //("PrintConfig/PrintScale"), s_ScaleList[idx]); 
+                //("PrintConfig/XFineScaleAdjust"),m_FineAdjustXscaleOpt->GetValue());
+                //("PrintConfig/YFineScaleAdjust"),m_FineAdjustYscaleOpt->GetValue());
+
 
                 //FIXME: Terminare inserimento
 

--------------2.1.4--


>From 839ca023ec7b1034bb4aa909a88b415f6ef66581 Mon Sep 17 00:00:00 2001
From: dino <dino.ghilardi@xxxxxxxx>
Date: Tue, 11 Oct 2016 08:38:20 +0200
Subject: [PATCH 7/9] Print options save working, to be checked.
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------2.1.4"

This is a multi-part message in MIME format.
--------------2.1.4
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit

---
 pcbnew/dialogs/dialog_print_using_printer.cpp | 66 +++++++++++++++++++++------
 1 file changed, 51 insertions(+), 15 deletions(-)


--------------2.1.4
Content-Type: text/x-patch; name="0007-Print-options-save-working-to-be-checked.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0007-Print-options-save-working-to-be-checked.patch"

diff --git a/pcbnew/dialogs/dialog_print_using_printer.cpp b/pcbnew/dialogs/dialog_print_using_printer.cpp
index 83a0a26..0917716 100644
--- a/pcbnew/dialogs/dialog_print_using_printer.cpp
+++ b/pcbnew/dialogs/dialog_print_using_printer.cpp
@@ -527,9 +527,9 @@ wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition);
                 CurrentDocPath = SaveDialog->GetPath();
                 wxFileConfig* PrintConfigFile = new wxFileConfig("", "",CurrentDocPath);
                 wxLogMessage( wxT("creating inifile: %s"), CurrentDocPath );
-		PrintConfigFile->Write(wxT("PrintConfig/PrintMirror"), m_Print_Mirror->GetValue());
+                PrintConfigFile->Write(wxT("PrintConfig/PrintMirror"), m_Print_Mirror->GetValue());
                 PrintConfigFile->Write(wxT("PrintConfig/PrintSheetRef"), m_Print_Sheet_Ref->GetValue());
-                PrintConfigFile->Write(wxT("PrintConfig/PrintBW"),  (m_ModeColorOption->GetSelection() != 0));
+                PrintConfigFile->Write(wxT("PrintConfig/PrintBW"),  (m_ModeColorOption->GetSelection()!= 0));
                 PrintConfigFile->Write(wxT("PrintConfig/DrillShapeOpt"), m_Drill_Shape_Opt->GetSelection());
                 PrintConfigFile->Write(wxT("PrintConfig/OptionPrintPage"),  (m_PagesOption->GetSelection() != 0));
 
@@ -600,6 +600,10 @@ wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition);
         SaveDialog->Destroy();
 }
 
+//template <typename T,unsigned S>
+//inline unsigned arraysize(const T (&v)[S]) { return S; }
+
+
 void DIALOG_PRINT_USING_PRINTER::OnLoadConfigClick( wxCommandEvent& event )
 {       wxString CurrentDocPath;
         wxFileDialog *OpenDialog = new wxFileDialog(
@@ -613,6 +617,8 @@ void DIALOG_PRINT_USING_PRINTER::OnLoadConfigClick( wxCommandEvent& event )
                 CurrentDocPath = OpenDialog->GetPath();
                 wxString ReadString;
                  bool val;
+                 int ival;
+                 double dval;
                  wxFileConfig* PrintConfigFile = new wxFileConfig("", "",
                                                         CurrentDocPath, "",    
                                                         wxCONFIG_USE_RELATIVE_PATH);
@@ -621,24 +627,54 @@ void DIALOG_PRINT_USING_PRINTER::OnLoadConfigClick( wxCommandEvent& event )
 
                 PrintConfigFile->Read("PrintConfig/PrintSheetRef", &val);
                 m_Print_Sheet_Ref->SetValue(val);
-        
+
                 PrintConfigFile->Read("PrintConfig/PrintBW",&val);
-                
-                if (val) m_ModeColorOption->SetSelection(0);
-                        else
-                         m_ModeColorOption->SetSelection(1);
 
-                //("PrintConfig/DrillShapeOpt"), m_Drill_Shape_Opt->GetSelection());
-                //("PrintConfig/OptionPrintPage"),  (m_PagesOption->GetSelection() != 0));
+                if (val)
+                        m_ModeColorOption->SetSelection(1);
+                else
+                         m_ModeColorOption->SetSelection(0);
+                PrintConfigFile->Read("PrintConfig/DrillShapeOpt", &ival);
+                m_Drill_Shape_Opt->SetSelection(ival);
+                PrintConfigFile->Read("PrintConfig/OptionPrintPage", &ival);
+                m_PagesOption->SetSelection(ival==0);
+
+                PrintConfigFile->Read("PrintConfig/PrintScale", &dval);
+
+//#define ARRAY_SIZE(array) (sizeof((array))/sizeof((array[0])))
+
+                for (unsigned ii=0; ii<DIM(s_ScaleList); ii++)
+                {       // If the saved scale is not found in the list, silently ignore the value.
+                       if (s_ScaleList[ii]==dval)
+                        {       m_ScaleOption->SetSelection(ii);
+                                break;
+                        }
+                }
 
-                //("PrintConfig/PrintScale"), s_ScaleList[idx]); 
-                //("PrintConfig/XFineScaleAdjust"),m_FineAdjustXscaleOpt->GetValue());
-                //("PrintConfig/YFineScaleAdjust"),m_FineAdjustYscaleOpt->GetValue());
+                PrintConfigFile->Read("PrintConfig/XFineScaleAdjust", &dval);
+                {       std::ostringstream strs;
+                        strs << dval;
+                        std::string str = strs.str();
+                        m_FineAdjustXscaleOpt->SetValue(str);
+                }
+                PrintConfigFile->Read("PrintConfig/YFineScaleAdjust", &dval);
+                {       std::ostringstream strs;
+                        strs << dval;
+                        std::string str = strs.str();
+                        m_FineAdjustYscaleOpt->SetValue(str);
+                }
 
+                for( unsigned ii = 0; ii < DIM(m_boxSelectLayer); ++ii )
+                {       wxString s1=wxT("PrintConfig/Layer");
+                        wxString s2= std::to_string(ii);
+                        wxString s3=wxT("Selected");
 
-                //FIXME: Terminare inserimento
+                        if( !m_boxSelectLayer[ii].first )
+                            continue;
+                        PrintConfigFile->Read(s1+s2+s3, &val);
+                        m_boxSelectLayer[ii].first->Check( m_boxSelectLayer[ii].second , val);
+                }
 
                 delete PrintConfigFile;
         } //OK clicked on file selection dialog.
-
-}
+} //OnLoadConfigClick

--------------2.1.4--


>From dc295dc3567cba04f26d98ee2ee612c413dd7af7 Mon Sep 17 00:00:00 2001
From: dino <dino.ghilardi@xxxxxxxx>
Date: Tue, 11 Oct 2016 19:21:43 +0200
Subject: [PATCH 8/9] Aesthetic changes
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------2.1.4"

This is a multi-part message in MIME format.
--------------2.1.4
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit

---
 pcbnew/dialogs/dialog_print_using_printer.cpp | 47 ---------------------------
 1 file changed, 47 deletions(-)


--------------2.1.4
Content-Type: text/x-patch; name="0008-Aesthetic-changes.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0008-Aesthetic-changes.patch"

diff --git a/pcbnew/dialogs/dialog_print_using_printer.cpp b/pcbnew/dialogs/dialog_print_using_printer.cpp
index 0917716..56fae2f 100644
--- a/pcbnew/dialogs/dialog_print_using_printer.cpp
+++ b/pcbnew/dialogs/dialog_print_using_printer.cpp
@@ -550,51 +550,6 @@ wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition);
 
                 PrintConfigFile->Flush();
                 delete PrintConfigFile;
-
-
-                /*
-                 long lngRet=-1;
-                std::ofstream confFile;
-                CurrentDocPath = SaveDialog->GetPath();
-                confFile.open (CurrentDocPath);
-                confFile << "[pcnbewPrintConfig]\n";
-
-                {
-                  confFile << "PrintMirror=" << m_Print_Mirror->GetValue()<<"\n";
-                  confFile << "PrintSheetRef="<< m_Print_Sheet_Ref->GetValue()<<"\n";
-                  confFile << "PrintBW="<< (m_ModeColorOption->GetSelection() != 0)<<"\n";
-                  confFile << "DrillShapeOpt=" << m_Drill_Shape_Opt->GetSelection()<<"\n";
-                  confFile << "OptionPrintPage ="<< (m_PagesOption->GetSelection() != 0)<<"\n";
-
-                   //SetLayerSetFromListSelection();
-
-                   int idx = m_ScaleOption->GetSelection();
-                   confFile<< "PrintScale="<< s_ScaleList[idx]<<"\n";
-                   confFile<< "XFineScaleAdjust="<<m_FineAdjustXscaleOpt->GetValue()<< "\n";
-                   confFile<< "YScaleAdjust=" <<m_FineAdjustYscaleOpt->GetValue()<<"\n";
-
-
-  for( unsigned ii = 0; ii < DIM(m_boxSelectLayer); ++ii )
-    {
-        if( !m_boxSelectLayer[ii].first )
-            continue;
-
-        confFile <<"LayerSelected("<<ii<<")=";
-        if( m_boxSelectLayer[ii].first->IsChecked( m_boxSelectLayer[ii].second ) )
-        {
-               confFile<<"1";
-        }
-        else
-                confFile<<"0";
-                confFile<<"\n";
-                }
-
-        confFile<< "PenWidth=" << ValueFromTextCtrl( *m_DialogPenWidth );
-
-        //m_parent->SetPlotSettings( plot_opts );
-         }
-                confFile.close();
-*/
         } //OK clicked.
         // Clean up after ourselves
         SaveDialog->Destroy();
@@ -641,8 +596,6 @@ void DIALOG_PRINT_USING_PRINTER::OnLoadConfigClick( wxCommandEvent& event )
 
                 PrintConfigFile->Read("PrintConfig/PrintScale", &dval);
 
-//#define ARRAY_SIZE(array) (sizeof((array))/sizeof((array[0])))
-
                 for (unsigned ii=0; ii<DIM(s_ScaleList); ii++)
                 {       // If the saved scale is not found in the list, silently ignore the value.
                        if (s_ScaleList[ii]==dval)

--------------2.1.4--


>From 67df14ec0ace97f9ba179a678982570b2b075738 Mon Sep 17 00:00:00 2001
From: dino <dino.ghilardi@xxxxxxxx>
Date: Tue, 11 Oct 2016 23:49:28 +0200
Subject: [PATCH 9/9] Code beautify following coding policy.
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------2.1.4"

This is a multi-part message in MIME format.
--------------2.1.4
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit


Used uncrustify to see differences.
---
 pcbnew/dialogs/dialog_print_using_printer.cpp | 241 ++++++++++++++------------
 1 file changed, 130 insertions(+), 111 deletions(-)


--------------2.1.4
Content-Type: text/x-patch; name="0009-Code-beautify-following-coding-policy.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0009-Code-beautify-following-coding-policy.patch"

diff --git a/pcbnew/dialogs/dialog_print_using_printer.cpp b/pcbnew/dialogs/dialog_print_using_printer.cpp
index 56fae2f..9c2ff30 100644
--- a/pcbnew/dialogs/dialog_print_using_printer.cpp
+++ b/pcbnew/dialogs/dialog_print_using_printer.cpp
@@ -411,9 +411,9 @@ void DIALOG_PRINT_USING_PRINTER::OnScaleSelectionClick( wxCommandEvent& event )
     bool enable = (scale == 1.0);
 
     if( m_FineAdjustXscaleOpt )
-        m_FineAdjustXscaleOpt->Enable(enable);
+        m_FineAdjustXscaleOpt->Enable( enable );
     if( m_FineAdjustYscaleOpt )
-        m_FineAdjustYscaleOpt->Enable(enable);
+        m_FineAdjustYscaleOpt->Enable( enable );
 }
 
 
@@ -516,118 +516,137 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event )
 
 void DIALOG_PRINT_USING_PRINTER::OnSaveConfigClick( wxCommandEvent& event )
 {
-        wxFileDialog *SaveDialog = new wxFileDialog(
-                this, _("Save File As _?"), wxEmptyString, wxEmptyString,_("Ini files (*.ini)|*.ini"),
-wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition);
- 
-        // Creates a Save Dialog with 4 file types
-        if (SaveDialog->ShowModal() == wxID_OK) // If the user clicked "OK"
-        {       wxString CurrentDocPath;
-
-                CurrentDocPath = SaveDialog->GetPath();
-                wxFileConfig* PrintConfigFile = new wxFileConfig("", "",CurrentDocPath);
-                wxLogMessage( wxT("creating inifile: %s"), CurrentDocPath );
-                PrintConfigFile->Write(wxT("PrintConfig/PrintMirror"), m_Print_Mirror->GetValue());
-                PrintConfigFile->Write(wxT("PrintConfig/PrintSheetRef"), m_Print_Sheet_Ref->GetValue());
-                PrintConfigFile->Write(wxT("PrintConfig/PrintBW"),  (m_ModeColorOption->GetSelection()!= 0));
-                PrintConfigFile->Write(wxT("PrintConfig/DrillShapeOpt"), m_Drill_Shape_Opt->GetSelection());
-                PrintConfigFile->Write(wxT("PrintConfig/OptionPrintPage"),  (m_PagesOption->GetSelection() != 0));
-
-                int idx = m_ScaleOption->GetSelection();
-                PrintConfigFile->Write(wxT("PrintConfig/PrintScale"), s_ScaleList[idx]); 
-                PrintConfigFile->Write(wxT("PrintConfig/XFineScaleAdjust"),m_FineAdjustXscaleOpt->GetValue());
-                PrintConfigFile->Write(wxT("PrintConfig/YFineScaleAdjust"),m_FineAdjustYscaleOpt->GetValue());
-
-                for( unsigned ii = 0; ii < DIM(m_boxSelectLayer); ++ii )
-                {       wxString s1=wxT("PrintConfig/Layer");
-                        wxString s3=wxT("Selected");
-                        wxString s2= std::to_string(ii);
-                        if( !m_boxSelectLayer[ii].first )
-                            continue;
-                        PrintConfigFile->Write(s1+s2+s3,
-                                                m_boxSelectLayer[ii].first->IsChecked( m_boxSelectLayer[ii].second ) );
-                }
-
-                PrintConfigFile->Flush();
-                delete PrintConfigFile;
+    wxFileDialog* saveDialog = new wxFileDialog(
+            this,
+            _( "Save File As _?" ),
+            wxEmptyString, wxEmptyString,
+            _( "Ini files (*.ini)|*.ini" ),
+            wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
+            wxDefaultPosition );
+
+    if( saveDialog->ShowModal() == wxID_OK )     // If the user clicked "OK"
+    {
+        wxString currentDocPath;
+        currentDocPath = saveDialog->GetPath();
+        wxFileConfig* printConfigFile = new wxFileConfig( "", "", currentDocPath );
+        // wxLogMessage( wxT("creating inifile: %s"), currentDocPath );
+        printConfigFile->Write( wxT( "PrintConfig/PrintMirror" ), m_Print_Mirror->GetValue() );
+        printConfigFile->Write( wxT( "PrintConfig/PrintSheetRef" ), m_Print_Sheet_Ref->GetValue() );
+        printConfigFile->Write( wxT( "PrintConfig/PrintBW" ),
+                (m_ModeColorOption->GetSelection()!= 0) );
+        printConfigFile->Write( wxT( "PrintConfig/DrillShapeOpt" ),
+                m_Drill_Shape_Opt->GetSelection() );
+        printConfigFile->Write( wxT( "PrintConfig/OptionPrintPage" ),
+                (m_PagesOption->GetSelection() != 0) );
+
+        {
+            int idx = m_ScaleOption->GetSelection();
+            printConfigFile->Write( wxT( "PrintConfig/PrintScale" ), s_ScaleList[idx] );
+        }
+        printConfigFile->Write( wxT(
+                        "PrintConfig/XFineScaleAdjust" ), m_FineAdjustXscaleOpt->GetValue() );
+        printConfigFile->Write( wxT( "PrintConfig/YFineScaleAdjust" ),
+                                m_FineAdjustYscaleOpt->GetValue() );
+
+        for( unsigned ii = 0; ii < DIM( m_boxSelectLayer ); ++ii )
+        {
+            wxString s1 = wxT( "PrintConfig/Layer" );
+            wxString s2 = std::to_string( ii );
+            wxString s3 = wxT( "Selected" );
+
+            if( !m_boxSelectLayer[ii].first )
+                continue;
+
+            printConfigFile->Write( s1+s2+s3,
+            m_boxSelectLayer[ii].first->IsChecked( m_boxSelectLayer[ii].second ) );
+        }// for
+                printConfigFile->Flush();
+                delete printConfigFile;
         } //OK clicked.
-        // Clean up after ourselves
-        SaveDialog->Destroy();
+        saveDialog->Destroy(); // Clean up after ourselves
 }
 
-//template <typename T,unsigned S>
-//inline unsigned arraysize(const T (&v)[S]) { return S; }
-
 
 void DIALOG_PRINT_USING_PRINTER::OnLoadConfigClick( wxCommandEvent& event )
-{       wxString CurrentDocPath;
-        wxFileDialog *OpenDialog = new wxFileDialog(
-        this, _("Choose a file to open"), wxEmptyString, wxEmptyString,
-                _("Ini (*.ini)|*.ini"),
-                wxFD_OPEN, wxDefaultPosition);
-
-        // Creates a "open file" dialog with 4 file types
-        if (OpenDialog->ShowModal() == wxID_OK) // if the user click "Open" instead of "cancel"
+{
+    wxString currentDocPath;
+    wxFileDialog* openDialog = new wxFileDialog(
+            this,
+            _( "Open print configuration file" ),
+            wxEmptyString,
+            wxEmptyString,
+            _( "Ini (*.ini)|*.ini" ),
+            wxFD_OPEN,
+            wxDefaultPosition );
+
+    if( openDialog->ShowModal() == wxID_OK )      // if the user clicks "Open"
+    {
+        currentDocPath = openDialog->GetPath();
+        wxString    ReadString;
+        bool    val;
+        int     ival;
+        double  dval;
+        wxFileConfig* printConfigFile = new wxFileConfig( "", "",
+                currentDocPath, "",
+                wxCONFIG_USE_RELATIVE_PATH );
+        printConfigFile->Read( "Printconfig/PrintMirror", &val );
+        m_Print_Mirror->SetValue( val );
+
+        printConfigFile->Read( "PrintConfig/PrintSheetRef", &val );
+        m_Print_Sheet_Ref->SetValue( val );
+
+        printConfigFile->Read( "PrintConfig/PrintBW", &val );
+
+        if( val )
+            m_ModeColorOption->SetSelection( 1 );
+        else
+            m_ModeColorOption->SetSelection( 0 );
+
+        printConfigFile->Read( "PrintConfig/DrillShapeOpt", &ival );
+        m_Drill_Shape_Opt->SetSelection( ival );
+        printConfigFile->Read( "PrintConfig/OptionPrintPage", &ival );
+        m_PagesOption->SetSelection( ival==0 );
+
+        printConfigFile->Read( "PrintConfig/PrintScale", &dval );
+
+        for( unsigned ii = 0; ii<DIM( s_ScaleList ); ii++ )
+        {
+            // If the saved scale is not found in the list, silently ignore.
+            if( s_ScaleList[ii]==dval )
+            {
+                m_ScaleOption->SetSelection( ii );
+                break;
+            }
+        }
+
+        printConfigFile->Read( "PrintConfig/XFineScaleAdjust", &dval );
+        {
+            std::ostringstream strs;
+            strs << dval;
+            std::string str = strs.str();
+            m_FineAdjustXscaleOpt->SetValue( str );
+        }
+        printConfigFile->Read( "PrintConfig/YFineScaleAdjust", &dval );
+        {
+            std::ostringstream strs;
+            strs << dval;
+            std::string str = strs.str();
+            m_FineAdjustYscaleOpt->SetValue( str );
+        }
+
+        for( unsigned ii = 0; ii < DIM( m_boxSelectLayer ); ++ii )
         {
-                CurrentDocPath = OpenDialog->GetPath();
-                wxString ReadString;
-                 bool val;
-                 int ival;
-                 double dval;
-                 wxFileConfig* PrintConfigFile = new wxFileConfig("", "",
-                                                        CurrentDocPath, "",    
-                                                        wxCONFIG_USE_RELATIVE_PATH);
-                PrintConfigFile->Read("Printconfig/PrintMirror", &val);
-                m_Print_Mirror->SetValue(val);
-
-                PrintConfigFile->Read("PrintConfig/PrintSheetRef", &val);
-                m_Print_Sheet_Ref->SetValue(val);
-
-                PrintConfigFile->Read("PrintConfig/PrintBW",&val);
-
-                if (val)
-                        m_ModeColorOption->SetSelection(1);
-                else
-                         m_ModeColorOption->SetSelection(0);
-                PrintConfigFile->Read("PrintConfig/DrillShapeOpt", &ival);
-                m_Drill_Shape_Opt->SetSelection(ival);
-                PrintConfigFile->Read("PrintConfig/OptionPrintPage", &ival);
-                m_PagesOption->SetSelection(ival==0);
-
-                PrintConfigFile->Read("PrintConfig/PrintScale", &dval);
-
-                for (unsigned ii=0; ii<DIM(s_ScaleList); ii++)
-                {       // If the saved scale is not found in the list, silently ignore the value.
-                       if (s_ScaleList[ii]==dval)
-                        {       m_ScaleOption->SetSelection(ii);
-                                break;
-                        }
-                }
-
-                PrintConfigFile->Read("PrintConfig/XFineScaleAdjust", &dval);
-                {       std::ostringstream strs;
-                        strs << dval;
-                        std::string str = strs.str();
-                        m_FineAdjustXscaleOpt->SetValue(str);
-                }
-                PrintConfigFile->Read("PrintConfig/YFineScaleAdjust", &dval);
-                {       std::ostringstream strs;
-                        strs << dval;
-                        std::string str = strs.str();
-                        m_FineAdjustYscaleOpt->SetValue(str);
-                }
-
-                for( unsigned ii = 0; ii < DIM(m_boxSelectLayer); ++ii )
-                {       wxString s1=wxT("PrintConfig/Layer");
-                        wxString s2= std::to_string(ii);
-                        wxString s3=wxT("Selected");
-
-                        if( !m_boxSelectLayer[ii].first )
-                            continue;
-                        PrintConfigFile->Read(s1+s2+s3, &val);
-                        m_boxSelectLayer[ii].first->Check( m_boxSelectLayer[ii].second , val);
-                }
-
-                delete PrintConfigFile;
-        } //OK clicked on file selection dialog.
-} //OnLoadConfigClick
+            wxString s1 = wxT( "PrintConfig/Layer" );
+            wxString s2 = std::to_string( ii );
+            wxString s3 = wxT( "Selected" );
+
+            if( !m_boxSelectLayer[ii].first )
+                continue;
+
+            printConfigFile->Read( s1 + s2 + s3, &val );
+            m_boxSelectLayer[ii].first->Check( m_boxSelectLayer[ii].second, val );
+        }
+
+        delete printConfigFile;
+    }   // OK clicked on file selection dialog.
+}       // OnLoadConfigClick

--------------2.1.4--



Follow ups