/////////////////////////////////////////////////////////////////////////////
// Name:        dialog_pad_edit.cpp
// Purpose:     
// Author:      jean-pierre Charras
// Modified by: 
// Created:     28/02/2006 13:34:48
// RCS-ID:      
// Copyright:   License GNU
// Licence:     
/////////////////////////////////////////////////////////////////////////////

// Generated by DialogBlocks (unregistered), 28/02/2006 13:34:48

#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "dialog_pad_edit.h"
#endif

// 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_pad_edit.h"

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

/*!
 * WinEDA_PadPropertiesFrame type definition
 */

IMPLEMENT_DYNAMIC_CLASS( WinEDA_PadPropertiesFrame, wxDialog )

/*!
 * WinEDA_PadPropertiesFrame event table definition
 */

BEGIN_EVENT_TABLE( WinEDA_PadPropertiesFrame, wxDialog )

////@begin WinEDA_PadPropertiesFrame event table entries
    EVT_RADIOBOX( ID_LISTBOX_ORIENT_PAD, WinEDA_PadPropertiesFrame::OnListboxOrientPadSelected )

    EVT_RADIOBOX( ID_LISTBOX_SHAPE_PAD, WinEDA_PadPropertiesFrame::OnListboxShapePadSelected )

    EVT_RADIOBOX( ID_LISTBOX_TYPE_PAD, WinEDA_PadPropertiesFrame::OnListboxTypePadSelected )

    EVT_BUTTON( wxID_OK, WinEDA_PadPropertiesFrame::OnOkClick )

    EVT_BUTTON( wxID_CANCEL, WinEDA_PadPropertiesFrame::OnCancelClick )

////@end WinEDA_PadPropertiesFrame event table entries

END_EVENT_TABLE()

/*!
 * WinEDA_PadPropertiesFrame constructors
 */

WinEDA_PadPropertiesFrame::WinEDA_PadPropertiesFrame( )
{
}

WinEDA_PadPropertiesFrame::WinEDA_PadPropertiesFrame( WinEDA_BasePcbFrame* parent,
            D_PAD * Pad,wxDC * DC,
            wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
	m_Parent = parent;
	m_DC = DC;
	m_Module = NULL;
	CurrentPad = Pad;

	if ( CurrentPad )
	{
		Current_PadNetName = CurrentPad->m_Netname;
		g_Current_PadName = CurrentPad->ReturnStringPadName();
		m_Module = (MODULE*) CurrentPad->m_Parent;
	}

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

/*!
 * WinEDA_PadPropertiesFrame creator
 */

bool WinEDA_PadPropertiesFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
////@begin WinEDA_PadPropertiesFrame member initialisation
    m_LeftBoxSizer = NULL;
    m_PadNumCtrl = NULL;
    m_PadNetNameCtrl = NULL;
    m_PadPositionBoxSizer = NULL;
    m_PadSizeBoxSizer = NULL;
    m_PadDeltaBoxSizer = NULL;
    m_PadOffsetBoxSizer = NULL;
    m_PadOrient = NULL;
    m_PadShape = NULL;
    m_PadType = NULL;
    m_PadLayerCu = NULL;
    m_PadLayerCmp = NULL;
    m_PadLayerAdhCmp = NULL;
    m_PadLayerAdhCu = NULL;
    m_PadLayerPateCmp = NULL;
    m_PadLayerPateCu = NULL;
    m_PadLayerSilkCmp = NULL;
    m_PadLayerSilkCu = NULL;
    m_PadLayerMaskCmp = NULL;
    m_PadLayerMaskCu = NULL;
    m_PadLayerECO1 = NULL;
    m_PadLayerECO2 = NULL;
    m_PadLayerDraft = NULL;
////@end WinEDA_PadPropertiesFrame member initialisation

////@begin WinEDA_PadPropertiesFrame creation
    SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS);
    wxDialog::Create( parent, id, caption, pos, size, style );

    CreateControls();
    GetSizer()->Fit(this);
    GetSizer()->SetSizeHints(this);
    Centre();
////@end WinEDA_PadPropertiesFrame creation
    return true;
}

/*!
 * Control creation for WinEDA_PadPropertiesFrame
 */

