From 8733da346bbf996ab64b54a3846aea24cc00215b Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 23 Jul 2013 18:45:23 +0200 Subject: [PATCH] Pl_Editor: bug fixes (default values not saved, and duplicate item names, when adding items) --- pagelayout_editor/events_functions.cpp | 11 ++++++++++ pagelayout_editor/page_layout_writer.cpp | 8 +++---- pagelayout_editor/pl_editor_frame.cpp | 27 +++++++++++++++++++++--- pagelayout_editor/pl_editor_frame.h | 1 + 4 files changed, 40 insertions(+), 7 deletions(-) diff --git a/pagelayout_editor/events_functions.cpp b/pagelayout_editor/events_functions.cpp index 29d15011f4..793ea3aa7a 100644 --- a/pagelayout_editor/events_functions.cpp +++ b/pagelayout_editor/events_functions.cpp @@ -199,9 +199,20 @@ void PL_EDITOR_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_ITEM_MOVE_START_POINT: + item = m_treePagelayout->GetPageLayoutSelectedItem(); + item->ClearFlags( LOCATE_ENDPOINT ); + MoveItem( item ); + break; + case ID_POPUP_ITEM_MOVE_END_POINT: + item = m_treePagelayout->GetPageLayoutSelectedItem(); + item->ClearFlags( LOCATE_STARTPOINT ); + MoveItem( item ); + break; + case ID_POPUP_ITEM_MOVE: item = m_treePagelayout->GetPageLayoutSelectedItem(); + item->ClearFlags( LOCATE_ENDPOINT|LOCATE_STARTPOINT ); MoveItem( item ); break; diff --git a/pagelayout_editor/page_layout_writer.cpp b/pagelayout_editor/page_layout_writer.cpp index adb006f53b..cd57401ac3 100644 --- a/pagelayout_editor/page_layout_writer.cpp +++ b/pagelayout_editor/page_layout_writer.cpp @@ -182,10 +182,10 @@ void WORKSHEET_LAYOUT_IO::Format( WORKSHEET_LAYOUT* aPageLayout ) const // Write default values: m_out->Print( nestLevel, "(%s", getTokenName( T_setup ) ); m_out->Print( 0, "(textsize %s %s)", - double2Str( TB_DEFAULT_TEXTSIZE ).c_str(), - double2Str( TB_DEFAULT_TEXTSIZE ).c_str() ); - m_out->Print( 0, "(linewidth %s)", double2Str( 0.15 ).c_str() ); - m_out->Print( 0, "(textlinewidth %s)", double2Str( 0.15 ).c_str() ); + double2Str( WORKSHEET_DATAITEM::m_DefaultTextSize.x ).c_str(), + double2Str( WORKSHEET_DATAITEM::m_DefaultTextSize.y ).c_str() ); + m_out->Print( 0, "(linewidth %s)", double2Str( WORKSHEET_DATAITEM::m_DefaultLineWidth ).c_str() ); + m_out->Print( 0, "(textlinewidth %s)", double2Str( WORKSHEET_DATAITEM::m_DefaultTextThickness ).c_str() ); m_out->Print( 0, "\n" ); // Write margin values diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index 93ec6f492f..e10dc55e4b 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -505,14 +505,35 @@ void PL_EDITOR_FRAME::RedrawActiveWindow( wxDC* aDC, bool aEraseBg ) void PL_EDITOR_FRAME::RebuildDesignTree() { const WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance(); + int rectId = 0; + int lineId = 0; + int textId = 0; + int polyId = 0; for( unsigned ii = 0; ii < pglayout.GetCount(); ii++ ) { WORKSHEET_DATAITEM* item = pglayout.GetItem( ii ); - if( item->m_Name.IsEmpty() ) + switch( item->GetType() ) { - item->m_Name = wxString::Format( wxT("item%d:%s"), ii+1, - GetChars(item->GetClassName()) ); + case WORKSHEET_DATAITEM::WS_TEXT: + item->m_Name = wxString::Format( wxT("text%d:%s"), ++textId, + GetChars(item->GetClassName()) ); + break; + + case WORKSHEET_DATAITEM:: WS_SEGMENT: + item->m_Name = wxString::Format( wxT("segm%d:%s"), ++lineId, + GetChars(item->GetClassName()) ); + break; + + case WORKSHEET_DATAITEM::WS_RECT: + item->m_Name = wxString::Format( wxT("rect%d:%s"), ++rectId, + GetChars(item->GetClassName()) ); + break; + + case WORKSHEET_DATAITEM::WS_POLYPOLYGON: + item->m_Name = wxString::Format( wxT("poly%d:%s"), ++polyId, + GetChars(item->GetClassName()) ); + break; } } diff --git a/pagelayout_editor/pl_editor_frame.h b/pagelayout_editor/pl_editor_frame.h index 7ea093a6b7..22b8c70f0c 100644 --- a/pagelayout_editor/pl_editor_frame.h +++ b/pagelayout_editor/pl_editor_frame.h @@ -322,6 +322,7 @@ public: /** * Initialize a move item command + * @param aItem is the item to move */ void MoveItem( WORKSHEET_DATAITEM* aItem );