From 67e28ade74aaba19a071ca17e9864cb05ceefaed Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Mon, 9 Jan 2012 11:24:01 -0600 Subject: [PATCH] ++eeschema Add shim class SCH_BASE_FRAME which introduces the data model SCH_SCREEN to the frame class hierarchy. --- CHANGELOG.txt | 3 ++ copyright.h | 4 +- eeschema/CMakeLists.txt | 1 + eeschema/libeditframe.cpp | 35 +---------------- eeschema/libeditframe.h | 34 ++++++---------- eeschema/sch_base_frame.cpp | 78 +++++++++++++++++++++++++++++++++++++ eeschema/schframe.cpp | 35 +---------------- eeschema/viewlib_frame.cpp | 35 +---------------- eeschema/viewlib_frame.h | 24 +++--------- include/sch_base_frame.h | 69 ++++++++++++++++++++++++++++++++ include/wxEeschemaStruct.h | 22 ++--------- include/wxstruct.h | 6 +-- 12 files changed, 180 insertions(+), 166 deletions(-) create mode 100644 eeschema/sch_base_frame.cpp create mode 100644 include/sch_base_frame.h diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 7a494574ef..6c8d844598 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -7,6 +7,9 @@ KiCad ChangeLog 2012 Carve out TITLE_BLOCK from BASE_SCREEN, add include/hashtables.h and put class PROPERTIES in there. Change PROPERTIES to use "const char*" as the key instead of wxString. +++eeschema + Add shim class SCH_BASE_FRAME which introduces the data model SCH_SCREEN + to the frame class hierarchy. 2012-Jan-5 UPDATE Dick Hollenbeck diff --git a/copyright.h b/copyright.h index 525f06343d..f2822cace0 100644 --- a/copyright.h +++ b/copyright.h @@ -12,8 +12,8 @@ may choose to document this corresponding work in the CHANGELOG.txt file. /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2011 - * Copyright (C) 2011 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2012 + * Copyright (C) 2012 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 32a3fde814..e6e7538a2d 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -114,6 +114,7 @@ set(EESCHEMA_SRCS onrightclick.cpp operations_on_items_lists.cpp pinedit.cpp + sch_base_frame.cpp sch_bitmap.cpp sch_bus_entry.cpp sch_collectors.cpp diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index 6e9d6540aa..c0e1b0856b 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -189,7 +189,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent, const wxPoint& pos, const wxSize& size, long style ) : - EDA_DRAW_FRAME( aParent, LIBEDITOR_FRAME, title, pos, size, style ) + SCH_BASE_FRAME( aParent, LIBEDITOR_FRAME, title, pos, size, style ) { wxASSERT( aParent ); @@ -287,39 +287,6 @@ LIB_EDIT_FRAME::~LIB_EDIT_FRAME() } -void LIB_EDIT_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings ) -{ - GetScreen()->SetPageSettings( aPageSettings ); -} - - -const PAGE_INFO& LIB_EDIT_FRAME::GetPageSettings () const -{ - return GetScreen()->GetPageSettings(); -} - - -const wxSize LIB_EDIT_FRAME::GetPageSizeIU() const -{ - // GetSizeIU is compile time dependent: - return GetScreen()->GetPageSettings().GetSizeIU(); -} - - -const wxPoint& LIB_EDIT_FRAME::GetOriginAxisPosition() const -{ - wxASSERT( GetScreen() ); - return GetScreen()->GetOriginAxisPosition(); -} - - -void LIB_EDIT_FRAME::SetOriginAxisPosition( const wxPoint& aPosition ) -{ - wxASSERT( GetScreen() ); - GetScreen()->SetOriginAxisPosition( aPosition ); -} - - void LIB_EDIT_FRAME::LoadSettings() { wxConfig* cfg; diff --git a/eeschema/libeditframe.h b/eeschema/libeditframe.h index 0bb97b3863..a6c63da557 100644 --- a/eeschema/libeditframe.h +++ b/eeschema/libeditframe.h @@ -28,14 +28,14 @@ * @brief Definition of class LIB_EDIT_FRAME */ -#ifndef __LIBEDITFRM_H__ -#define __LIBEDITFRM_H__ +#ifndef LIBEDITFRM_H_ +#define LIBEDITFRM_H_ -#include "wxstruct.h" -#include "class_sch_screen.h" +#include +#include -#include "lib_draw_item.h" -#include "lib_collectors.h" +#include +#include class SCH_EDIT_FRAME; @@ -49,7 +49,7 @@ class DIALOG_LIB_EDIT_TEXT; /** * The component library editor main window. */ -class LIB_EDIT_FRAME : public EDA_DRAW_FRAME +class LIB_EDIT_FRAME : public SCH_BASE_FRAME { LIB_COMPONENT* m_tempCopyComponent; ///< Temporary copy of current component during edit. LIB_COLLECTOR m_collectedItems; // Used for hit testing. @@ -122,9 +122,9 @@ class LIB_EDIT_FRAME : public EDA_DRAW_FRAME LIB_ITEM* locateItem( const wxPoint& aPosition, const KICAD_T aFilterList[] ); public: - LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent, const wxString& title, - const wxPoint& pos, const wxSize& size, - long style = KICAD_DEFAULT_DRAWFRAME_STYLE ); + LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent, const wxString& aTitle, + const wxPoint& aPosition, const wxSize& aSize, + long aStyle = KICAD_DEFAULT_DRAWFRAME_STYLE ); ~LIB_EDIT_FRAME(); @@ -257,18 +257,6 @@ public: double BestZoom(); // Returns the best zoom void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ); - SCH_SCREEN* GetScreen() const { return (SCH_SCREEN*) EDA_DRAW_FRAME::GetScreen(); } - - // note: a common base class shared between LIB_EDIT_FRAME, LIB_VIEW_FRAME, and SCH_EDIT_FRAME - // would allow sharing of these 5 functions: - - void SetPageSettings( const PAGE_INFO& aPageSettings ); // overload EDA_DRAW_FRAME - const PAGE_INFO& GetPageSettings () const; // overload EDA_DRAW_FRAME - const wxSize GetPageSizeIU() const; // overload EDA_DRAW_FRAME - - const wxPoint& GetOriginAxisPosition() const; // overload EDA_DRAW_FRAME - void SetOriginAxisPosition( const wxPoint& aPosition ); // overload EDA_DRAW_FRAME - void OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem = NULL ); void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); @@ -599,4 +587,4 @@ public: DECLARE_EVENT_TABLE() }; -#endif /* __LIBEDITFRM_H__ */ +#endif // LIBEDITFRM_H_ diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp new file mode 100644 index 0000000000..9cc0492977 --- /dev/null +++ b/eeschema/sch_base_frame.cpp @@ -0,0 +1,78 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck + * Copyright (C) 2012 KiCad Developers, see change_log.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include + + +SCH_SCREEN* SCH_BASE_FRAME::GetScreen() const +{ + return (SCH_SCREEN*) EDA_DRAW_FRAME::GetScreen(); +} + + +void SCH_BASE_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings ) +{ + GetScreen()->SetPageSettings( aPageSettings ); +} + + +const PAGE_INFO& SCH_BASE_FRAME::GetPageSettings () const +{ + return GetScreen()->GetPageSettings(); +} + + +const wxSize SCH_BASE_FRAME::GetPageSizeIU() const +{ + // GetSizeIU is compile time dependent: + return GetScreen()->GetPageSettings().GetSizeIU(); +} + + +const wxPoint& SCH_BASE_FRAME::GetOriginAxisPosition() const +{ + wxASSERT( GetScreen() ); + return GetScreen()->GetOriginAxisPosition(); +} + + +void SCH_BASE_FRAME::SetOriginAxisPosition( const wxPoint& aPosition ) +{ + wxASSERT( GetScreen() ); + GetScreen()->SetOriginAxisPosition( aPosition ); +} + + +const TITLE_BLOCK& SCH_BASE_FRAME::GetTitleBlock() const +{ + wxASSERT( GetScreen() ); + return GetScreen()->GetTitleBlock(); +} + + +void SCH_BASE_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) +{ + wxASSERT( GetScreen() ); + GetScreen()->SetTitleBlock( aTitleBlock ); +} diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index d9305681d2..4a16a57b4a 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -183,7 +183,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( wxWindow* father, const wxPoint& pos, const wxSize& size, long style ) : - EDA_DRAW_FRAME( father, SCHEMATIC_FRAME, title, pos, size, style ) + SCH_BASE_FRAME( father, SCHEMATIC_FRAME, title, pos, size, style ) { m_FrameName = wxT( "SchematicFrame" ); m_showAxis = false; // true to show axis @@ -285,39 +285,6 @@ SCH_EDIT_FRAME::~SCH_EDIT_FRAME() } -void SCH_EDIT_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings ) -{ - GetScreen()->SetPageSettings( aPageSettings ); -} - - -const PAGE_INFO& SCH_EDIT_FRAME::GetPageSettings () const -{ - return GetScreen()->GetPageSettings(); -} - - -const wxSize SCH_EDIT_FRAME::GetPageSizeIU() const -{ - // GetSizeIU is compile time dependent: - return GetScreen()->GetPageSettings().GetSizeIU(); -} - - -const wxPoint& SCH_EDIT_FRAME::GetOriginAxisPosition() const -{ - wxASSERT( GetScreen() ); - return GetScreen()->GetOriginAxisPosition(); -} - - -void SCH_EDIT_FRAME::SetOriginAxisPosition( const wxPoint& aPosition ) -{ - wxASSERT( GetScreen() ); - GetScreen()->SetOriginAxisPosition( aPosition ); -} - - void SCH_EDIT_FRAME::SetSheetNumberAndCount() { SCH_SCREEN* screen = GetScreen(); diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index a9a3d50b99..e3f7915221 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -100,7 +100,7 @@ static wxAcceleratorEntry accels[] = LIB_VIEW_FRAME::LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library, wxSemaphore* semaphore ) : - EDA_DRAW_FRAME( father, VIEWER_FRAME, _( "Library Browser" ), + SCH_BASE_FRAME( father, VIEWER_FRAME, _( "Library Browser" ), wxDefaultPosition, wxDefaultSize ) { wxAcceleratorTable table( ACCEL_TABLE_CNT, accels ); @@ -265,39 +265,6 @@ LIB_VIEW_FRAME::~LIB_VIEW_FRAME() } -void LIB_VIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings ) -{ - GetScreen()->SetPageSettings( aPageSettings ); -} - - -const PAGE_INFO& LIB_VIEW_FRAME::GetPageSettings () const -{ - return GetScreen()->GetPageSettings(); -} - - -const wxSize LIB_VIEW_FRAME::GetPageSizeIU() const -{ - // GetSizeIU is compile time dependent: - return GetScreen()->GetPageSettings().GetSizeIU(); -} - - -const wxPoint& LIB_VIEW_FRAME::GetOriginAxisPosition() const -{ - wxASSERT( GetScreen() ); - return GetScreen()->GetOriginAxisPosition(); -} - - -void LIB_VIEW_FRAME::SetOriginAxisPosition( const wxPoint& aPosition ) -{ - wxASSERT( GetScreen() ); - GetScreen()->SetOriginAxisPosition( aPosition ); -} - - void LIB_VIEW_FRAME::OnCloseWindow( wxCloseEvent& Event ) { SaveSettings(); diff --git a/eeschema/viewlib_frame.h b/eeschema/viewlib_frame.h index 89866393ab..ff3630e06e 100644 --- a/eeschema/viewlib_frame.h +++ b/eeschema/viewlib_frame.h @@ -27,14 +27,14 @@ * @file viewlib_frame.h */ -#ifndef __LIBVIEWFRM_H__ -#define __LIBVIEWFRM_H__ +#ifndef LIBVIEWFRM_H_ +#define LIBVIEWFRM_H_ #include -#include "wxstruct.h" -#include "class_sch_screen.h" +#include +#include class wxSashLayoutWindow; class wxListBox; @@ -45,7 +45,7 @@ class CMP_LIBRARY; /** * Component library viewer main window. */ -class LIB_VIEW_FRAME : public EDA_DRAW_FRAME +class LIB_VIEW_FRAME : public SCH_BASE_FRAME { private: wxComboBox* SelpartBox; @@ -107,18 +107,6 @@ public: void ClickOnCmpList( wxCommandEvent& event ); void OnSetRelativeOffset( wxCommandEvent& event ); - SCH_SCREEN* GetScreen() const { return (SCH_SCREEN*) EDA_DRAW_FRAME::GetScreen(); } - - // note: a common base class shared between LIB_EDIT_FRAME, LIB_VIEW_FRAME, and SCH_EDIT_FRAME - // would allow sharing of these 5 functions: - - void SetPageSettings( const PAGE_INFO& aPageSettings ); // overload EDA_DRAW_FRAME - const PAGE_INFO& GetPageSettings () const; // overload EDA_DRAW_FRAME - const wxSize GetPageSizeIU() const; // overload EDA_DRAW_FRAME - - const wxPoint& GetOriginAxisPosition() const; // overload EDA_DRAW_FRAME - void SetOriginAxisPosition( const wxPoint& aPosition ); // overload EDA_DRAW_FRAME - void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); /** @@ -167,4 +155,4 @@ private: DECLARE_EVENT_TABLE() }; -#endif /* __LIBVIEWFRM_H__ */ +#endif // LIBVIEWFRM_H_ diff --git a/include/sch_base_frame.h b/include/sch_base_frame.h new file mode 100644 index 0000000000..d8cd707f29 --- /dev/null +++ b/include/sch_base_frame.h @@ -0,0 +1,69 @@ +#ifndef SCH_BASE_FRAME_H_ +#define SCH_BASE_FRAME_H_ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck + * Copyright (C) 2012 KiCad Developers, see change_log.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include + +class PAGE_INFO; +class TITLE_BLOCK; + + +/** + * Class SCH_BASE_FRAME + * is a shim class between EDA_DRAW_FRAME and several derived classes: + * LIB_EDIT_FRAME, LIB_VIEW_FRAME, and SCH_EDIT_FRAME, and it brings in a + * common way of handling the provided virtual functions for the derived classes. + *

+ * The motivation here is to switch onto GetScreen() for the underlying data model. + * + * @author Dick Hollenbeck + */ +class SCH_BASE_FRAME : public EDA_DRAW_FRAME +{ +public: + SCH_BASE_FRAME( wxWindow* aParent, + id_drawframe aWindowType, + const wxString& aTitle, + const wxPoint& aPosition, const wxSize& aSize, + long aStyle = KICAD_DEFAULT_DRAWFRAME_STYLE ) : + EDA_DRAW_FRAME( aParent, aWindowType, aTitle, aPosition, aSize, aStyle ) + { + } + + SCH_SCREEN* GetScreen() const; // overload EDA_DRAW_FRAME + + void SetPageSettings( const PAGE_INFO& aPageSettings ); // overload EDA_DRAW_FRAME + const PAGE_INFO& GetPageSettings () const; // overload EDA_DRAW_FRAME + const wxSize GetPageSizeIU() const; // overload EDA_DRAW_FRAME + + const wxPoint& GetOriginAxisPosition() const; // overload EDA_DRAW_FRAME + void SetOriginAxisPosition( const wxPoint& aPosition ); // overload EDA_DRAW_FRAME + + const TITLE_BLOCK& GetTitleBlock() const; // overload EDA_DRAW_FRAME + void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ); // overload EDA_DRAW_FRAME +}; + +#endif // SCH_BASE_FRAME_H_ diff --git a/include/wxEeschemaStruct.h b/include/wxEeschemaStruct.h index 1ae678bb48..c5a5a7f281 100644 --- a/include/wxEeschemaStruct.h +++ b/include/wxEeschemaStruct.h @@ -30,7 +30,7 @@ #ifndef WX_EESCHEMA_STRUCT_H #define WX_EESCHEMA_STRUCT_H -#include "wxstruct.h" +#include "sch_base_frame.h" #include "param_config.h" #include "class_undoredo_container.h" #include "template_fieldnames.h" @@ -110,7 +110,7 @@ enum SCH_SEARCH_T { /** * Schematic editor (Eeschema) main window. */ -class SCH_EDIT_FRAME : public EDA_DRAW_FRAME +class SCH_EDIT_FRAME : public SCH_BASE_FRAME { private: SCH_SHEET_PATH* m_CurrentSheet; ///< which sheet we are presently working on. @@ -198,6 +198,8 @@ public: ~SCH_EDIT_FRAME(); + SCH_SCREEN* GetScreen() const; // overload SCH_BASE_FRAME + void OnCloseWindow( wxCloseEvent& Event ); void SetLibraryEditorWindow( LIB_EDIT_FRAME* aFrame ) { m_LibeditFrame = aFrame; } @@ -348,22 +350,6 @@ public: */ void OnModify(); - SCH_SCREEN* GetScreen() const; - - // note: a common base class shared between LIB_EDIT_FRAME, LIB_VIEW_FRAME, and SCH_EDIT_FRAME - // would allow sharing of these three functions: - - // note: a common base class shared between LIB_EDIT_FRAME, LIB_VIEW_FRAME, and SCH_EDIT_FRAME - // would allow sharing of these 5 functions: - - void SetPageSettings( const PAGE_INFO& aPageSettings ); // overload EDA_DRAW_FRAME - const PAGE_INFO& GetPageSettings () const; // overload EDA_DRAW_FRAME - const wxSize GetPageSizeIU() const; // overload EDA_DRAW_FRAME - - const wxPoint& GetOriginAxisPosition() const; // overload EDA_DRAW_FRAME - void SetOriginAxisPosition( const wxPoint& aPosition ); // overload EDA_DRAW_FRAME - - virtual wxString GetScreenDesc(); void InstallConfigFrame( wxCommandEvent& event ); diff --git a/include/wxstruct.h b/include/wxstruct.h index 9fa84566b7..0959be7eb4 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -28,8 +28,8 @@ * @brief Base window classes and related definitions. */ -#ifndef WXSTRUCT_H -#define WXSTRUCT_H +#ifndef WXSTRUCT_H_ +#define WXSTRUCT_H_ #include @@ -1177,4 +1177,4 @@ public: }; -#endif /* WXSTRUCT_H */ +#endif // WXSTRUCT_H_