void WinEDA_PadPropertiesFrame::CreateControls()
{    
	SetFont(*g_DialogFont);
////@begin WinEDA_PadPropertiesFrame content construction
    // Generated by DialogBlocks, 30/05/2006 08:38:02 (unregistered)

    WinEDA_PadPropertiesFrame* itemDialog1 = this;

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

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

    wxStaticText* itemStaticText4 = new wxStaticText( itemDialog1, wxID_STATIC, _("Pad Num :"), wxDefaultPosition, wxDefaultSize, 0 );
    m_LeftBoxSizer->Add(itemStaticText4, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);

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

    wxStaticText* itemStaticText6 = new wxStaticText( itemDialog1, wxID_STATIC, _("Pad Net Name :"), wxDefaultPosition, wxDefaultSize, 0 );
    m_LeftBoxSizer->Add(itemStaticText6, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);

    m_PadNetNameCtrl = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
    m_LeftBoxSizer->Add(m_PadNetNameCtrl, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);

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

    m_PadSizeBoxSizer = new wxBoxSizer(wxVERTICAL);
    m_LeftBoxSizer->Add(m_PadSizeBoxSizer, 0, wxGROW|wxTOP|wxBOTTOM, 5);

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

    m_PadOffsetBoxSizer = new wxBoxSizer(wxVERTICAL);
    m_LeftBoxSizer->Add(m_PadOffsetBoxSizer, 0, wxGROW|wxTOP|wxBOTTOM, 5);

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

    wxString m_PadOrientStrings[] = {
        _("0"),
        _("90"),
        _("-90"),
        _("180"),
        _("User")
    };
    m_PadOrient = new wxRadioBox( itemDialog1, ID_LISTBOX_ORIENT_PAD, _("Pad Orient:"), wxDefaultPosition, wxDefaultSize, 5, m_PadOrientStrings, 1, wxRA_SPECIFY_COLS );
    itemBoxSizer12->Add(m_PadOrient, 0, wxGROW|wxALL, 5);

    wxString m_PadShapeStrings[] = {
        _("Circle"),
        _("Oval"),
        _("Rect"),
        _("Trapeze")
    };
    m_PadShape = new wxRadioBox( itemDialog1, ID_LISTBOX_SHAPE_PAD, _("Pad Shape:"), wxDefaultPosition, wxDefaultSize, 4, m_PadShapeStrings, 1, wxRA_SPECIFY_COLS );
    itemBoxSizer12->Add(m_PadShape, 0, wxGROW|wxALL, 5);

    wxString m_PadTypeStrings[] = {
        _("Standard"),
        _("SMD"),
        _("Conn"),
        _("Hole"),
        _("Mechanical")
    };
    m_PadType = new wxRadioBox( itemDialog1, ID_LISTBOX_TYPE_PAD, _("Pad Type:"), wxDefaultPosition, wxDefaultSize, 5, m_PadTypeStrings, 1, wxRA_SPECIFY_COLS );
    itemBoxSizer12->Add(m_PadType, 0, wxGROW|wxALL, 5);

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

    wxButton* itemButton17 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
    itemButton17->SetForegroundColour(wxColour(204, 0, 0));
    itemBoxSizer16->Add(itemButton17, 0, wxGROW|wxALL, 5);

    wxButton* itemButton18 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
    itemButton18->SetForegroundColour(wxColour(0, 0, 255));
    itemBoxSizer16->Add(itemButton18, 0, wxGROW|wxALL, 5);

    wxStaticBox* itemStaticBoxSizer19Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Layers:"));
    wxStaticBoxSizer* itemStaticBoxSizer19 = new wxStaticBoxSizer(itemStaticBoxSizer19Static, wxVERTICAL);
    itemBoxSizer16->Add(itemStaticBoxSizer19, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);

    m_PadLayerCu = new wxCheckBox( itemDialog1, ID_CHECKBOX, _("Copper layer"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
    m_PadLayerCu->SetValue(false);
    itemStaticBoxSizer19->Add(m_PadLayerCu, 0, wxGROW|wxALL, 5);

    m_PadLayerCmp = new wxCheckBox( itemDialog1, ID_CHECKBOX1, _("Comp layer"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
    m_PadLayerCmp->SetValue(false);
    itemStaticBoxSizer19->Add(m_PadLayerCmp, 0, wxGROW|wxALL, 5);

    itemStaticBoxSizer19->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);

    m_PadLayerAdhCmp = new wxCheckBox( itemDialog1, ID_CHECKBOX2, _("Adhesive Cmp"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
    m_PadLayerAdhCmp->SetValue(false);
    itemStaticBoxSizer19->Add(m_PadLayerAdhCmp, 0, wxGROW|wxALL, 5);

    m_PadLayerAdhCu = new wxCheckBox( itemDialog1, ID_CHECKBOX3, _("Adhesive Copper"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
    m_PadLayerAdhCu->SetValue(false);
    itemStaticBoxSizer19->Add(m_PadLayerAdhCu, 0, wxGROW|wxALL, 5);

    m_PadLayerPateCmp = new wxCheckBox( itemDialog1, ID_CHECKBOX4, _("Solder paste Cmp"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
    m_PadLayerPateCmp->SetValue(false);
    itemStaticBoxSizer19->Add(m_PadLayerPateCmp, 0, wxGROW|wxALL, 5);

    m_PadLayerPateCu = new wxCheckBox( itemDialog1, ID_CHECKBOX5, _("Solder paste Copper"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
    m_PadLayerPateCu->SetValue(false);
    itemStaticBoxSizer19->Add(m_PadLayerPateCu, 0, wxGROW|wxALL, 5);

    m_PadLayerSilkCmp = new wxCheckBox( itemDialog1, ID_CHECKBOX6, _("Silkscreen Cmp"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
    m_PadLayerSilkCmp->SetValue(false);
    itemStaticBoxSizer19->Add(m_PadLayerSilkCmp, 0, wxGROW|wxALL, 5);

    m_PadLayerSilkCu = new wxCheckBox( itemDialog1, ID_CHECKBOX7, _("Silkscreen Copper"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
    m_PadLayerSilkCu->SetValue(false);
    itemStaticBoxSizer19->Add(m_PadLayerSilkCu, 0, wxGROW|wxALL, 5);

    m_PadLayerMaskCmp = new wxCheckBox( itemDialog1, ID_CHECKBOX8, _("Solder mask Cmp"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
    m_PadLayerMaskCmp->SetValue(false);
    itemStaticBoxSizer19->Add(m_PadLayerMaskCmp, 0, wxGROW|wxALL, 5);

    m_PadLayerMaskCu = new wxCheckBox( itemDialog1, ID_CHECKBOX9, _("Solder mask Copper"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
    m_PadLayerMaskCu->SetValue(false);
    itemStaticBoxSizer19->Add(m_PadLayerMaskCu, 0, wxGROW|wxALL, 5);

    m_PadLayerECO1 = new wxCheckBox( itemDialog1, ID_CHECKBOX10, _("E.C.O.1 layer"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
    m_PadLayerECO1->SetValue(false);
    itemStaticBoxSizer19->Add(m_PadLayerECO1, 0, wxGROW|wxALL, 5);

    m_PadLayerECO2 = new wxCheckBox( itemDialog1, ID_CHECKBOX11, _("E.C.O.2 layer"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
    m_PadLayerECO2->SetValue(false);
    itemStaticBoxSizer19->Add(m_PadLayerECO2, 0, wxGROW|wxALL, 5);

    m_PadLayerDraft = new wxCheckBox( itemDialog1, ID_CHECKBOX12, _("Draft layer"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
    m_PadLayerDraft->SetValue(false);
    itemStaticBoxSizer19->Add(m_PadLayerDraft, 0, wxGROW|wxALL, 5);

////@end WinEDA_PadPropertiesFrame content construction

	SetOthersControls();
}

/*!
 * Should we show tooltips?
 */

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

/*!
 * Get bitmap resources
 */

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

/*!
 * Get icon resources
 */

wxIcon WinEDA_PadPropertiesFrame::GetIconResource( const wxString& name )
{
    // Icon retrieval
////@begin WinEDA_PadPropertiesFrame icon retrieval
    wxUnusedVar(name);
    return wxNullIcon;
////@end WinEDA_PadPropertiesFrame icon retrieval
}
/*!
 * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
 */

void WinEDA_PadPropertiesFrame::OnOkClick( wxCommandEvent& event )
{
	PadPropertiesAccept(event);
}

/*!
 * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
 */

void WinEDA_PadPropertiesFrame::OnCancelClick( wxCommandEvent& event )
{
////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_PadPropertiesFrame.
    // Before editing this code, remove the block markers.
    event.Skip();
////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL in WinEDA_PadPropertiesFrame. 
}


/*!
 * wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_LISTBOX_ORIENT_PAD
 */

void WinEDA_PadPropertiesFrame::OnListboxOrientPadSelected( wxCommandEvent& event )
{
	PadOrientEvent(event);
}

/*!
 * wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_LISTBOX_SHAPE_PAD
 */

void WinEDA_PadPropertiesFrame::OnListboxShapePadSelected( wxCommandEvent& event )
{
////@begin wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_LISTBOX_SHAPE_PAD in WinEDA_PadPropertiesFrame.
    // Before editing this code, remove the block markers.
    event.Skip();
////@end wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_LISTBOX_SHAPE_PAD in WinEDA_PadPropertiesFrame. 
}

/*!
 * wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_LISTBOX_TYPE_PAD
 */

void WinEDA_PadPropertiesFrame::OnListboxTypePadSelected( wxCommandEvent& event )
{
	PadTypeSelectedEvent(event);
}


