326 lines
12 KiB
C++
326 lines
12 KiB
C++
/////////////////////////////////////////////////////////////////////////////
|
|
// Name: dialog_create_component.cpp
|
|
// Purpose:
|
|
// Author:
|
|
// Modified by:
|
|
// Created: 01/14/06 10:14:28
|
|
// RCS-ID:
|
|
// Copyright:
|
|
// Licence:
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Generated by DialogBlocks (unregistered), 01/14/06 10:14:28
|
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
|
#pragma implementation "dialog_create_component.h"
|
|
#endif
|
|
|
|
#include "fctsys.h"
|
|
#include "common.h"
|
|
#include "confirm.h"
|
|
|
|
#include "program.h"
|
|
#include "class_libentry.h"
|
|
#include "libeditfrm.h"
|
|
|
|
////@begin includes
|
|
////@end includes
|
|
|
|
#include "dialog_create_component.h"
|
|
|
|
////@begin XPM images
|
|
////@end XPM images
|
|
|
|
/*!
|
|
* WinEDA_CreateCmpDialog type definition
|
|
*/
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS( WinEDA_CreateCmpDialog, wxDialog )
|
|
|
|
/*!
|
|
* WinEDA_CreateCmpDialog event table definition
|
|
*/
|
|
|
|
BEGIN_EVENT_TABLE( WinEDA_CreateCmpDialog, wxDialog )
|
|
|
|
////@begin WinEDA_CreateCmpDialog event table entries
|
|
EVT_BUTTON( wxID_OK, WinEDA_CreateCmpDialog::OnOkClick )
|
|
|
|
EVT_BUTTON( wxID_CANCEL, WinEDA_CreateCmpDialog::OnCancelClick )
|
|
|
|
////@end WinEDA_CreateCmpDialog event table entries
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
/*!
|
|
* WinEDA_CreateCmpDialog constructors
|
|
*/
|
|
|
|
WinEDA_CreateCmpDialog::WinEDA_CreateCmpDialog( )
|
|
{
|
|
}
|
|
|
|
WinEDA_CreateCmpDialog::WinEDA_CreateCmpDialog( WinEDA_DrawFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
|
{
|
|
Create(parent, id, caption, pos, size, style);
|
|
}
|
|
|
|
/*!
|
|
* WinEDA_CreateCmpDialog creator
|
|
*/
|
|
|
|
bool WinEDA_CreateCmpDialog::Create( WinEDA_DrawFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
|
{
|
|
////@begin WinEDA_CreateCmpDialog member initialisation
|
|
m_CmpName = NULL;
|
|
m_Reference = NULL;
|
|
m_AsConvert = NULL;
|
|
m_IsPowerSymbol = NULL;
|
|
m_PartsAreLocked = NULL;
|
|
m_btClose = NULL;
|
|
m_PartsCount = NULL;
|
|
m_ShowPinNum = NULL;
|
|
m_ShowPinname = NULL;
|
|
m_PinNameInside = NULL;
|
|
m_SetSkew = NULL;
|
|
////@end WinEDA_CreateCmpDialog member initialisation
|
|
|
|
////@begin WinEDA_CreateCmpDialog creation
|
|
SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
|
|
wxDialog::Create( parent, id, caption, pos, size, style );
|
|
|
|
CreateControls();
|
|
if (GetSizer())
|
|
{
|
|
GetSizer()->SetSizeHints(this);
|
|
}
|
|
Centre();
|
|
////@end WinEDA_CreateCmpDialog creation
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/**********************************************************************************/
|
|
void WinEDA_CreateCmpDialog::SetComponentData( LIB_COMPONENT & component )
|
|
/**********************************************************************************/
|
|
{
|
|
WinEDA_LibeditFrame* parent = (WinEDA_LibeditFrame*) GetParent();
|
|
|
|
parent->SetShowDeMorgan( m_AsConvert->GetValue() );
|
|
component.SetPartCount( m_PartsCount->GetSelection() + 1 );
|
|
component.GetReference().m_Text = m_Reference->GetValue();
|
|
if ( m_PinNameInside->GetValue() == FALSE)
|
|
component.m_TextInside = 0;
|
|
else
|
|
component.m_TextInside = m_SetSkew->GetValue();
|
|
|
|
if ( m_IsPowerSymbol->GetValue() == TRUE)
|
|
component.m_Options = ENTRY_POWER;
|
|
else
|
|
component.m_Options = ENTRY_NORMAL;
|
|
|
|
/* Set the option "Units locked".
|
|
Obviously, cannot be TRUE if there is only one part */
|
|
component.m_UnitSelectionLocked = m_PartsAreLocked->GetValue();
|
|
if ( component.GetPartCount() <= 1 )
|
|
component.m_UnitSelectionLocked = FALSE;
|
|
}
|
|
|
|
/*!
|
|
* Control creation for WinEDA_CreateCmpDialog
|
|
*/
|
|
|
|
void WinEDA_CreateCmpDialog::CreateControls()
|
|
{
|
|
////@begin WinEDA_CreateCmpDialog content construction
|
|
// Generated by DialogBlocks, 24/04/2009 14:20:19 (unregistered)
|
|
|
|
WinEDA_CreateCmpDialog* itemDialog1 = this;
|
|
|
|
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
|
|
itemDialog1->SetSizer(itemBoxSizer2);
|
|
|
|
wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
|
|
itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_LEFT|wxALL, 5);
|
|
|
|
wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL);
|
|
itemBoxSizer3->Add(itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
|
|
|
wxStaticBox* itemStaticBoxSizer5Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Name"));
|
|
wxStaticBoxSizer* itemStaticBoxSizer5 = new wxStaticBoxSizer(itemStaticBoxSizer5Static, wxVERTICAL);
|
|
itemBoxSizer4->Add(itemStaticBoxSizer5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
|
|
|
|
m_CmpName = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
|
|
itemStaticBoxSizer5->Add(m_CmpName, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
|
|
|
|
wxStaticBox* itemStaticBoxSizer7Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Reference"));
|
|
wxStaticBoxSizer* itemStaticBoxSizer7 = new wxStaticBoxSizer(itemStaticBoxSizer7Static, wxVERTICAL);
|
|
itemBoxSizer4->Add(itemStaticBoxSizer7, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
|
|
|
|
m_Reference = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _("U"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
itemStaticBoxSizer7->Add(m_Reference, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
|
|
|
|
itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
|
|
|
wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxVERTICAL);
|
|
itemBoxSizer3->Add(itemBoxSizer10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
|
|
|
wxStaticBox* itemStaticBoxSizer11Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Options"));
|
|
wxStaticBoxSizer* itemStaticBoxSizer11 = new wxStaticBoxSizer(itemStaticBoxSizer11Static, wxVERTICAL);
|
|
itemBoxSizer10->Add(itemStaticBoxSizer11, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
|
|
|
|
m_AsConvert = new wxCheckBox( itemDialog1, ID_CHECKBOX3, _("As Convert"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
|
|
m_AsConvert->SetValue(false);
|
|
itemStaticBoxSizer11->Add(m_AsConvert, 0, wxALIGN_LEFT|wxALL, 5);
|
|
|
|
m_IsPowerSymbol = new wxCheckBox( itemDialog1, ID_CHECKBOX4, _("Power Symbol"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
|
|
m_IsPowerSymbol->SetValue(false);
|
|
itemStaticBoxSizer11->Add(m_IsPowerSymbol, 0, wxALIGN_LEFT|wxALL, 5);
|
|
|
|
m_PartsAreLocked = new wxCheckBox( itemDialog1, ID_CHECKBOX2, _("Parts are locked"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
|
|
m_PartsAreLocked->SetValue(false);
|
|
itemStaticBoxSizer11->Add(m_PartsAreLocked, 0, wxALIGN_LEFT|wxALL, 5);
|
|
|
|
wxBoxSizer* itemBoxSizer15 = new wxBoxSizer(wxVERTICAL);
|
|
itemBoxSizer3->Add(itemBoxSizer15, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
|
|
|
wxButton* itemButton16 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
itemButton16->SetDefault();
|
|
itemBoxSizer15->Add(itemButton16, 0, wxGROW|wxALL, 5);
|
|
|
|
m_btClose = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
itemBoxSizer15->Add(m_btClose, 0, wxGROW|wxALL, 5);
|
|
|
|
wxStaticLine* itemStaticLine18 = new wxStaticLine( itemDialog1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL|wxDOUBLE_BORDER );
|
|
itemBoxSizer2->Add(itemStaticLine18, 0, wxGROW|wxALL, 5);
|
|
|
|
wxBoxSizer* itemBoxSizer19 = new wxBoxSizer(wxHORIZONTAL);
|
|
itemBoxSizer2->Add(itemBoxSizer19, 0, wxGROW|wxALL, 5);
|
|
|
|
wxArrayString m_PartsCountStrings;
|
|
m_PartsCountStrings.Add(_("&1"));
|
|
m_PartsCountStrings.Add(_("&2"));
|
|
m_PartsCountStrings.Add(_("&3"));
|
|
m_PartsCountStrings.Add(_("&4"));
|
|
m_PartsCountStrings.Add(_("&5"));
|
|
m_PartsCountStrings.Add(_("&6"));
|
|
m_PartsCountStrings.Add(_("&7"));
|
|
m_PartsCountStrings.Add(_("&8"));
|
|
m_PartsCountStrings.Add(_("&9"));
|
|
m_PartsCountStrings.Add(_("&10"));
|
|
m_PartsCountStrings.Add(_("&11"));
|
|
m_PartsCountStrings.Add(_("&12"));
|
|
m_PartsCountStrings.Add(_("&13"));
|
|
m_PartsCountStrings.Add(_("&14"));
|
|
m_PartsCountStrings.Add(_("&15"));
|
|
m_PartsCountStrings.Add(_("&16"));
|
|
m_PartsCountStrings.Add(_("&17"));
|
|
m_PartsCountStrings.Add(_("&18"));
|
|
m_PartsCountStrings.Add(_("&19"));
|
|
m_PartsCountStrings.Add(_("&20"));
|
|
m_PartsCountStrings.Add(_("&21"));
|
|
m_PartsCountStrings.Add(_("&22"));
|
|
m_PartsCountStrings.Add(_("&23"));
|
|
m_PartsCountStrings.Add(_("&24"));
|
|
m_PartsCountStrings.Add(_("&25"));
|
|
m_PartsCountStrings.Add(_("&26"));
|
|
m_PartsCount = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Parts per component"), wxDefaultPosition, wxDefaultSize, m_PartsCountStrings, 9, wxRA_SPECIFY_ROWS );
|
|
m_PartsCount->SetSelection(0);
|
|
itemBoxSizer19->Add(m_PartsCount, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
|
|
|
itemBoxSizer19->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
|
|
|
wxStaticBox* itemStaticBoxSizer22Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Draw options"));
|
|
wxStaticBoxSizer* itemStaticBoxSizer22 = new wxStaticBoxSizer(itemStaticBoxSizer22Static, wxVERTICAL);
|
|
itemBoxSizer19->Add(itemStaticBoxSizer22, 0, wxGROW|wxALL, 5);
|
|
|
|
m_ShowPinNum = new wxCheckBox( itemDialog1, ID_CHECKBOX1, _("Show Pin Number"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
|
|
m_ShowPinNum->SetValue(true);
|
|
itemStaticBoxSizer22->Add(m_ShowPinNum, 0, wxALIGN_LEFT|wxALL, 5);
|
|
|
|
m_ShowPinname = new wxCheckBox( itemDialog1, ID_CHECKBOX5, _("Show Pin Name"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
|
|
m_ShowPinname->SetValue(true);
|
|
itemStaticBoxSizer22->Add(m_ShowPinname, 0, wxALIGN_LEFT|wxALL, 5);
|
|
|
|
m_PinNameInside = new wxCheckBox( itemDialog1, ID_CHECKBOX, _("Pin Name Inside"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
|
|
m_PinNameInside->SetValue(true);
|
|
itemStaticBoxSizer22->Add(m_PinNameInside, 0, wxALIGN_LEFT|wxALL, 5);
|
|
|
|
wxStaticBox* itemStaticBoxSizer26Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Skew:"));
|
|
wxStaticBoxSizer* itemStaticBoxSizer26 = new wxStaticBoxSizer(itemStaticBoxSizer26Static, wxVERTICAL);
|
|
itemStaticBoxSizer22->Add(itemStaticBoxSizer26, 0, wxALIGN_LEFT|wxALL, 5);
|
|
|
|
m_SetSkew = new wxSpinCtrl( itemDialog1, ID_SPINCTRL, _T("40"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 100, 40 );
|
|
itemStaticBoxSizer26->Add(m_SetSkew, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
|
|
|
|
////@end WinEDA_CreateCmpDialog content construction
|
|
|
|
m_btClose->SetFocus();
|
|
}
|
|
|
|
/*!
|
|
* Should we show tooltips?
|
|
*/
|
|
|
|
bool WinEDA_CreateCmpDialog::ShowToolTips()
|
|
{
|
|
return TRUE;
|
|
}
|
|
|
|
/*!
|
|
* Get bitmap resources
|
|
*/
|
|
|
|
wxBitmap WinEDA_CreateCmpDialog::GetBitmapResource( const wxString& name )
|
|
{
|
|
// Bitmap retrieval
|
|
////@begin WinEDA_CreateCmpDialog bitmap retrieval
|
|
wxUnusedVar(name);
|
|
return wxNullBitmap;
|
|
////@end WinEDA_CreateCmpDialog bitmap retrieval
|
|
}
|
|
|
|
/*!
|
|
* Get icon resources
|
|
*/
|
|
|
|
wxIcon WinEDA_CreateCmpDialog::GetIconResource( const wxString& name )
|
|
{
|
|
// Icon retrieval
|
|
////@begin WinEDA_CreateCmpDialog icon retrieval
|
|
wxUnusedVar(name);
|
|
return wxNullIcon;
|
|
////@end WinEDA_CreateCmpDialog icon retrieval
|
|
}
|
|
/*!
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON
|
|
*/
|
|
|
|
void WinEDA_CreateCmpDialog::OnOkClick( wxCommandEvent& event )
|
|
{
|
|
if ( m_CmpName->GetValue() == wxEmptyString )
|
|
{
|
|
DisplayError(this,_("You must provide a name for this component"));
|
|
return;
|
|
}
|
|
////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON in WinEDA_CreateCmpDialog.
|
|
// Before editing this code, remove the block markers.
|
|
event.Skip();
|
|
////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON in WinEDA_CreateCmpDialog.
|
|
}
|
|
|
|
|
|
/*!
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON1
|
|
*/
|
|
|
|
void WinEDA_CreateCmpDialog::OnCancelClick( wxCommandEvent& event )
|
|
{
|
|
////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON1 in WinEDA_CreateCmpDialog.
|
|
// Before editing this code, remove the block markers.
|
|
event.Skip();
|
|
////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON1 in WinEDA_CreateCmpDialog.
|
|
}
|
|
|
|
|