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
|
2007-08-20 01:20:48 +00:00
|
|
|
// Licence:
|
2007-05-06 16:03:28 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Generated by DialogBlocks (unregistered), 08/02/2006 18:37:02
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
#if defined (__GNUG__) && !defined (NO_GCC_PRAGMA)
|
2007-05-06 16:03:28 +00:00
|
|
|
#pragma implementation "sheet.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 "gr_basic.h"
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "program.h"
|
|
|
|
#include "libcmp.h"
|
|
|
|
#include "general.h"
|
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
/* Routines Locales */
|
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
|
|
|
|
|
|
|
/* Variables locales */
|
2007-08-20 01:20:48 +00:00
|
|
|
static int s_SheetMindx, s_SheetMindy;
|
|
|
|
static wxPoint s_OldPos; /* Ancienne pos pour annulation ReSize ou move */
|
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
|
2007-08-20 01:20:48 +00:00
|
|
|
EVT_BUTTON( wxID_CANCEL, WinEDA_SheetPropertiesFrame::OnCancelClick )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +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
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
WinEDA_SheetPropertiesFrame::WinEDA_SheetPropertiesFrame( WinEDA_SchematicFrame* parent,
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawSheetStruct* 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,
|
|
|
|
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,
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
|
2007-08-20 01:20:48 +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
|
2007-08-20 01:20:48 +00:00
|
|
|
m_FileNameWin = NULL;
|
|
|
|
m_SheetNameWin = NULL;
|
|
|
|
m_FileNameTextSize = NULL;
|
|
|
|
m_FileNameSize = NULL;
|
2007-05-06 16:03:28 +00:00
|
|
|
m_SheetNameTextSize = NULL;
|
2007-08-20 01:20:48 +00:00
|
|
|
m_SheetNameSize = NULL;
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
////@end WinEDA_SheetPropertiesFrame member initialisation
|
|
|
|
|
|
|
|
////@begin WinEDA_SheetPropertiesFrame creation
|
2007-08-20 01:20:48 +00:00
|
|
|
SetExtraStyle( GetExtraStyle() | wxWS_EX_BLOCK_EVENTS );
|
2007-05-06 16:03:28 +00:00
|
|
|
wxDialog::Create( parent, id, caption, pos, size, style );
|
|
|
|
|
|
|
|
CreateControls();
|
2007-08-20 01:20:48 +00:00
|
|
|
GetSizer()->Fit( this );
|
|
|
|
GetSizer()->SetSizeHints( this );
|
2007-05-06 16:03:28 +00:00
|
|
|
Centre();
|
2007-08-20 01:20:48 +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
|
|
|
{
|
|
|
|
SetFont( *g_DialogFont );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
////@begin WinEDA_SheetPropertiesFrame content construction
|
|
|
|
// Generated by DialogBlocks, 27/02/2006 14:12:10 (unregistered)
|
|
|
|
|
|
|
|
WinEDA_SheetPropertiesFrame* itemDialog1 = this;
|
|
|
|
|
2007-08-20 01:20:48 +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 );
|
|
|
|
|
|
|
|
wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, wxID_STATIC, _(
|
|
|
|
"Filename:" ), wxDefaultPosition,
|
|
|
|
wxDefaultSize, 0 );
|
|
|
|
itemBoxSizer4->Add( itemStaticText5,
|
|
|
|
0,
|
|
|
|
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
|
|
|
|
5 );
|
|
|
|
|
|
|
|
m_FileNameWin = 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 );
|
|
|
|
itemBoxSizer4->Add( itemStaticText7,
|
|
|
|
0,
|
|
|
|
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
|
|
|
|
5 );
|
|
|
|
|
|
|
|
m_SheetNameWin = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T( "" ), wxDefaultPosition,
|
|
|
|
wxSize( 300, -1 ), 0 );
|
|
|
|
itemBoxSizer4->Add( m_SheetNameWin, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
|
|
|
|
|
|
|
|
wxBoxSizer* itemBoxSizer9 = new wxBoxSizer( wxVERTICAL );
|
|
|
|
itemBoxSizer3->Add( itemBoxSizer9, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
|
|
|
|
|
|
|
m_FileNameTextSize = new wxStaticText( itemDialog1, wxID_STATIC, _(
|
|
|
|
"Size" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
itemBoxSizer9->Add( m_FileNameTextSize,
|
|
|
|
0,
|
|
|
|
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
|
|
|
|
5 );
|
|
|
|
|
|
|
|
m_FileNameSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL2, _T(
|
|
|
|
"" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
itemBoxSizer9->Add( m_FileNameSize, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
|
|
|
|
|
|
|
|
m_SheetNameTextSize = new wxStaticText( itemDialog1, wxID_STATIC, _(
|
|
|
|
"Size" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
itemBoxSizer9->Add( m_SheetNameTextSize,
|
|
|
|
0,
|
|
|
|
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
|
|
|
|
5 );
|
|
|
|
|
|
|
|
m_SheetNameSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL3, _T(
|
|
|
|
"" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
itemBoxSizer9->Add( m_SheetNameSize, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
|
|
|
|
|
|
|
|
itemBoxSizer2->Add( 5, 5, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 );
|
|
|
|
|
|
|
|
wxBoxSizer* itemBoxSizer15 = new wxBoxSizer( wxHORIZONTAL );
|
|
|
|
itemBoxSizer2->Add( itemBoxSizer15, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 );
|
|
|
|
|
|
|
|
wxButton* itemButton16 = new wxButton( itemDialog1, wxID_CANCEL, _(
|
|
|
|
"&Cancel" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
itemButton16->SetForegroundColour( wxColour( 0, 0, 255 ) );
|
|
|
|
itemBoxSizer15->Add( itemButton16, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
|
|
|
|
|
|
|
wxButton* itemButton17 = new wxButton( itemDialog1, wxID_OK, _(
|
|
|
|
"&OK" ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
itemButton17->SetForegroundColour( wxColour( 196, 0, 0 ) );
|
|
|
|
itemBoxSizer15->Add( itemButton17, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
// Set validators
|
2007-08-20 01:20:48 +00:00
|
|
|
m_FileNameWin->SetValidator( wxTextValidator( wxFILTER_NONE, &m_CurrentSheet->m_FileName ) );
|
|
|
|
m_SheetNameWin->SetValidator( wxTextValidator( wxFILTER_NONE, &m_CurrentSheet->m_SheetName ) );
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
////@end WinEDA_SheetPropertiesFrame content construction
|
|
|
|
}
|
|
|
|
|
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
|
2007-08-20 01:20:48 +00:00
|
|
|
wxUnusedVar( name );
|
2007-05-06 16:03:28 +00:00
|
|
|
return wxNullBitmap;
|
2007-08-20 01:20:48 +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
|
2007-08-20 01:20:48 +00:00
|
|
|
wxUnusedVar( name );
|
2007-05-06 16:03:28 +00:00
|
|
|
return wxNullIcon;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
////@end WinEDA_SheetPropertiesFrame icon retrieval
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_SheetPropertiesFrame::SheetPropertiesAccept( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
wxString FileName, msg;
|
|
|
|
|
|
|
|
FileName = m_FileNameWin->GetValue();
|
|
|
|
FileName.Trim( FALSE ); FileName.Trim( TRUE );
|
|
|
|
|
|
|
|
if( FileName.IsEmpty() )
|
|
|
|
{
|
|
|
|
DisplayError( this, _( "No Filename! Aborted" ) );
|
|
|
|
EndModal( FALSE );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ChangeFileNameExt( FileName, g_SchExtBuffer );
|
|
|
|
|
|
|
|
if( m_CurrentSheet->m_FileName != FileName )
|
|
|
|
{
|
|
|
|
m_CurrentSheet->m_FileName = FileName;
|
|
|
|
|
|
|
|
if( wxFileExists( FileName ) ) /* do we reload the data from the existing file */
|
|
|
|
{
|
|
|
|
msg.Printf( _( "A file named %s exists, load it ?" ), FileName.GetData() );
|
|
|
|
if( IsOK( this, msg ) )
|
|
|
|
{
|
|
|
|
m_Parent->LoadOneSheet( m_CurrentSheet, FileName );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
msg = m_FileNameSize->GetValue();
|
|
|
|
m_CurrentSheet->m_FileNameSize =
|
|
|
|
ReturnValueFromString( g_UnitMetric,
|
|
|
|
msg, m_Parent->m_InternalUnits );
|
|
|
|
|
|
|
|
m_CurrentSheet->m_SheetName = m_SheetNameWin->GetValue();
|
|
|
|
msg = m_SheetNameSize->GetValue();
|
|
|
|
m_CurrentSheet->m_SheetNameSize =
|
|
|
|
ReturnValueFromString( g_UnitMetric,
|
|
|
|
msg, m_Parent->m_InternalUnits );
|
|
|
|
|
|
|
|
if( ( m_CurrentSheet->m_SheetName.IsEmpty() ) )
|
|
|
|
m_CurrentSheet->m_SheetName = m_CurrentSheet->m_FileName;
|
|
|
|
|
|
|
|
|
|
|
|
EndModal( TRUE );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
bool WinEDA_SchematicFrame::EditSheet( DrawSheetStruct* Sheet, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*************************************************************************/
|
2007-05-28 18:09:49 +00:00
|
|
|
/* Routine to edit the SheetName and the FileName for the sheet "Sheet" */
|
2007-05-06 16:03:28 +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
|
|
|
|
/****************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawSheetStruct* WinEDA_SchematicFrame::CreateSheet( wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/****************************************************************/
|
|
|
|
/* Routine de Creation d'une feuille de hierarchie (Sheet) */
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
g_ItemToRepeat = NULL;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawSheetStruct* Sheet = new DrawSheetStruct( m_CurrentScreen->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;
|
|
|
|
Sheet->m_TimeStamp = GetTimeStamp();
|
|
|
|
Sheet->m_Parent = m_CurrentScreen;
|
|
|
|
s_SheetMindx = SHEET_MIN_WIDTH;
|
|
|
|
s_SheetMindy = SHEET_MIN_HEIGHT;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
m_CurrentScreen->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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_SchematicFrame::ReSizeSheet( DrawSheetStruct* Sheet, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*******************************************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawSheetLabelStruct* sheetlabel;
|
|
|
|
|
|
|
|
if( Sheet == NULL )
|
|
|
|
return;
|
|
|
|
if( Sheet->m_Flags & IS_NEW )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( Sheet->m_StructType != DRAW_SHEET_STRUCT_TYPE )
|
|
|
|
{
|
|
|
|
DisplayError( this, wxT( "WinEDA_SchematicFrame::ReSizeSheet: Bad SructType" ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
Sheet->m_Flags |= IS_RESIZED;
|
|
|
|
|
|
|
|
/* sauvegarde des anciennes valeurs */
|
|
|
|
s_OldPos.x = Sheet->m_Size.x;
|
|
|
|
s_OldPos.y = Sheet->m_Size.y;
|
|
|
|
|
|
|
|
/* Recalcul des dims min de la sheet */
|
|
|
|
s_SheetMindx = SHEET_MIN_WIDTH;
|
|
|
|
s_SheetMindy = SHEET_MIN_HEIGHT;
|
|
|
|
sheetlabel = Sheet->m_Label;
|
|
|
|
while( sheetlabel )
|
|
|
|
{
|
|
|
|
s_SheetMindx = MAX( s_SheetMindx,
|
|
|
|
(int) ( (sheetlabel->GetLength() + 1) * sheetlabel->m_Size.x ) );
|
|
|
|
s_SheetMindy = MAX( s_SheetMindy, sheetlabel->m_Pos.y - Sheet->m_Pos.y );
|
|
|
|
sheetlabel = (DrawSheetLabelStruct*) sheetlabel->Pnext;
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawPanel->ManageCurseur = DeplaceSheet;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = ExitSheet;
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_SchematicFrame::StartMoveSheet( DrawSheetStruct* Sheet, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*********************************************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( (Sheet == NULL) || ( Sheet->m_StructType != DRAW_SHEET_STRUCT_TYPE) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
DrawPanel->CursorOff( DC );
|
|
|
|
m_CurrentScreen->m_Curseur = Sheet->m_Pos;
|
|
|
|
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
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/********************************************************/
|
|
|
|
/*** Routine de deplacement Sheet, lie au curseur. */
|
|
|
|
/* Appele par GeneralControle grace a 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
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
wxPoint move_vector;
|
|
|
|
DrawSheetLabelStruct* SheetLabel;
|
|
|
|
BASE_SCREEN* screen = panel->m_Parent->m_CurrentScreen;
|
|
|
|
|
|
|
|
DrawSheetStruct* Sheet = (DrawSheetStruct*)
|
|
|
|
screen->GetCurItem();
|
|
|
|
|
|
|
|
/* Effacement du composant: tj apres depl curseur */
|
|
|
|
if( erase )
|
|
|
|
RedrawOneStruct( panel, DC, Sheet, g_XorMode );
|
|
|
|
|
|
|
|
if( Sheet->m_Flags & IS_RESIZED )
|
|
|
|
{
|
|
|
|
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 );
|
|
|
|
SheetLabel = Sheet->m_Label;
|
|
|
|
while( SheetLabel )
|
|
|
|
{
|
|
|
|
if( SheetLabel->m_Edge )
|
|
|
|
SheetLabel->m_Pos.x = Sheet->m_Pos.x + Sheet->m_Size.x;
|
|
|
|
SheetLabel = (DrawSheetLabelStruct*) SheetLabel->Pnext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* Move Sheet */
|
|
|
|
{
|
|
|
|
move_vector.x = screen->m_Curseur.x - Sheet->m_Pos.x;
|
|
|
|
move_vector.y = screen->m_Curseur.y - Sheet->m_Pos.y;
|
|
|
|
MoveOneStruct( Sheet, move_vector );
|
|
|
|
}
|
|
|
|
|
|
|
|
RedrawOneStruct( panel, DC, Sheet, g_XorMode );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void DrawSheetStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/****************************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
/* Placement en liste des structures si nouveau composant:*/
|
|
|
|
if( m_Flags & IS_NEW )
|
|
|
|
{
|
|
|
|
if( !( (WinEDA_SchematicFrame*) frame )->EditSheet( this, DC ) )
|
|
|
|
{
|
|
|
|
frame->m_CurrentScreen->SetCurItem( NULL );
|
|
|
|
frame->DrawPanel->ManageCurseur = NULL;
|
|
|
|
frame->DrawPanel->ForceCloseManageCurseur = NULL;
|
|
|
|
RedrawOneStruct( frame->DrawPanel, DC, this, g_XorMode );
|
|
|
|
delete this;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if( wxFileExists( m_FileName ) )
|
|
|
|
{
|
|
|
|
( (WinEDA_SchematicFrame*) frame )->LoadOneSheet(
|
|
|
|
this, m_FileName );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EDA_BaseStruct::Place( frame, DC );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/****************************************/
|
|
|
|
/* Routine de sortie du Menu de Sheet */
|
|
|
|
/****************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
static void ExitSheet( WinEDA_DrawPanel* Panel, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
SCH_SCREEN* Screen = (SCH_SCREEN*) Panel->m_Parent->m_CurrentScreen;
|
|
|
|
DrawSheetStruct* Sheet = (DrawSheetStruct*) Screen->GetCurItem();
|
|
|
|
|
|
|
|
if( Sheet == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Deplacement composant en cours */
|
|
|
|
if( Sheet->m_Flags & IS_NEW ) /* Nouveau Placement en cours, on l'efface */
|
|
|
|
{
|
|
|
|
RedrawOneStruct( Panel, DC, Sheet, g_XorMode );
|
|
|
|
delete Sheet;
|
|
|
|
}
|
|
|
|
else if( Sheet->m_Flags & IS_RESIZED )/* resize en cours: on l'annule */
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
else if( Sheet->m_Flags & IS_MOVED )/* move en cours: on l'annule */
|
|
|
|
{
|
|
|
|
wxPoint curspos = Screen->m_Curseur;
|
|
|
|
Panel->m_Parent->m_CurrentScreen->m_Curseur = s_OldPos;
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/********************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* frame, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
/********************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* Delete pinsheets which are not corresponding to a Global label
|
2007-08-20 01:20:48 +00:00
|
|
|
* if DC != NULL, redraw Sheet
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawSheetLabelStruct* Pinsheet, * NextPinsheet;
|
|
|
|
|
|
|
|
if( !IsOK( frame, _( "Ok to cleanup this sheet" ) ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
Pinsheet = m_Label;
|
|
|
|
while( Pinsheet )
|
|
|
|
{
|
|
|
|
/* Search Glabel corresponding to this Pinsheet */
|
|
|
|
|
|
|
|
EDA_BaseStruct* DrawStruct = EEDrawList;
|
|
|
|
DrawGlobalLabelStruct* GLabel = NULL;
|
|
|
|
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext )
|
|
|
|
{
|
|
|
|
if( DrawStruct->m_StructType != DRAW_GLOBAL_LABEL_STRUCT_TYPE )
|
|
|
|
continue;
|
|
|
|
GLabel = (DrawGlobalLabelStruct*) DrawStruct;
|
|
|
|
if( Pinsheet->m_Text.CmpNoCase( GLabel->m_Text ) == 0 )
|
|
|
|
break; // Found!
|
|
|
|
GLabel = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
NextPinsheet = (DrawSheetLabelStruct*) Pinsheet->Pnext;
|
|
|
|
if( GLabel == NULL ) // Glabel not found: delete pinsheet
|
|
|
|
{
|
|
|
|
frame->GetScreen()->SetModify();
|
|
|
|
frame->DeleteSheetLabel( DC, Pinsheet );
|
|
|
|
}
|
|
|
|
Pinsheet = NextPinsheet;
|
|
|
|
}
|
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_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 );
|
|
|
|
EndModal( 1 );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|