Commit 67e28ade authored by Dick Hollenbeck's avatar Dick Hollenbeck

++eeschema

    Add shim class SCH_BASE_FRAME which introduces the data model SCH_SCREEN
    to the frame class hierarchy.
parent f6940353
......@@ -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 <dick@softplc.com>
......
......@@ -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 <author>
* Copyright (C) 2011 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2012 <author>
* 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
......
......@@ -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
......
......@@ -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;
......
......@@ -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 <sch_base_frame.h>
#include <class_sch_screen.h>
#include "lib_draw_item.h"
#include "lib_collectors.h"
#include <lib_draw_item.h>
#include <lib_collectors.h>
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_
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* 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_base_frame.h>
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 );
}
......@@ -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();
......
......@@ -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();
......
......@@ -27,14 +27,14 @@
* @file viewlib_frame.h
*/
#ifndef __LIBVIEWFRM_H__
#define __LIBVIEWFRM_H__
#ifndef LIBVIEWFRM_H_
#define LIBVIEWFRM_H_
#include <wx/gdicmn.h>
#include "wxstruct.h"
#include "class_sch_screen.h"
#include <sch_base_frame.h>
#include <class_sch_screen.h>
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_
#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 <dick@softplc.com>
* 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 <wxstruct.h>
#include <class_sch_screen.h>
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.
* <p>
* 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_
......@@ -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 );
......
......@@ -28,8 +28,8 @@
* @brief Base window classes and related definitions.
*/
#ifndef WXSTRUCT_H
#define WXSTRUCT_H
#ifndef WXSTRUCT_H_
#define WXSTRUCT_H_
#include <vector>
......@@ -1177,4 +1177,4 @@ public:
};
#endif /* WXSTRUCT_H */
#endif // WXSTRUCT_H_
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