Commit 76737d56 authored by charras's avatar charras

Eeschema: fixed some issues in undo/redo and ESC commands related to...

Eeschema: fixed some issues in undo/redo and ESC commands related to hierarchical sheets; Work in progress
parent 7fb88ad5
......@@ -21,6 +21,8 @@ class DIALOG_LIBEDIT_DIMENSIONS : public DIALOG_LIBEDIT_DIMENSIONS_BASE
public:
DIALOG_LIBEDIT_DIMENSIONS( WinEDA_LibeditFrame* parent);
~DIALOG_LIBEDIT_DIMENSIONS();
private:
void initDialog( );
};
......@@ -33,10 +35,16 @@ void WinEDA_LibeditFrame::InstallDimensionsDialog( wxCommandEvent& event )
DIALOG_LIBEDIT_DIMENSIONS::DIALOG_LIBEDIT_DIMENSIONS( WinEDA_LibeditFrame* parent )
: DIALOG_LIBEDIT_DIMENSIONS_BASE( parent )
{
this->Centre( wxBOTH );
GetSizer()->SetSizeHints(this);
Centre( wxBOTH );
}
DIALOG_LIBEDIT_DIMENSIONS::~DIALOG_LIBEDIT_DIMENSIONS()
{
}
void DIALOG_LIBEDIT_DIMENSIONS::initDialog()
{
SetFocus( );
}
......@@ -9,15 +9,18 @@
///////////////////////////////////////////////////////////////////////////
BEGIN_EVENT_TABLE( DIALOG_LIBEDIT_DIMENSIONS_BASE, wxDialog )
EVT_BUTTON( wxID_ANY, DIALOG_LIBEDIT_DIMENSIONS_BASE::_wxFB_OnSaveSetupClick )
EVT_BUTTON( wxID_CANCEL, DIALOG_LIBEDIT_DIMENSIONS_BASE::_wxFB_OnCancelClick )
EVT_BUTTON( wxID_OK, DIALOG_LIBEDIT_DIMENSIONS_BASE::_wxFB_OnOkClick )
END_EVENT_TABLE()
DIALOG_LIBEDIT_DIMENSIONS_BASE::DIALOG_LIBEDIT_DIMENSIONS_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* mainSizer;
mainSizer = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bSizerMain;
bSizerMain = new wxBoxSizer( wxVERTICAL );
mainSizer = new wxBoxSizer( wxVERTICAL );
wxFlexGridSizer* fgSizer1;
fgSizer1 = new wxFlexGridSizer( 7, 3, 0, 0 );
......@@ -31,7 +34,7 @@ DIALOG_LIBEDIT_DIMENSIONS_BASE::DIALOG_LIBEDIT_DIMENSIONS_BASE( wxWindow* parent
m_staticText3->Wrap( -1 );
fgSizer1->Add( m_staticText3, 1, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
wxString m_choiceGridSizeChoices[] = { _("100"), _("50"), _("25"), _("10"), _("5"), _("2"), _("1") };
wxString m_choiceGridSizeChoices[] = { _("50"), _("25"), _("10"), _("5"), _("2"), _("1") };
int m_choiceGridSizeNChoices = sizeof( m_choiceGridSizeChoices ) / sizeof( wxString );
m_choiceGridSize = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceGridSizeNChoices, m_choiceGridSizeChoices, 0 );
m_choiceGridSize->SetSelection( 0 );
......@@ -67,7 +70,7 @@ DIALOG_LIBEDIT_DIMENSIONS_BASE::DIALOG_LIBEDIT_DIMENSIONS_BASE( wxWindow* parent
m_staticText9->Wrap( -1 );
fgSizer1->Add( m_staticText9, 1, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
wxString m_choiceRepeatHorizontalChoices[] = { _("100"), _("50") };
wxString m_choiceRepeatHorizontalChoices[] = { _("50"), _("25") };
int m_choiceRepeatHorizontalNChoices = sizeof( m_choiceRepeatHorizontalChoices ) / sizeof( wxString );
m_choiceRepeatHorizontal = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceRepeatHorizontalNChoices, m_choiceRepeatHorizontalChoices, 0 );
m_choiceRepeatHorizontal->SetSelection( 0 );
......@@ -81,7 +84,7 @@ DIALOG_LIBEDIT_DIMENSIONS_BASE::DIALOG_LIBEDIT_DIMENSIONS_BASE( wxWindow* parent
m_staticText12->Wrap( -1 );
fgSizer1->Add( m_staticText12, 1, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
wxString m_choiceRepeatVerticalChoices[] = { _("100"), _("50") };
wxString m_choiceRepeatVerticalChoices[] = { _("50"), _("25") };
int m_choiceRepeatVerticalNChoices = sizeof( m_choiceRepeatVerticalChoices ) / sizeof( wxString );
m_choiceRepeatVertical = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceRepeatVerticalNChoices, m_choiceRepeatVerticalChoices, 0 );
m_choiceRepeatVertical->SetSelection( 0 );
......@@ -91,7 +94,7 @@ DIALOG_LIBEDIT_DIMENSIONS_BASE::DIALOG_LIBEDIT_DIMENSIONS_BASE( wxWindow* parent
m_staticRepeatYUnits->Wrap( -1 );
fgSizer1->Add( m_staticRepeatYUnits, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
m_staticText15 = new wxStaticText( this, wxID_ANY, _("Current &pin lenght"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText15 = new wxStaticText( this, wxID_ANY, _("Current &pin lenght:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText15->Wrap( -1 );
fgSizer1->Add( m_staticText15, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
......@@ -102,7 +105,7 @@ DIALOG_LIBEDIT_DIMENSIONS_BASE::DIALOG_LIBEDIT_DIMENSIONS_BASE( wxWindow* parent
m_staticText161->Wrap( -1 );
fgSizer1->Add( m_staticText161, 0, wxALL, 5 );
m_CurrentPinNameSizeText = new wxStaticText( this, wxID_ANY, _("Current pin name size"), wxDefaultPosition, wxDefaultSize, 0 );
m_CurrentPinNameSizeText = new wxStaticText( this, wxID_ANY, _("Current pin name size:"), wxDefaultPosition, wxDefaultSize, 0 );
m_CurrentPinNameSizeText->Wrap( -1 );
fgSizer1->Add( m_CurrentPinNameSizeText, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
......@@ -113,7 +116,7 @@ DIALOG_LIBEDIT_DIMENSIONS_BASE::DIALOG_LIBEDIT_DIMENSIONS_BASE( wxWindow* parent
m_staticText18->Wrap( -1 );
fgSizer1->Add( m_staticText18, 0, wxALL, 5 );
m_CurrentPinNumberSizeText = new wxStaticText( this, wxID_ANY, _("Current pin number size"), wxDefaultPosition, wxDefaultSize, 0 );
m_CurrentPinNumberSizeText = new wxStaticText( this, wxID_ANY, _("Current pin number size:"), wxDefaultPosition, wxDefaultSize, 0 );
m_CurrentPinNumberSizeText->Wrap( -1 );
fgSizer1->Add( m_CurrentPinNumberSizeText, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
......@@ -134,10 +137,16 @@ DIALOG_LIBEDIT_DIMENSIONS_BASE::DIALOG_LIBEDIT_DIMENSIONS_BASE( wxWindow* parent
fgSizer1->Add( 0, 0, 1, wxALIGN_CENTER_VERTICAL|wxEXPAND, 3 );
bSizerMain->Add( fgSizer1, 0, wxALIGN_CENTER|wxEXPAND, 0 );
mainSizer->Add( fgSizer1, 0, wxALIGN_CENTER|wxEXPAND, 0 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerMain->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 );
mainSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 );
wxBoxSizer* bSizerBttons;
bSizerBttons = new wxBoxSizer( wxHORIZONTAL );
m_buttonSave = new wxButton( this, wxID_ANY, _("Save as Default"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerBttons->Add( m_buttonSave, 0, wxALL, 5 );
m_sdbSizer1 = new wxStdDialogButtonSizer();
m_sdbSizer1OK = new wxButton( this, wxID_OK );
......@@ -145,9 +154,9 @@ DIALOG_LIBEDIT_DIMENSIONS_BASE::DIALOG_LIBEDIT_DIMENSIONS_BASE( wxWindow* parent
m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer1->AddButton( m_sdbSizer1Cancel );
m_sdbSizer1->Realize();
bSizerMain->Add( m_sdbSizer1, 0, wxALL|wxEXPAND, 0 );
bSizerBttons->Add( m_sdbSizer1, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 0 );
mainSizer->Add( bSizerMain, 1, wxALL|wxEXPAND, 12 );
mainSizer->Add( bSizerBttons, 0, wxALIGN_RIGHT, 5 );
this->SetSizer( mainSizer );
this->Layout();
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -31,7 +31,14 @@
///////////////////////////////////////////////////////////////////////////////
class DIALOG_LIBEDIT_DIMENSIONS_BASE : public wxDialog
{
DECLARE_EVENT_TABLE()
private:
// Private event handlers
void _wxFB_OnSaveSetupClick( wxCommandEvent& event ){ OnSaveSetupClick( event ); }
void _wxFB_OnCancelClick( wxCommandEvent& event ){ OnCancelClick( event ); }
void _wxFB_OnOkClick( wxCommandEvent& event ){ OnOkClick( event ); }
protected:
wxStaticText* m_staticText3;
......@@ -62,12 +69,19 @@ class DIALOG_LIBEDIT_DIMENSIONS_BASE : public wxDialog
wxSpinCtrl* m_spinRepeatLabel;
wxStaticLine* m_staticline1;
wxButton* m_buttonSave;
wxStdDialogButtonSizer* m_sdbSizer1;
wxButton* m_sdbSizer1OK;
wxButton* m_sdbSizer1Cancel;
// Virtual event handlers, overide them in your derived class
virtual void OnSaveSetupClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ){ event.Skip(); }
public:
DIALOG_LIBEDIT_DIMENSIONS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Library Editor Options"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 412,358 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
DIALOG_LIBEDIT_DIMENSIONS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Library Editor Options"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 412,349 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_LIBEDIT_DIMENSIONS_BASE();
};
......
......@@ -70,13 +70,6 @@ void DeleteItemsInList( WinEDA_DrawPanel* panel, PICKED_ITEMS_LIST& aItemsList )
/* this item is depending on a sheet, and is not in global list */
wxMessageBox( wxT( "DeleteItemsInList() err: unexpected \
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE" ) );
#if 0
SCH_SHEET_PIN* pinlabel = (SCH_SHEET_PIN*) item;
frame->DeleteSheetLabel( false, pinlabel->m_Parent );
itemWrapper.m_PickedItem = pinlabel->m_Parent;
itemWrapper.m_UndoRedoStatus = UR_CHANGED;
itemsList.PushItem( itemWrapper );
#endif
}
else
{
......
......@@ -180,6 +180,36 @@ void SwapData( EDA_BaseStruct* aItem, EDA_BaseStruct* aImage )
}
/** function CloneStruct
* must be used only in undo/redo functions
*
* Routine to create a new copy of given schatic object.
* It does the same job as DuplicateStruct, but
* but clone time stamp and sheet name when cloning a SCH_SHEET objects
* (because time stamp and sheets name must be unique
* DuplicateStruct does not copy these members
*/
static SCH_ITEM* CloneStruct( SCH_ITEM* aDrawStruct )
{
SCH_ITEM* item = DuplicateStruct( aDrawStruct );
if( item == NULL )
return NULL;
item->m_TimeStamp = aDrawStruct->m_TimeStamp;
switch( item->Type() )
{
case DRAW_SHEET_STRUCT_TYPE:
((SCH_SHEET*)item)->m_SheetName = ((SCH_SHEET*)aDrawStruct)->m_SheetName;
break;
default:
break;
}
return item;
}
/** function SaveCopyInUndoList
* Create a copy of the current schematic item, and put it in the undo list.
*
......@@ -230,7 +260,7 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* aItem,
switch( aCommandType )
{
case UR_CHANGED: /* Create a copy of item */
CopyOfItem = DuplicateStruct( aItem );
CopyOfItem = CloneStruct( aItem );
itemWrapper.m_Link = CopyOfItem;
if ( CopyOfItem )
commandToUndo->PushItem( itemWrapper );
......@@ -300,7 +330,7 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
* If this link is not null, the copy is already done
*/
if( commandToUndo->GetPickedItemLink(ii) == NULL )
commandToUndo->SetPickedItemLink( DuplicateStruct( item ), ii );
commandToUndo->SetPickedItemLink( CloneStruct( item ), ii );
wxASSERT( commandToUndo->GetPickedItemLink(ii) );
break;
......
......@@ -138,7 +138,7 @@ structures and cannot be undone.\nOk to continue renaming?" );
/* Move selected sheet with the cursor.
* Callback function use by ManageCurseur.
*/
static void MoveSheet( WinEDA_DrawPanel* aPanel, wxDC* aDC, bool aErase )
static void MoveOrResizeSheet( WinEDA_DrawPanel* aPanel, wxDC* aDC, bool aErase )
{
wxPoint moveVector;
SCH_SHEET_PIN* sheetLabel;
......@@ -185,20 +185,11 @@ static void ExitSheet( WinEDA_DrawPanel* aPanel, wxDC* aDC )
RedrawOneStruct( aPanel, aDC, sheet, g_XorMode );
SAFE_DELETE( sheet );
}
else if( sheet->m_Flags & IS_RESIZED )
{
/* Resize in progress, cancel move. */
RedrawOneStruct( aPanel, aDC, sheet, g_XorMode );
sheet->m_Size.x = s_OldPos.x;
sheet->m_Size.y = s_OldPos.y;
RedrawOneStruct( aPanel, aDC, sheet, GR_DEFAULT_DRAWMODE );
sheet->m_Flags = 0;
}
else if( sheet->m_Flags & IS_MOVED )
else if( (sheet->m_Flags & (IS_RESIZED|IS_MOVED)) )
{
wxPoint curspos = screen->m_Curseur;
aPanel->GetScreen()->m_Curseur = s_OldPos;
MoveSheet( aPanel, aDC, true );
MoveOrResizeSheet( aPanel, aDC, true );
RedrawOneStruct( aPanel, aDC, sheet, GR_DEFAULT_DRAWMODE );
sheet->m_Flags = 0;
screen->m_Curseur = curspos;
......@@ -237,7 +228,7 @@ SCH_SHEET* WinEDA_SchematicFrame::CreateSheet( wxDC* aDC )
// a sheet to a screen that already has multiple instances (!)
GetScreen()->SetCurItem( sheet );
DrawPanel->ManageCurseur = MoveSheet;
DrawPanel->ManageCurseur = MoveOrResizeSheet;
DrawPanel->ForceCloseManageCurseur = ExitSheet;
DrawPanel->ManageCurseur( DrawPanel, aDC, false );
......@@ -263,8 +254,7 @@ void WinEDA_SchematicFrame::ReSizeSheet( SCH_SHEET* aSheet, wxDC* aDC )
OnModify( );
aSheet->m_Flags |= IS_RESIZED;
s_OldPos.x = aSheet->m_Size.x;
s_OldPos.y = aSheet->m_Size.y;
s_OldPos = aSheet->m_Pos + aSheet->m_Size;
s_PreviousSheetWidth = SHEET_MIN_WIDTH;
s_PreviousSheetHeight = SHEET_MIN_HEIGHT;
......@@ -280,7 +270,7 @@ void WinEDA_SchematicFrame::ReSizeSheet( SCH_SHEET* aSheet, wxDC* aDC )
sheetLabel = sheetLabel->Next();
}
DrawPanel->ManageCurseur = MoveSheet;
DrawPanel->ManageCurseur = MoveOrResizeSheet;
DrawPanel->ForceCloseManageCurseur = ExitSheet;
DrawPanel->ManageCurseur( DrawPanel, aDC, true );
}
......@@ -297,7 +287,7 @@ void WinEDA_SchematicFrame::StartMoveSheet( SCH_SHEET* aSheet, wxDC* aDC )
s_OldPos = aSheet->m_Pos;
aSheet->m_Flags |= IS_MOVED;
DrawPanel->ManageCurseur = MoveSheet;
DrawPanel->ManageCurseur = MoveOrResizeSheet;
DrawPanel->ForceCloseManageCurseur = ExitSheet;
DrawPanel->ManageCurseur( DrawPanel, aDC, true );
DrawPanel->CursorOn( aDC );
......
......@@ -19,6 +19,8 @@ static void Move_PinSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static int s_CurrentTypeLabel = NET_INPUT;
static wxSize NetSheetTextSize( DEFAULT_SIZE_TEXT, DEFAULT_SIZE_TEXT );
static wxPoint s_InitialPosition; // remember here the initial value of the pin label when moving it
/****************************************/
/* class WinEDA_PinSheetPropertiesFrame */
......@@ -126,7 +128,9 @@ void WinEDA_PinSheetPropertiesFrame::OnOkClick( wxCommandEvent& event )
EndModal( wxID_OK );
}
/* Called when aborting a move pinsheet label
* delete a new pin sheet label, or restire its old position
*/
static void ExitPinSheet( WinEDA_DrawPanel* Panel, wxDC* DC )
{
SCH_SHEET_PIN* SheetLabel =
......@@ -142,6 +146,15 @@ static void ExitPinSheet( WinEDA_DrawPanel* Panel, wxDC* DC )
}
else
{
RedrawOneStruct( Panel, DC, SheetLabel, g_XorMode );
SheetLabel->m_Pos = s_InitialPosition;
// Restore edge position:
SCH_SHEET* sheet = (SCH_SHEET*) SheetLabel->GetParent();
if( s_InitialPosition.x > ( sheet->m_Pos.x + (sheet->m_Size.x / 2) ) )
SheetLabel->m_Edge = 1;
else
SheetLabel->m_Edge = 0;
RedrawOneStruct( Panel, DC, SheetLabel, GR_DEFAULT_DRAWMODE );
SheetLabel->m_Flags = 0;
}
......@@ -204,6 +217,7 @@ void WinEDA_SchematicFrame::StartMove_PinSheet( SCH_SHEET_PIN* SheetLabel,
NetSheetTextSize = SheetLabel->m_Size;
s_CurrentTypeLabel = SheetLabel->m_Shape;
SheetLabel->m_Flags |= IS_MOVED;
s_InitialPosition = SheetLabel->m_Pos;
DrawPanel->ManageCurseur = Move_PinSheet;
DrawPanel->ForceCloseManageCurseur = ExitPinSheet;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment