/////////////////////////////////////////////////////////////////////////////
// Name:        dialog_gendrill.cpp
// Purpose:
// Author:      jean-pierre Charras
// Modified by:
// Created:     13/01/2008 17:26:27
// RCS-ID:
// Copyright:   License GNU
// Licence:
/////////////////////////////////////////////////////////////////////////////

// Generated by DialogBlocks (unregistered), 13/01/2008 17:26:27

// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"

#ifdef __BORLANDC__
#pragma hdrstop
#endif

#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif

////@begin includes
////@end includes

#include "dialog_gendrill.h"

////@begin XPM images
////@end XPM images


/*!
 * WinEDA_DrillFrame type definition
 */

IMPLEMENT_DYNAMIC_CLASS( WinEDA_DrillFrame, wxDialog )


/*!
 * WinEDA_DrillFrame event table definition
 */

BEGIN_EVENT_TABLE( WinEDA_DrillFrame, wxDialog )

////@begin WinEDA_DrillFrame event table entries
    EVT_CLOSE( WinEDA_DrillFrame::OnCloseWindow )

    EVT_RADIOBOX( ID_SEL_DRILL_UNITS, WinEDA_DrillFrame::OnSelDrillUnitsSelected )

    EVT_RADIOBOX( ID_SEL_ZEROS_FMT, WinEDA_DrillFrame::OnSelZerosFmtSelected )

    EVT_BUTTON( wxID_OK, WinEDA_DrillFrame::OnOkClick )

    EVT_BUTTON( wxID_CANCEL, WinEDA_DrillFrame::OnCancelClick )

////@end WinEDA_DrillFrame event table entries

END_EVENT_TABLE()


/*!
 * WinEDA_DrillFrame constructors
 */

WinEDA_DrillFrame::WinEDA_DrillFrame()
{
    Init();
}

WinEDA_DrillFrame::WinEDA_DrillFrame( WinEDA_PcbFrame* parent, wxWindowID id,
    const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
    m_Parent = parent;
    //SetFont( *g_DialogFont );

    SetReturnCode( 1 );
    Init();
    Create(parent, id, caption, pos, size, style);
}


/*!
 * WinEDA_DrillFrame creator
 */

bool WinEDA_DrillFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
////@begin WinEDA_DrillFrame creation
    SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
    wxDialog::Create( parent, id, caption, pos, size, style );

    CreateControls();
    if (GetSizer())
    {
        GetSizer()->SetSizeHints(this);
    }
    Centre();
////@end WinEDA_DrillFrame creation
    return true;
}


/*!
 * WinEDA_DrillFrame destructor
 */

WinEDA_DrillFrame::~WinEDA_DrillFrame()
{
////@begin WinEDA_DrillFrame destruction
////@end WinEDA_DrillFrame destruction
}


/*!
 * Member initialisation
 */

void WinEDA_DrillFrame::Init()
{
////@begin WinEDA_DrillFrame member initialisation
    m_LeftBoxSizer = NULL;
    m_Choice_Unit = NULL;
    m_Choice_Zeros_Format = NULL;
    m_Choice_Precision = NULL;
    m_Choice_Drill_Offset = NULL;
    m_Choice_Drill_Map = NULL;
    m_Choice_Drill_Report = NULL;
    m_PenSpeed = NULL;
    m_PenNum = NULL;
    m_Check_Mirror = NULL;
    m_Check_Minimal = NULL;
    m_DefaultViasDrillSizer = NULL;
    m_ViaDrillValue = NULL;
    m_MicroViasDrillSizer = NULL;
    m_MicroViaDrillValue = NULL;
    m_PadsCountInfoMsg = NULL;
    m_ThroughViasInfoMsg = NULL;
    m_MicroViasInfoMsg = NULL;
    m_BuriedViasInfoMsg = NULL;
    m_OkButton = NULL;
    m_CancelButton = NULL;
////@end WinEDA_DrillFrame member initialisation
}


/*!
 * Control creation for WinEDA_DrillFrame
 */

void WinEDA_DrillFrame::CreateControls()
{
////@begin WinEDA_DrillFrame content construction
    // Generated by DialogBlocks, 12/08/2008 13:05:18 (unregistered)

    WinEDA_DrillFrame* itemDialog1 = this;

    wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
    itemDialog1->SetSizer(itemBoxSizer2);

    m_LeftBoxSizer = new wxBoxSizer(wxVERTICAL);
    itemBoxSizer2->Add(m_LeftBoxSizer, 0, wxGROW|wxALL, 5);

    wxArrayString m_Choice_UnitStrings;
    m_Choice_UnitStrings.Add(_("Millimeters"));
    m_Choice_UnitStrings.Add(_("Inches"));
    m_Choice_Unit = new wxRadioBox( itemDialog1, ID_SEL_DRILL_UNITS, _("Drill Units:"), wxDefaultPosition, wxDefaultSize, m_Choice_UnitStrings, 1, wxRA_SPECIFY_COLS );
    m_Choice_Unit->SetSelection(0);
    m_LeftBoxSizer->Add(m_Choice_Unit, 0, wxGROW|wxALL, 5);

    wxArrayString m_Choice_Zeros_FormatStrings;
    m_Choice_Zeros_FormatStrings.Add(_("decimal format"));
    m_Choice_Zeros_FormatStrings.Add(_("suppress leading zeros"));
    m_Choice_Zeros_FormatStrings.Add(_("suppress trailing zeros"));
    m_Choice_Zeros_FormatStrings.Add(_("keep zeros"));
    m_Choice_Zeros_Format = new wxRadioBox( itemDialog1, ID_SEL_ZEROS_FMT, _("Zeros Format"), wxDefaultPosition, wxDefaultSize, m_Choice_Zeros_FormatStrings, 1, wxRA_SPECIFY_COLS );
    m_Choice_Zeros_Format->SetSelection(0);
    if (WinEDA_DrillFrame::ShowToolTips())
        m_Choice_Zeros_Format->SetToolTip(_("Choose excellon numbers notation"));
    m_LeftBoxSizer->Add(m_Choice_Zeros_Format, 0, wxALIGN_LEFT|wxALL, 5);

    wxArrayString m_Choice_PrecisionStrings;
    m_Choice_PrecisionStrings.Add(_("2:3"));
    m_Choice_PrecisionStrings.Add(_("2:4"));
    m_Choice_Precision = new wxRadioBox( itemDialog1, ID_SEL_PRECISION, _("Precision"), wxDefaultPosition, wxDefaultSize, m_Choice_PrecisionStrings, 1, wxRA_SPECIFY_COLS );
    m_Choice_Precision->SetSelection(0);
    if (WinEDA_DrillFrame::ShowToolTips())
        m_Choice_Precision->SetToolTip(_("Choose excellon numbers precision"));
    m_LeftBoxSizer->Add(m_Choice_Precision, 0, wxGROW|wxALL, 5);

    wxArrayString m_Choice_Drill_OffsetStrings;
    m_Choice_Drill_OffsetStrings.Add(_("absolute"));
    m_Choice_Drill_OffsetStrings.Add(_("auxiliary axis"));
    m_Choice_Drill_Offset = new wxRadioBox( itemDialog1, ID_SEL_DRILL_SHEET, _("Drill Origin:"), wxDefaultPosition, wxDefaultSize, m_Choice_Drill_OffsetStrings, 1, wxRA_SPECIFY_COLS );
    m_Choice_Drill_Offset->SetSelection(0);
    if (WinEDA_DrillFrame::ShowToolTips())
        m_Choice_Drill_Offset->SetToolTip(_("Choose the coordinate origin: absolute or relative to the auxiliray axis"));
    m_LeftBoxSizer->Add(m_Choice_Drill_Offset, 0, wxGROW|wxALL, 5);

    wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxVERTICAL);
    itemBoxSizer2->Add(itemBoxSizer8, 0, wxGROW|wxALL, 5);

    wxArrayString m_Choice_Drill_MapStrings;
    m_Choice_Drill_MapStrings.Add(_("None"));
    m_Choice_Drill_MapStrings.Add(_("drill sheet (HPGL)"));
    m_Choice_Drill_MapStrings.Add(_("drill sheet (PostScript)"));
    m_Choice_Drill_Map = new wxRadioBox( itemDialog1, ID_SEL_DRILL_SHEET, _("Drill Sheet:"), wxDefaultPosition, wxDefaultSize, m_Choice_Drill_MapStrings, 1, wxRA_SPECIFY_COLS );
    m_Choice_Drill_Map->SetSelection(0);
    if (WinEDA_DrillFrame::ShowToolTips())
        m_Choice_Drill_Map->SetToolTip(_("Creates a drill map in PS or HPGL format"));
    itemBoxSizer8->Add(m_Choice_Drill_Map, 0, wxGROW|wxALL, 5);

    wxArrayString m_Choice_Drill_ReportStrings;
    m_Choice_Drill_ReportStrings.Add(_("None"));
    m_Choice_Drill_ReportStrings.Add(_("Drill report"));
    m_Choice_Drill_Report = new wxRadioBox( itemDialog1, ID_SEL_DRILL_REPORT, _("Drill Report:"), wxDefaultPosition, wxDefaultSize, m_Choice_Drill_ReportStrings, 1, wxRA_SPECIFY_COLS );
    m_Choice_Drill_Report->SetSelection(0);
    if (WinEDA_DrillFrame::ShowToolTips())
        m_Choice_Drill_Report->SetToolTip(_("Creates a plain text report"));
    itemBoxSizer8->Add(m_Choice_Drill_Report, 0, wxGROW|wxALL, 5);

    wxStaticBox* itemStaticBoxSizer11Static = new wxStaticBox(itemDialog1, wxID_ANY, _("HPGL plotter Options:"));
    wxStaticBoxSizer* itemStaticBoxSizer11 = new wxStaticBoxSizer(itemStaticBoxSizer11Static, wxVERTICAL);
    itemBoxSizer8->Add(itemStaticBoxSizer11, 0, wxGROW|wxALL, 5);

    wxStaticText* itemStaticText12 = new wxStaticText( itemDialog1, wxID_STATIC, _("Speed (cm/s)"), wxDefaultPosition, wxDefaultSize, 0 );
    itemStaticBoxSizer11->Add(itemStaticText12, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5);

    m_PenSpeed = new wxTextCtrl( itemDialog1, ID_TEXTCTRL2, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
    itemStaticBoxSizer11->Add(m_PenSpeed, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);

    wxStaticText* itemStaticText14 = new wxStaticText( itemDialog1, wxID_STATIC, _("Pen Number"), wxDefaultPosition, wxDefaultSize, 0 );
    itemStaticBoxSizer11->Add(itemStaticText14, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5);

    m_PenNum = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
    itemStaticBoxSizer11->Add(m_PenNum, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);

    wxStaticBox* itemStaticBoxSizer16Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Options:"));
    wxStaticBoxSizer* itemStaticBoxSizer16 = new wxStaticBoxSizer(itemStaticBoxSizer16Static, wxVERTICAL);
    itemStaticBoxSizer11->Add(itemStaticBoxSizer16, 0, wxGROW|wxALL, 5);

    m_Check_Mirror = new wxCheckBox( itemDialog1, ID_CHECKBOX2, _("mirror y axis"), wxDefaultPosition, wxDefaultSize, 0 );
    m_Check_Mirror->SetValue(false);
    itemStaticBoxSizer16->Add(m_Check_Mirror, 0, wxGROW|wxALL, 5);

    m_Check_Minimal = new wxCheckBox( itemDialog1, ID_CHECKBOX3, _("minimal header"), wxDefaultPosition, wxDefaultSize, 0 );
    m_Check_Minimal->SetValue(false);
    if (WinEDA_DrillFrame::ShowToolTips())
        m_Check_Minimal->SetToolTip(_("If checked, the excellon header is minimal"));
    itemStaticBoxSizer16->Add(m_Check_Minimal, 0, wxGROW|wxALL, 5);

    wxBoxSizer* itemBoxSizer19 = new wxBoxSizer(wxVERTICAL);
    itemBoxSizer2->Add(itemBoxSizer19, 0, wxGROW|wxALL, 5);

    wxStaticBox* itemStaticBoxSizer20Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Info:"));
    wxStaticBoxSizer* itemStaticBoxSizer20 = new wxStaticBoxSizer(itemStaticBoxSizer20Static, wxVERTICAL);
    itemBoxSizer19->Add(itemStaticBoxSizer20, 0, wxGROW|wxALL, 5);

    m_DefaultViasDrillSizer = new wxStaticBox(itemDialog1, wxID_ANY, _("Default Vias Drill:"));
    wxStaticBoxSizer* itemStaticBoxSizer21 = new wxStaticBoxSizer(m_DefaultViasDrillSizer, wxVERTICAL);
    itemStaticBoxSizer20->Add(itemStaticBoxSizer21, 0, wxGROW|wxALL, 5);

    m_ViaDrillValue = new wxStaticText( itemDialog1, wxID_STATIC, _("Via Drill Value"), wxDefaultPosition, wxDefaultSize, 0 );
    itemStaticBoxSizer21->Add(m_ViaDrillValue, 0, wxGROW|wxALL, 5);

    m_MicroViasDrillSizer = new wxStaticBox(itemDialog1, wxID_ANY, _("Micro Vias Drill:"));
    wxStaticBoxSizer* itemStaticBoxSizer23 = new wxStaticBoxSizer(m_MicroViasDrillSizer, wxVERTICAL);
    itemStaticBoxSizer20->Add(itemStaticBoxSizer23, 0, wxGROW|wxALL, 5);

    m_MicroViaDrillValue = new wxStaticText( itemDialog1, wxID_STATIC, _("Micro Via Drill Value"), wxDefaultPosition, wxDefaultSize, 0 );
    itemStaticBoxSizer23->Add(m_MicroViaDrillValue, 0, wxGROW|wxALL, 5);

    wxStaticBox* itemStaticBoxSizer25Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Holes Count:"));
    wxStaticBoxSizer* itemStaticBoxSizer25 = new wxStaticBoxSizer(itemStaticBoxSizer25Static, wxVERTICAL);
    itemStaticBoxSizer20->Add(itemStaticBoxSizer25, 0, wxGROW|wxALL, 5);

    m_PadsCountInfoMsg = new wxStaticText( itemDialog1, wxID_STATIC, _("Pads:"), wxDefaultPosition, wxDefaultSize, 0 );
    itemStaticBoxSizer25->Add(m_PadsCountInfoMsg, 0, wxGROW|wxALL, 5);

    m_ThroughViasInfoMsg = new wxStaticText( itemDialog1, wxID_STATIC, _("Through Vias:"), wxDefaultPosition, wxDefaultSize, 0 );
    itemStaticBoxSizer25->Add(m_ThroughViasInfoMsg, 0, wxGROW|wxALL, 5);

    m_MicroViasInfoMsg = new wxStaticText( itemDialog1, wxID_STATIC, _("Micro Vias:"), wxDefaultPosition, wxDefaultSize, 0 );
    itemStaticBoxSizer25->Add(m_MicroViasInfoMsg, 0, wxGROW|wxALL, 5);

    m_BuriedViasInfoMsg = new wxStaticText( itemDialog1, wxID_STATIC, _("Buried Vias:"), wxDefaultPosition, wxDefaultSize, 0 );
    itemStaticBoxSizer25->Add(m_BuriedViasInfoMsg, 0, wxGROW|wxALL, 5);

    itemBoxSizer19->Add(5, 5, 1, wxGROW|wxALL, 5);

    m_OkButton = new wxButton( itemDialog1, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 );
    m_OkButton->SetDefault();
    m_OkButton->SetForegroundColour(wxColour(156, 1, 5));
    itemBoxSizer19->Add(m_OkButton, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);

    m_CancelButton = new wxButton( itemDialog1, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
    m_CancelButton->SetForegroundColour(wxColour(16, 1, 205));
    itemBoxSizer19->Add(m_CancelButton, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);

    // Set validators
    m_Choice_Unit->SetValidator( wxGenericValidator(& s_Unit_Drill_is_Inch) );
    m_Choice_Zeros_Format->SetValidator( wxGenericValidator(& s_Zeros_Format) );
    m_Check_Mirror->SetValidator( wxGenericValidator(& Mirror) );
    m_Check_Minimal->SetValidator( wxGenericValidator(& Minimal) );
////@end WinEDA_DrillFrame content construction

    SetFocus(); // Under wxGTK: mandatory to close dialog by the ESC key
	InitDisplayParams();
}


/*!
 * wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_RADIOBOX
 */

void WinEDA_DrillFrame::OnSelDrillUnitsSelected( wxCommandEvent& event )
{
	UpdatePrecisionOptions(event);
}


/*!
 * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
 */

void WinEDA_DrillFrame::OnOkClick( wxCommandEvent& event )
{
	GenDrillFiles(event);
}


/*!
 * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE
 */

void WinEDA_DrillFrame::OnCancelClick( wxCommandEvent& event )
{
    UpdateConfig();     /* Save drill options: */
    event.Skip();       // Process the default cancel event (close dialog)
}


/*!
 * Should we show tooltips?
 */

bool WinEDA_DrillFrame::ShowToolTips()
{
    return true;
}

/*!
 * Get bitmap resources
 */

wxBitmap WinEDA_DrillFrame::GetBitmapResource( const wxString& name )
{
    // Bitmap retrieval
////@begin WinEDA_DrillFrame bitmap retrieval
    wxUnusedVar(name);
    return wxNullBitmap;
////@end WinEDA_DrillFrame bitmap retrieval
}

/*!
 * Get icon resources
 */

wxIcon WinEDA_DrillFrame::GetIconResource( const wxString& name )
{
    // Icon retrieval
////@begin WinEDA_DrillFrame icon retrieval
    wxUnusedVar(name);
    return wxNullIcon;
////@end WinEDA_DrillFrame icon retrieval
}


/*!
 * wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_SEL_ZEROS_FMT
 */

void WinEDA_DrillFrame::OnSelZerosFmtSelected( wxCommandEvent& event )
{
	UpdatePrecisionOptions(event);
}


/*!
 * wxEVT_CLOSE_WINDOW event handler for ID_WINEDA_DRILLFRAME
 */

void WinEDA_DrillFrame::OnCloseWindow( wxCloseEvent& event )
{
////@begin wxEVT_CLOSE_WINDOW event handler for ID_WINEDA_DRILLFRAME in WinEDA_DrillFrame.
    // Before editing this code, remove the block markers.
    event.Skip();
////@end wxEVT_CLOSE_WINDOW event handler for ID_WINEDA_DRILLFRAME in WinEDA_DrillFrame.
}