kicad/cvpcb/dialog_display_options.cpp

308 lines
9.0 KiB
C++
Raw Normal View History

/////////////////////////////////////////////////////////////////////////////
// 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 */
{
KiDisplayOptionsFrame * OptionWindow = new KiDisplayOptionsFrame(this);
2007-10-07 03:08:24 +00:00
OptionWindow->ShowModal();
OptionWindow->Destroy();
}
/*!
* KiDisplayOptionsFrame type definition
*/
IMPLEMENT_DYNAMIC_CLASS( KiDisplayOptionsFrame, wxDialog )
/*!
* KiDisplayOptionsFrame event table definition
*/
BEGIN_EVENT_TABLE( KiDisplayOptionsFrame, wxDialog )
////@begin KiDisplayOptionsFrame event table entries
EVT_BUTTON( ID_SAVE_CONFIG, KiDisplayOptionsFrame::OnSaveConfigClick )
2007-10-07 03:08:24 +00:00
EVT_BUTTON( wxID_OK, KiDisplayOptionsFrame::OnOkClick )
2007-10-07 03:08:24 +00:00
EVT_BUTTON( wxID_CANCEL, KiDisplayOptionsFrame::OnCancelClick )
2007-10-07 03:08:24 +00:00
EVT_BUTTON( wxID_APPLY, KiDisplayOptionsFrame::OnApplyClick )
////@end KiDisplayOptionsFrame event table entries
END_EVENT_TABLE()
/*!
* KiDisplayOptionsFrame constructors
*/
KiDisplayOptionsFrame::KiDisplayOptionsFrame( )
{
}
KiDisplayOptionsFrame::KiDisplayOptionsFrame( 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);
}
/*!
* KiDisplayOptionsFrame creator
*/
bool KiDisplayOptionsFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
////@begin KiDisplayOptionsFrame member initialisation
m_EdgesDisplayOption = NULL;
m_TextDisplayOption = NULL;
2007-10-07 03:08:24 +00:00
m_IsShowPadNum = NULL;
m_IsShowPadFill = NULL;
////@end KiDisplayOptionsFrame member initialisation
////@begin KiDisplayOptionsFrame creation
SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS);
wxDialog::Create( parent, id, caption, pos, size, style );
CreateControls();
GetSizer()->Fit(this);
GetSizer()->SetSizeHints(this);
Centre();
////@end KiDisplayOptionsFrame creation
return true;
}
/*!
* Control creation for KiDisplayOptionsFrame
*/
void KiDisplayOptionsFrame::CreateControls()
{
SetFont(*g_DialogFont);
////@begin KiDisplayOptionsFrame content construction
// Generated by DialogBlocks, 17/02/2006 18:31:55 (unregistered)
KiDisplayOptionsFrame* itemDialog1 = this;
2007-10-07 03:08:24 +00:00
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
itemDialog1->SetSizer(itemBoxSizer2);
2007-10-07 03:08:24 +00:00
wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
// itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_TOP|wxALL, 5);
2007-10-07 03:08:24 +00:00
wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
// itemBoxSizer2->Add(itemBoxSizer4, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
itemBoxSizer2->Add(itemBoxSizer4, 0, wxGROW|wxALIGN_TOP|wxALL, 5);
wxString m_EdgesDisplayOptionStrings[] = {
_("&Filaire"),
_("&Filled"),
_("&Sketch")
};
m_EdgesDisplayOption = new wxRadioBox( itemDialog1, EDGE_SELECT, _("Edges:"), wxDefaultPosition, wxDefaultSize, 3, m_EdgesDisplayOptionStrings, 1, wxRA_SPECIFY_COLS );
2007-10-07 03:08:24 +00:00
// itemBoxSizer3->Add(m_EdgesDisplayOption, 0, wxGROW|wxALL, 5);
itemBoxSizer3->Add(m_EdgesDisplayOption, 0, wxALIGN_LEFT|wxALL, 5);
wxString m_TextDisplayOptionStrings[] = {
_("&Filaire"),
_("&Filled"),
_("&Sketch")
};
m_TextDisplayOption = new wxRadioBox( itemDialog1, TEXT_SELECT, _("Texts:"), wxDefaultPosition, wxDefaultSize, 3, m_TextDisplayOptionStrings, 1, wxRA_SPECIFY_COLS );
2007-10-07 03:08:24 +00:00
// itemBoxSizer3->Add(m_TextDisplayOption, 0, wxGROW|wxALL, 5);
itemBoxSizer3->Add(m_TextDisplayOption, 0, wxALIGN_LEFT|wxALL, 5);
wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL);
// itemBoxSizer3->Add(itemBoxSizer5, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemBoxSizer3->Add(itemBoxSizer5, 0, wxGROW|wxALL, 0);
// Provide a spacer to improve appearance of dialog box
itemBoxSizer5->AddSpacer(5);
m_IsShowPadNum = new wxCheckBox( itemDialog1, PADNUM_OPT, _("Pad &Num"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
m_IsShowPadNum->SetValue(false);
// itemBoxSizer5->Add(m_IsShowPadNum, 0, wxGROW|wxALL, 5);
itemBoxSizer5->Add(m_IsShowPadNum, 0, wxALIGN_TOP|wxALL, 5);
m_IsShowPadFill = new wxCheckBox( itemDialog1, PADFILL_OPT, _("&Pad Fill"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
m_IsShowPadFill->SetValue(false);
// itemBoxSizer5->Add(m_IsShowPadFill, 0, wxGROW|wxALL, 5);
itemBoxSizer5->Add(m_IsShowPadFill, 0, wxALIGN_TOP|wxALL, 5);
// Provide a stretch spacer to improve appearance of dialog box
itemBoxSizer5->AddStretchSpacer();
wxButton* itemButton6 = new wxButton( itemDialog1, ID_SAVE_CONFIG, _("Save Cfg..."), wxDefaultPosition, wxDefaultSize, 0 );
// itemBoxSizer5->Add(itemButton6, 0, wxGROW|wxALL, 5);
itemBoxSizer5->Add(itemButton6, 0, wxALIGN_BOTTOM|wxALL, 5);
// itemBoxSizer4->AddStretchSpacer();
wxButton* itemButton7 = new wxButton( itemDialog1, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 );
itemButton7->SetForegroundColour(*wxRED);
// itemBoxSizer4->Add(itemButton7, 0, wxGROW|wxALL, 5);
itemBoxSizer4->Add(itemButton7, 0, wxALIGN_RIGHT|wxALL, 5);
wxButton* itemButton8 = new wxButton( itemDialog1, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
itemButton8->SetForegroundColour(*wxBLUE);
// itemBoxSizer4->Add(itemButton8, 0, wxGROW|wxALL, 5);
itemBoxSizer4->Add(itemButton8, 0, wxALIGN_RIGHT|wxALL, 5);
wxButton* itemButton9 = new wxButton( itemDialog1, wxID_APPLY, _("Apply"), wxDefaultPosition, wxDefaultSize, 0 );
// itemBoxSizer4->Add(itemButton9, 0, wxGROW|wxALL, 5);
itemBoxSizer4->Add(itemButton9, 0, wxALIGN_RIGHT|wxALL, 5);
// Set validators
m_EdgesDisplayOption->SetValidator( wxGenericValidator(& DisplayOpt.DisplayModEdge) );
m_TextDisplayOption->SetValidator( wxGenericValidator(& DisplayOpt.DisplayModText) );
2007-10-07 03:08:24 +00:00
m_IsShowPadNum->SetValidator( wxGenericValidator(& DisplayOpt.DisplayPadNum) );
m_IsShowPadFill->SetValidator( wxGenericValidator(& DisplayOpt.DisplayPadFill) );
////@end KiDisplayOptionsFrame content construction
}
/*!
* Should we show tooltips?
*/
bool KiDisplayOptionsFrame::ShowToolTips()
{
return true;
}
/*!
* Get bitmap resources
*/
wxBitmap KiDisplayOptionsFrame::GetBitmapResource( const wxString& name )
{
// Bitmap retrieval
////@begin KiDisplayOptionsFrame bitmap retrieval
wxUnusedVar(name);
return wxNullBitmap;
////@end KiDisplayOptionsFrame bitmap retrieval
}
/*!
* Get icon resources
*/
wxIcon KiDisplayOptionsFrame::GetIconResource( const wxString& name )
{
// Icon retrieval
////@begin KiDisplayOptionsFrame icon retrieval
wxUnusedVar(name);
return wxNullIcon;
////@end KiDisplayOptionsFrame icon retrieval
}
/*!
2007-10-07 03:08:24 +00:00
* Update settings related to edges, text strings, and pads
*/
2007-10-07 03:08:24 +00:00
void KiDisplayOptionsFrame::UpdateObjectSettings()
{
2007-10-07 03:08:24 +00:00
// Update settings
////@begin KiDisplayOptionsFrame 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();
2007-10-07 03:08:24 +00:00
m_Parent->ReDrawPanel();
2007-10-07 03:08:24 +00:00
////@end KiDisplayOptionsFrame update settings
}
/*!
2007-10-07 03:08:24 +00:00
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_SAVE_CONFIG
*/
2007-10-07 03:08:24 +00:00
void KiDisplayOptionsFrame::OnSaveConfigClick( wxCommandEvent& event )
{
2007-10-07 03:08:24 +00:00
Save_Config(this);
}
/*!
2007-10-07 03:08:24 +00:00
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
*/
2007-10-07 03:08:24 +00:00
void KiDisplayOptionsFrame::OnOkClick( wxCommandEvent& event )
{
2007-10-07 03:08:24 +00:00
UpdateObjectSettings();
EndModal( 1 );
}
/*!
2007-10-07 03:08:24 +00:00
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
*/
2007-10-07 03:08:24 +00:00
void KiDisplayOptionsFrame::OnCancelClick( wxCommandEvent& event )
{
2007-10-07 03:08:24 +00:00
EndModal( -1 );
}
/*!
2007-10-07 03:08:24 +00:00
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_APPLY
*/
2007-10-07 03:08:24 +00:00
void KiDisplayOptionsFrame::OnApplyClick( wxCommandEvent& event )
{
2007-10-07 03:08:24 +00:00
UpdateObjectSettings();
}