/////////////////////////////////////////////////////////////////////////////
// Name:        dialog_display_options.cpp
// Purpose:     
// Author:      jean-pierre Charras
// Modified by: 
// Created:     17/02/2006 17:47:55
// RCS-ID:      
// Copyright:   License GNU
// Licence:     
/////////////////////////////////////////////////////////////////////////////

// Generated by DialogBlocks (unregistered), 17/02/2006 17:47:55

#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "dialog_display_options.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 "fctsys.h"

#include "wxstruct.h"
#include "common.h"
#include "cvpcb.h"
#include "protos.h"

#include "dialog_display_options.h"

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


/*********************************************************************/
void WinEDA_DisplayFrame::InstallOptionsDisplay(wxCommandEvent& event)
/*********************************************************************/
/* Creation de la fenetre d'options de la fenetre de visu */
{
	WinEDA_FootprintDisplayOptionsFrame * OptionWindow = new WinEDA_FootprintDisplayOptionsFrame(this);
	OptionWindow->ShowModal();
	OptionWindow->Destroy();
}



/*!
 * WinEDA_FootprintDisplayOptionsFrame type definition
 */

IMPLEMENT_DYNAMIC_CLASS( WinEDA_FootprintDisplayOptionsFrame, wxDialog )

/*!
 * WinEDA_FootprintDisplayOptionsFrame event table definition
 */

BEGIN_EVENT_TABLE( WinEDA_FootprintDisplayOptionsFrame, wxDialog )

////@begin WinEDA_FootprintDisplayOptionsFrame event table entries
    EVT_BUTTON( ID_SAVE_CONFIG, WinEDA_FootprintDisplayOptionsFrame::OnSaveConfigClick )

    EVT_BUTTON( wxID_OK, WinEDA_FootprintDisplayOptionsFrame::OnOkClick )

    EVT_BUTTON( wxID_CANCEL, WinEDA_FootprintDisplayOptionsFrame::OnCancelClick )

    EVT_BUTTON( wxID_APPLY, WinEDA_FootprintDisplayOptionsFrame::OnApplyClick )

////@end WinEDA_FootprintDisplayOptionsFrame event table entries

END_EVENT_TABLE()

/*!
 * WinEDA_FootprintDisplayOptionsFrame constructors
 */

WinEDA_FootprintDisplayOptionsFrame::WinEDA_FootprintDisplayOptionsFrame( )
{
}

