2007-05-06 16:03:28 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
// Name: sheet.cpp
|
2007-08-20 01:20:48 +00:00
|
|
|
// Purpose:
|
2007-05-06 16:03:28 +00:00
|
|
|
// Author: jean-pierre Charras
|
2007-08-20 01:20:48 +00:00
|
|
|
// Modified by:
|
2007-05-06 16:03:28 +00:00
|
|
|
// Created: 08/02/2006 18:37:02
|
2007-08-20 01:20:48 +00:00
|
|
|
// RCS-ID:
|
2007-05-06 16:03:28 +00:00
|
|
|
// Copyright: License GNU
|
2009-11-04 20:46:53 +00:00
|
|
|
// License:
|
2007-05-06 16:03:28 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Generated by DialogBlocks (unregistered), 08/02/2006 18:37:02
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
2007-05-06 16:03:28 +00:00
|
|
|
#pragma implementation "sheet.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
////@begin includes
|
|
|
|
////@end includes
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
|
|
|
#include "gestfich.h"
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "program.h"
|
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
static void ExitSheet( WinEDA_DrawPanel* Panel, wxDC* DC );
|
|
|
|
static void DeplaceSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
static int s_SheetMindx, s_SheetMindy;
|
2009-11-04 20:46:53 +00:00
|
|
|
static wxPoint s_OldPos; /* Former position for cancellation or move ReSize */
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include "sheet.h"
|
|
|
|
|
|
|
|
////@begin XPM images
|
|
|
|
////@end XPM images
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* WinEDA_SheetPropertiesFrame type definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS( WinEDA_SheetPropertiesFrame, wxDialog )
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* WinEDA_SheetPropertiesFrame event table definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE( WinEDA_SheetPropertiesFrame, wxDialog )
|
|
|
|
|
|
|
|
////@begin WinEDA_SheetPropertiesFrame event table entries
|
2009-06-11 14:26:17 +00:00
|
|
|
EVT_BUTTON( wxID_CANCEL, WinEDA_SheetPropertiesFrame::OnCancelClick )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-06-11 14:26:17 +00:00
|
|
|
EVT_BUTTON( wxID_OK, WinEDA_SheetPropertiesFrame::OnOkClick )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
////@end WinEDA_SheetPropertiesFrame event table entries
|
|
|
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
/*!
|
|
|
|
* WinEDA_SheetPropertiesFrame constructors
|
|
|
|
*/
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
WinEDA_SheetPropertiesFrame::WinEDA_SheetPropertiesFrame()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
WinEDA_SheetPropertiesFrame::WinEDA_SheetPropertiesFrame(
|
|
|
|
WinEDA_SchematicFrame* parent,
|
|
|
|
SCH_SHEET* currentsheet,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxString& caption,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
long style )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
m_Parent = parent;
|
|
|
|
m_CurrentSheet = currentsheet;
|
|
|
|
Create( parent, id, caption, pos, size, style );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
AddUnitSymbol( *m_SheetNameTextSize );
|
|
|
|
PutValueInLocalUnits( *m_SheetNameSize, m_CurrentSheet->m_SheetNameSize,
|
2009-06-11 14:26:17 +00:00
|
|
|
m_Parent->m_InternalUnits );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
AddUnitSymbol( *m_FileNameTextSize );
|
|
|
|
PutValueInLocalUnits( *m_FileNameSize, m_CurrentSheet->m_FileNameSize,
|
2009-06-11 14:26:17 +00:00
|
|
|
m_Parent->m_InternalUnits );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*!
|
|
|
|
* WinEDA_SheetPropertiesFrame creator
|
|
|
|
*/
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
bool WinEDA_SheetPropertiesFrame::Create( wxWindow* parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxString& caption,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
long style )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
////@begin WinEDA_SheetPropertiesFrame member initialisation
|
2009-06-11 14:26:17 +00:00
|
|
|
m_FileNameWin = NULL;
|
2008-04-30 11:52:34 +00:00
|
|
|
m_SheetNameWin = NULL;
|
2009-06-11 14:26:17 +00:00
|
|
|
m_FileNameTextSize = NULL;
|
|
|
|
m_FileNameSize = NULL;
|
2007-05-06 16:03:28 +00:00
|
|
|
m_SheetNameTextSize = NULL;
|
2009-06-11 14:26:17 +00:00
|
|
|
m_SheetNameSize = NULL;
|
2008-04-30 11:52:34 +00:00
|
|
|
m_btClose = NULL;
|
2009-06-11 14:26:17 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
////@end WinEDA_SheetPropertiesFrame member initialisation
|
|
|
|
|
|
|
|
////@begin WinEDA_SheetPropertiesFrame creation
|
2009-06-11 14:26:17 +00:00
|
|
|
SetExtraStyle( wxWS_EX_BLOCK_EVENTS );
|
2007-05-06 16:03:28 +00:00
|
|
|
wxDialog::Create( parent, id, caption, pos, size, style );
|
|
|
|
|
|
|
|
CreateControls();
|
2009-06-11 14:26:17 +00:00
|
|
|
if( GetSizer() )
|
2008-02-28 19:27:25 +00:00
|
|
|
{
|
2009-06-11 14:26:17 +00:00
|
|
|
GetSizer()->SetSizeHints( this );
|
2008-02-28 19:27:25 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
Centre();
|
2009-06-11 14:26:17 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
////@end WinEDA_SheetPropertiesFrame creation
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*!
|
|
|
|
* Control creation for WinEDA_SheetPropertiesFrame
|
|
|
|
*/
|
|
|
|
|
|
|
|
void WinEDA_SheetPropertiesFrame::CreateControls()
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2007-05-06 16:03:28 +00:00
|
|
|
////@begin WinEDA_SheetPropertiesFrame content construction
|
2009-04-29 17:09:00 +00:00
|
|
|
// Generated by DialogBlocks, 24/04/2009 14:25:43 (unregistered)
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
WinEDA_SheetPropertiesFrame* itemDialog1 = this;
|
|
|
|
|
2009-06-11 14:26:17 +00:00
|
|
|
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer( wxVERTICAL );
|
|
|
|
|
|
|
|
itemDialog1->SetSizer( itemBoxSizer2 );
|
|
|
|
|
|
|
|
wxBoxSizer* itemBoxSizer3 = new wxBoxSizer( wxHORIZONTAL );
|
|
|
|
itemBoxSizer2->Add( itemBoxSizer3, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
wxBoxSizer* itemBoxSizer4 = new wxBoxSizer( wxVERTICAL );
|
|
|
|
itemBoxSizer3->Add( itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1,
|
|
|
|
wxID_STATIC,
|
|
|
|
_( "Filename:" ),
|
|
|
|
wxDefaultPosition,
|
|
|
|
wxDefaultSize,
|
|
|
|
0 );
|
2009-06-11 14:26:17 +00:00
|
|
|
itemBoxSizer4->Add( itemStaticText5,
|
|
|
|
0,
|
2009-11-04 20:46:53 +00:00
|
|
|
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP |
|
|
|
|
wxADJUST_MINSIZE,
|
2009-06-11 14:26:17 +00:00
|
|
|
5 );
|
|
|
|
|
|
|
|
m_FileNameWin =
|
2009-11-04 20:46:53 +00:00
|
|
|
new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T( "" ), wxDefaultPosition,
|
|
|
|
wxSize( 300, - 1 ), wxTE_PROCESS_ENTER );
|
|
|
|
itemBoxSizer4->Add( m_FileNameWin,
|
|
|
|
0,
|
|
|
|
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM,
|
|
|
|
5 );
|
|
|
|
|
|
|
|
wxStaticText* itemStaticText7 = new wxStaticText( itemDialog1,
|
|
|
|
wxID_STATIC,
|
|
|
|
_( "Sheetname:" ),
|
|
|
|
wxDefaultPosition,
|
|
|
|
wxDefaultSize,
|
|
|
|
0 );
|
2009-06-11 14:26:17 +00:00
|
|
|
itemBoxSizer4->Add( itemStaticText7,
|
|
|
|
0,
|
2009-11-04 20:46:53 +00:00
|
|
|
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP |
|
|
|
|
wxADJUST_MINSIZE,
|
2009-06-11 14:26:17 +00:00
|
|
|
5 );
|
|
|
|
|
|
|
|
m_SheetNameWin =
|
2009-11-04 20:46:53 +00:00
|
|
|
new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T( "" ), wxDefaultPosition,
|
|
|
|
wxSize( 300, -1 ), 0 );
|
|
|
|
itemBoxSizer4->Add( m_SheetNameWin,
|
|
|
|
0,
|
|
|
|
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM,
|
|
|
|
5 );
|
2009-06-11 14:26:17 +00:00
|
|
|
|
|
|
|
wxBoxSizer* itemBoxSizer9 = new wxBoxSizer( wxVERTICAL );
|
|
|
|
itemBoxSizer3->Add( itemBoxSizer9, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
m_FileNameTextSize = new wxStaticText( itemDialog1, wxID_STATIC,
|
|
|
|
_( "Size" ), wxDefaultPosition,
|
|
|
|
wxDefaultSize, 0 );
|
2009-06-11 14:26:17 +00:00
|
|
|
itemBoxSizer9->Add( m_FileNameTextSize,
|
|
|
|
0,
|
2009-11-04 20:46:53 +00:00
|
|
|
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP |
|
|
|
|
wxADJUST_MINSIZE,
|
2009-06-11 14:26:17 +00:00
|
|
|
5 );
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
m_FileNameSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL2, _T( "" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
itemBoxSizer9->Add( m_FileNameSize,
|
|
|
|
0,
|
|
|
|
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM,
|
|
|
|
5 );
|
2009-06-11 14:26:17 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
m_SheetNameTextSize = new wxStaticText( itemDialog1, wxID_STATIC,
|
|
|
|
_( "Size" ), wxDefaultPosition,
|
|
|
|
wxDefaultSize, 0 );
|
2009-06-11 14:26:17 +00:00
|
|
|
itemBoxSizer9->Add( m_SheetNameTextSize,
|
|
|
|
0,
|
2009-11-04 20:46:53 +00:00
|
|
|
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP |
|
|
|
|
wxADJUST_MINSIZE,
|
2009-06-11 14:26:17 +00:00
|
|
|
5 );
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
m_SheetNameSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL3, _T( "" ),
|
|
|
|
wxDefaultPosition,
|
|
|
|
wxDefaultSize, 0 );
|
|
|
|
itemBoxSizer9->Add( m_SheetNameSize,
|
|
|
|
0,
|
|
|
|
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM,
|
|
|
|
5 );
|
2009-06-11 14:26:17 +00:00
|
|
|
|
|
|
|
itemBoxSizer2->Add( 5, 5, 1, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
wxBoxSizer* itemBoxSizer15 = new wxBoxSizer( wxHORIZONTAL );
|
2009-11-04 20:46:53 +00:00
|
|
|
itemBoxSizer2->Add( itemBoxSizer15,
|
|
|
|
0,
|
|
|
|
wxALIGN_CENTER_HORIZONTAL | wxALL,
|
|
|
|
5 );
|
2009-06-11 14:26:17 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
m_btClose = new wxButton( itemDialog1, wxID_CANCEL, _( "&Cancel" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize, 0 );
|
2009-06-11 14:26:17 +00:00
|
|
|
itemBoxSizer15->Add( m_btClose, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
wxButton* itemButton17 = new wxButton( itemDialog1, wxID_OK,
|
|
|
|
_( "&OK" ), wxDefaultPosition,
|
|
|
|
wxDefaultSize, 0 );
|
2008-04-30 11:52:34 +00:00
|
|
|
itemButton17->SetDefault();
|
2009-06-11 14:26:17 +00:00
|
|
|
itemBoxSizer15->Add( itemButton17, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
2008-04-30 11:52:34 +00:00
|
|
|
|
|
|
|
// Set validators
|
2009-11-04 20:46:53 +00:00
|
|
|
m_SheetNameWin->SetValidator( wxTextValidator( wxFILTER_NONE,
|
|
|
|
&m_CurrentSheet->m_SheetName ) );
|
2009-06-11 14:26:17 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
////@end WinEDA_SheetPropertiesFrame content construction
|
2008-02-28 19:27:25 +00:00
|
|
|
|
2008-04-30 11:52:34 +00:00
|
|
|
m_btClose->SetFocus();
|
2008-02-28 20:39:04 +00:00
|
|
|
m_FileNameWin->SetValue( m_CurrentSheet->GetFileName() );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*!
|
|
|
|
* Should we show tooltips?
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool WinEDA_SheetPropertiesFrame::ShowToolTips()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*!
|
|
|
|
* Get bitmap resources
|
|
|
|
*/
|
|
|
|
|
|
|
|
wxBitmap WinEDA_SheetPropertiesFrame::GetBitmapResource( const wxString& name )
|
|
|
|
{
|
|
|
|
// Bitmap retrieval
|
|
|
|
////@begin WinEDA_SheetPropertiesFrame bitmap retrieval
|
2009-06-11 14:26:17 +00:00
|
|
|
wxUnusedVar( name );
|
2007-05-06 16:03:28 +00:00
|
|
|
return wxNullBitmap;
|
2009-06-11 14:26:17 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
////@end WinEDA_SheetPropertiesFrame bitmap retrieval
|
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*!
|
|
|
|
* Get icon resources
|
|
|
|
*/
|
|
|
|
|
|
|
|
wxIcon WinEDA_SheetPropertiesFrame::GetIconResource( const wxString& name )
|
|
|
|
{
|
|
|
|
// Icon retrieval
|
|
|
|
////@begin WinEDA_SheetPropertiesFrame icon retrieval
|
2009-06-11 14:26:17 +00:00
|
|
|
wxUnusedVar( name );
|
2007-05-06 16:03:28 +00:00
|
|
|
return wxNullIcon;
|
2009-06-11 14:26:17 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
////@end WinEDA_SheetPropertiesFrame icon retrieval
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-29 12:33:07 +00:00
|
|
|
/** Function SheetPropertiesAccept
|
|
|
|
* Set the new sheets properties:
|
|
|
|
* sheetname and filename (text and size)
|
|
|
|
*/
|
2009-11-04 20:46:53 +00:00
|
|
|
void WinEDA_SheetPropertiesFrame::SheetPropertiesAccept( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
wxFileName fn;
|
2009-06-11 14:26:17 +00:00
|
|
|
wxString msg;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
fn = m_FileNameWin->GetValue();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if( !fn.IsOk() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
DisplayError( this, _( "No Filename! Aborted" ) );
|
|
|
|
EndModal( FALSE );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
fn.SetExt( SchematicFileExtension );
|
2008-03-30 15:12:08 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* m_CurrentSheet->m_AssociatedScreen must be a valide screen, and the
|
|
|
|
* sheet must have a valid associated filename,
|
2008-03-30 15:12:08 +00:00
|
|
|
* so we must call m_CurrentSheet->ChangeFileName to set a filename,
|
2009-11-04 20:46:53 +00:00
|
|
|
* AND always when a new sheet is created ( when
|
|
|
|
* m_CurrentSheet->m_AssociatedScreen is null ),
|
2008-03-30 15:12:08 +00:00
|
|
|
* to create or set an Associated Screen
|
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
if( ( fn.GetFullPath() != m_CurrentSheet->GetFileName() )
|
2009-06-11 14:26:17 +00:00
|
|
|
|| ( m_CurrentSheet->m_AssociatedScreen == NULL) )
|
2008-03-30 15:12:08 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
msg = _( "Changing a Filename can change all the schematic \
|
|
|
|
structures and cannot be undone.\nOk to continue renaming?" );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2008-03-30 15:12:08 +00:00
|
|
|
if( m_CurrentSheet->m_AssociatedScreen == NULL || IsOK( NULL, msg ) )
|
2009-11-04 20:46:53 +00:00
|
|
|
{
|
|
|
|
// do not prompt on a new sheet. in fact, we should not allow a
|
|
|
|
// sheet to be created without a valid associated filename to be
|
|
|
|
// read from.
|
2008-03-30 15:12:08 +00:00
|
|
|
m_Parent->GetScreen()->ClearUndoRedoList();
|
2009-11-04 20:46:53 +00:00
|
|
|
|
|
|
|
// set filename and the associated screen
|
|
|
|
m_CurrentSheet->ChangeFileName( m_Parent, fn.GetFullPath() );
|
2008-03-30 15:12:08 +00:00
|
|
|
}
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
msg = m_FileNameSize->GetValue();
|
|
|
|
m_CurrentSheet->m_FileNameSize =
|
|
|
|
ReturnValueFromString( g_UnitMetric,
|
2009-06-11 14:26:17 +00:00
|
|
|
msg, m_Parent->m_InternalUnits );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
m_CurrentSheet->m_SheetName = m_SheetNameWin->GetValue();
|
|
|
|
msg = m_SheetNameSize->GetValue();
|
|
|
|
m_CurrentSheet->m_SheetNameSize =
|
|
|
|
ReturnValueFromString( g_UnitMetric,
|
2009-06-11 14:26:17 +00:00
|
|
|
msg, m_Parent->m_InternalUnits );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( ( m_CurrentSheet->m_SheetName.IsEmpty() ) )
|
2008-02-28 20:39:04 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
m_CurrentSheet->m_SheetName.Printf( wxT( "Sheet%8.8lX" ),
|
2009-11-04 20:46:53 +00:00
|
|
|
GetTimeStamp() );
|
2008-02-28 20:39:04 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
EndModal( TRUE );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
/* Routine to edit the SheetName and the FileName for the sheet "Sheet" */
|
2009-11-04 20:46:53 +00:00
|
|
|
bool WinEDA_SchematicFrame::EditSheet( SCH_SHEET* Sheet, wxDC* DC )
|
2008-04-14 19:22:48 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
WinEDA_SheetPropertiesFrame* frame;
|
|
|
|
bool edit = TRUE;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Sheet == NULL )
|
|
|
|
return FALSE;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
/* Get the new texts */
|
|
|
|
RedrawOneStruct( DrawPanel, DC, Sheet, g_XorMode );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = TRUE;
|
2007-08-20 01:20:48 +00:00
|
|
|
frame = new WinEDA_SheetPropertiesFrame( this, Sheet );
|
|
|
|
edit = frame->ShowModal(); frame->Destroy();
|
2007-05-06 16:03:28 +00:00
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = FALSE;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
RedrawOneStruct( DrawPanel, DC, Sheet, GR_DEFAULT_DRAWMODE );
|
|
|
|
return edit;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define SHEET_MIN_WIDTH 500
|
|
|
|
#define SHEET_MIN_HEIGHT 150
|
2009-11-04 20:46:53 +00:00
|
|
|
|
|
|
|
/* Create hierarchy sheet. */
|
|
|
|
SCH_SHEET* WinEDA_SchematicFrame::CreateSheet( wxDC* DC )
|
2008-04-14 19:22:48 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
g_ItemToRepeat = NULL;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
SCH_SHEET* Sheet = new SCH_SHEET( GetScreen()->m_Curseur );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Sheet->m_Flags = IS_NEW | IS_RESIZED;
|
2008-02-26 19:19:54 +00:00
|
|
|
Sheet->m_TimeStamp = GetTimeStamp();
|
2008-11-24 06:53:43 +00:00
|
|
|
Sheet->SetParent( GetScreen() );
|
2008-02-26 19:19:54 +00:00
|
|
|
Sheet->m_AssociatedScreen = NULL;
|
2007-08-20 01:20:48 +00:00
|
|
|
s_SheetMindx = SHEET_MIN_WIDTH;
|
|
|
|
s_SheetMindy = SHEET_MIN_HEIGHT;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
//need to check if this is being added to the EEDrawList.
|
2008-02-28 20:39:04 +00:00
|
|
|
//also need to update the hierarchy, if we are adding
|
2008-02-26 19:19:54 +00:00
|
|
|
// a sheet to a screen that already has multiple instances (!)
|
|
|
|
GetScreen()->SetCurItem( Sheet );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->ManageCurseur = DeplaceSheet;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = ExitSheet;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
return Sheet;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
void WinEDA_SchematicFrame::ReSizeSheet( SCH_SHEET* Sheet, wxDC* DC )
|
2008-04-14 19:22:48 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
SCH_SHEET_PIN* sheetlabel;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( Sheet == NULL )
|
|
|
|
return;
|
|
|
|
if( Sheet->m_Flags & IS_NEW )
|
|
|
|
return;
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
if( Sheet->Type() != DRAW_SHEET_STRUCT_TYPE )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
DisplayError( this,
|
|
|
|
wxT( "WinEDA_SchematicFrame::ReSizeSheet: Bad SructType" ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
Sheet->m_Flags |= IS_RESIZED;
|
|
|
|
|
|
|
|
s_OldPos.x = Sheet->m_Size.x;
|
|
|
|
s_OldPos.y = Sheet->m_Size.y;
|
|
|
|
|
|
|
|
s_SheetMindx = SHEET_MIN_WIDTH;
|
|
|
|
s_SheetMindy = SHEET_MIN_HEIGHT;
|
|
|
|
sheetlabel = Sheet->m_Label;
|
|
|
|
while( sheetlabel )
|
|
|
|
{
|
|
|
|
s_SheetMindx = MAX( s_SheetMindx,
|
2009-11-04 20:46:53 +00:00
|
|
|
(int) ( ( sheetlabel->GetLength() + 1 ) *
|
|
|
|
sheetlabel->m_Size.x ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
s_SheetMindy = MAX( s_SheetMindy, sheetlabel->m_Pos.y - Sheet->m_Pos.y );
|
2008-11-24 06:53:43 +00:00
|
|
|
sheetlabel = sheetlabel->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DrawPanel->ManageCurseur = DeplaceSheet;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = ExitSheet;
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
void WinEDA_SchematicFrame::StartMoveSheet( SCH_SHEET* Sheet, wxDC* DC )
|
2008-04-14 19:22:48 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
if( ( Sheet == NULL ) || ( Sheet->Type() != DRAW_SHEET_STRUCT_TYPE ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
DrawPanel->CursorOff( DC );
|
2008-02-12 21:12:46 +00:00
|
|
|
GetScreen()->m_Curseur = Sheet->m_Pos;
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
|
|
|
|
s_OldPos = Sheet->m_Pos;
|
|
|
|
Sheet->m_Flags |= IS_MOVED;
|
|
|
|
DrawPanel->ManageCurseur = DeplaceSheet;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = ExitSheet;
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
|
|
|
|
|
|
|
|
DrawPanel->CursorOn( DC );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Move selected sheet with the cursor.
|
|
|
|
* Callback function use by ManageCurseur.
|
|
|
|
*/
|
2007-08-20 01:20:48 +00:00
|
|
|
static void DeplaceSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
wxPoint move_vector;
|
|
|
|
SCH_SHEET_PIN* SheetLabel;
|
|
|
|
BASE_SCREEN* screen = panel->GetScreen();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
SCH_SHEET* Sheet = (SCH_SHEET*) screen->GetCurItem();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( erase )
|
|
|
|
RedrawOneStruct( panel, DC, Sheet, g_XorMode );
|
|
|
|
|
|
|
|
if( Sheet->m_Flags & IS_RESIZED )
|
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
Sheet->m_Size.x =
|
|
|
|
MAX( s_SheetMindx, screen->m_Curseur.x - Sheet->m_Pos.x );
|
|
|
|
Sheet->m_Size.y =
|
|
|
|
MAX( s_SheetMindy, screen->m_Curseur.y - Sheet->m_Pos.y );
|
2007-08-20 01:20:48 +00:00
|
|
|
SheetLabel = Sheet->m_Label;
|
|
|
|
while( SheetLabel )
|
|
|
|
{
|
|
|
|
if( SheetLabel->m_Edge )
|
|
|
|
SheetLabel->m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x;
|
2008-11-24 06:53:43 +00:00
|
|
|
SheetLabel = SheetLabel->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
2008-02-29 12:33:07 +00:00
|
|
|
else /* Move Sheet */
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-07-27 14:32:40 +00:00
|
|
|
move_vector = screen->m_Curseur - Sheet->m_Pos;
|
|
|
|
Sheet->Move( move_vector );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RedrawOneStruct( panel, DC, Sheet, g_XorMode );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Complete sheet move. */
|
2007-08-20 01:20:48 +00:00
|
|
|
static void ExitSheet( WinEDA_DrawPanel* Panel, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
SCH_SCREEN* Screen = (SCH_SCREEN*) Panel->GetScreen();
|
|
|
|
SCH_SHEET* Sheet = (SCH_SHEET*) Screen->GetCurItem();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( Sheet == NULL )
|
|
|
|
return;
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
if( Sheet->m_Flags & IS_NEW )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
RedrawOneStruct( Panel, DC, Sheet, g_XorMode );
|
2008-02-26 19:19:54 +00:00
|
|
|
SAFE_DELETE( Sheet );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2009-11-04 20:46:53 +00:00
|
|
|
else if( Sheet->m_Flags & IS_RESIZED )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Resize in progress, cancel move. */
|
2007-08-20 01:20:48 +00:00
|
|
|
RedrawOneStruct( Panel, DC, Sheet, g_XorMode );
|
|
|
|
Sheet->m_Size.x = s_OldPos.x;
|
|
|
|
Sheet->m_Size.y = s_OldPos.y;
|
|
|
|
RedrawOneStruct( Panel, DC, Sheet, GR_DEFAULT_DRAWMODE );
|
|
|
|
Sheet->m_Flags = 0;
|
|
|
|
}
|
2009-11-04 20:46:53 +00:00
|
|
|
else if( Sheet->m_Flags & IS_MOVED )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-06-11 14:26:17 +00:00
|
|
|
wxPoint curspos = Screen->m_Curseur;
|
2008-04-17 16:25:29 +00:00
|
|
|
Panel->GetScreen()->m_Curseur = s_OldPos;
|
2007-08-20 01:20:48 +00:00
|
|
|
DeplaceSheet( Panel, DC, TRUE );
|
|
|
|
RedrawOneStruct( Panel, DC, Sheet, GR_DEFAULT_DRAWMODE );
|
|
|
|
Sheet->m_Flags = 0;
|
|
|
|
Screen->m_Curseur = curspos;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Sheet->m_Flags = 0;
|
|
|
|
|
|
|
|
Screen->SetCurItem( NULL );
|
|
|
|
Panel->ManageCurseur = NULL;
|
|
|
|
Panel->ForceCloseManageCurseur = NULL;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
|
|
|
|
*/
|
|
|
|
|
|
|
|
void WinEDA_SheetPropertiesFrame::OnCancelClick( wxCommandEvent& event )
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
EndModal( 0 );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
|
|
|
|
*/
|
|
|
|
|
|
|
|
void WinEDA_SheetPropertiesFrame::OnOkClick( wxCommandEvent& event )
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
SheetPropertiesAccept( event );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|