WinEDA_FootprintDisplayOptionsFrame::WinEDA_FootprintDisplayOptionsFrame( WinEDA_BasePcbFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
	m_Parent = parent;

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

/*!
 * WinEDA_FootprintDisplayOptionsFrame creator
 */

bool WinEDA_FootprintDisplayOptionsFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
////@begin WinEDA_FootprintDisplayOptionsFrame member initialisation
    OuterBoxSizer = NULL;
    MainBoxSizer = NULL;
    m_EdgesDisplayOption = NULL;
    m_TextDisplayOption = NULL;
    ColumnBoxSizer = NULL;
    m_IsShowPadFill = NULL;
    m_IsShowPadNum = NULL;
    BottomBoxSizer = NULL;
////@end WinEDA_FootprintDisplayOptionsFrame member initialisation

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

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

/*!
 * Control creation for WinEDA_FootprintDisplayOptionsFrame
 */

void WinEDA_FootprintDisplayOptionsFrame::CreateControls()
{    
	SetFont(*g_DialogFont);

////@begin WinEDA_FootprintDisplayOptionsFrame content construction
    // Generated by DialogBlocks, 27/10/2007 09:57:04 (unregistered)

    WinEDA_FootprintDisplayOptionsFrame* itemDialog1 = this;

    OuterBoxSizer = new wxBoxSizer(wxVERTICAL);
    itemDialog1->SetSizer(OuterBoxSizer);

    MainBoxSizer = new wxBoxSizer(wxHORIZONTAL);
    OuterBoxSizer->Add(MainBoxSizer, 1, wxGROW|wxALL, 5);

    wxArrayString m_EdgesDisplayOptionStrings;
    m_EdgesDisplayOptionStrings.Add(_("&Line"));
    m_EdgesDisplayOptionStrings.Add(_("&Filled"));
    m_EdgesDisplayOptionStrings.Add(_("&Sketch"));
    m_EdgesDisplayOption = new wxRadioBox( itemDialog1, EDGE_SELECT, _("Edges:"), wxDefaultPosition, wxDefaultSize, m_EdgesDisplayOptionStrings, 1, wxRA_SPECIFY_COLS );
    m_EdgesDisplayOption->SetSelection(0);
    MainBoxSizer->Add(m_EdgesDisplayOption, 0, wxALIGN_TOP|wxALL, 5);

    wxArrayString m_TextDisplayOptionStrings;
    m_TextDisplayOptionStrings.Add(_("&Line"));
    m_TextDisplayOptionStrings.Add(_("&Filled"));
    m_TextDisplayOptionStrings.Add(_("&Sketch"));
    m_TextDisplayOption = new wxRadioBox( itemDialog1, TEXT_SELECT, _("Texts:"), wxDefaultPosition, wxDefaultSize, m_TextDisplayOptionStrings, 1, wxRA_SPECIFY_COLS );
    m_TextDisplayOption->SetSelection(0);
    MainBoxSizer->Add(m_TextDisplayOption, 0, wxALIGN_TOP|wxALL, 5);

    ColumnBoxSizer = new wxBoxSizer(wxVERTICAL);
    MainBoxSizer->Add(ColumnBoxSizer, 1, wxALIGN_TOP|wxLEFT|wxRIGHT|wxTOP, 5);

    m_IsShowPadFill = new wxCheckBox( itemDialog1, PADFILL_OPT, _("&Pad Filled"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
    m_IsShowPadFill->SetValue(false);
    ColumnBoxSizer->Add(m_IsShowPadFill, 1, wxGROW|wxALL, 5);

    m_IsShowPadNum = new wxCheckBox( itemDialog1, PADNUM_OPT, _("Display Pad &Num"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
    m_IsShowPadNum->SetValue(false);
    if (ShowToolTips())
        m_IsShowPadNum->SetToolTip(_("Display pad number"));
    ColumnBoxSizer->Add(m_IsShowPadNum, 1, wxGROW|wxALL, 5);

    ColumnBoxSizer->Add(5, 5, 0, wxGROW|wxTOP, 5);

    wxButton* itemButton10 = new wxButton( itemDialog1, ID_SAVE_CONFIG, _("Save Cfg"), wxDefaultPosition, wxDefaultSize, 0 );
    ColumnBoxSizer->Add(itemButton10, 0, wxALIGN_LEFT|wxALL, 5);

    wxStaticLine* itemStaticLine11 = new wxStaticLine( itemDialog1, ID_STATICLINE1, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
    OuterBoxSizer->Add(itemStaticLine11, 0, wxGROW|wxALL, 5);

    BottomBoxSizer = new wxBoxSizer(wxHORIZONTAL);
    OuterBoxSizer->Add(BottomBoxSizer, 0, wxALIGN_RIGHT|wxALL, 5);

    wxButton* itemButton13 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
    itemButton13->SetDefault();
    itemButton13->SetForegroundColour(wxColour(255, 0, 0));
    BottomBoxSizer->Add(itemButton13, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

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

    wxButton* itemButton15 = new wxButton( itemDialog1, wxID_APPLY, _("&Apply"), wxDefaultPosition, wxDefaultSize, 0 );
    BottomBoxSizer->Add(itemButton15, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

    // Set validators
    m_EdgesDisplayOption->SetValidator( wxGenericValidator(& DisplayOpt.DisplayModEdge) );
    m_TextDisplayOption->SetValidator( wxGenericValidator(& DisplayOpt.DisplayModText) );
    m_IsShowPadFill->SetValidator( wxGenericValidator(& DisplayOpt.DisplayPadFill) );
    m_IsShowPadNum->SetValidator( wxGenericValidator(& DisplayOpt.DisplayPadNum) );
////@end WinEDA_FootprintDisplayOptionsFrame content construction
}

/*!
 * Should we show tooltips?
 */

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

/*!
 * Get bitmap resources
 */

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

/*!
 * Get icon resources
 */

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

/*!
 * Update settings related to edges, text strings, and pads
 */

void WinEDA_FootprintDisplayOptionsFrame::UpdateObjectSettings(void)
{
    // Update settings
////@begin WinEDA_FootprintDisplayOptionsFrame update settings
	DisplayOpt.DisplayModEdge = m_Parent->m_DisplayModEdge =
		m_EdgesDisplayOption->GetSelection();

	DisplayOpt.DisplayModText = m_Parent->m_DisplayModText = 
		m_TextDisplayOption->GetSelection();

    DisplayOpt.DisplayPadNum = m_Parent->m_DisplayPadNum =
        m_IsShowPadNum->GetValue();

	DisplayOpt.DisplayPadFill = m_Parent->m_DisplayPadFill =
		m_IsShowPadFill->GetValue();

	m_Parent->ReDrawPanel();
////@end WinEDA_FootprintDisplayOptionsFrame update settings
}

/*!
 * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_SAVE_CONFIG
 */

void WinEDA_FootprintDisplayOptionsFrame::OnSaveConfigClick( wxCommandEvent& event )
{
	Save_Config(this);
}

/*!
 * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
 */

void WinEDA_FootprintDisplayOptionsFrame::OnOkClick( wxCommandEvent& event )
{
	UpdateObjectSettings();
    EndModal( 1 );
}

/*!
 * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
 */

void WinEDA_FootprintDisplayOptionsFrame::OnCancelClick( wxCommandEvent& event )
{
    EndModal( -1 );
}

/*!
 * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_APPLY
 */

void WinEDA_FootprintDisplayOptionsFrame::OnApplyClick( wxCommandEvent& event )
{
	UpdateObjectSettings();
}
