From b810135e4ed4479e9d6036744f800f6f82c9ddb1 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 11 Sep 2012 21:03:21 +0200 Subject: [PATCH] Code cleaning, minor fixes and minor coding style fixes. wxWidgets 2.9.4 compatibility fix( deprecated function MakeModal ) --- 3d-viewer/3d_draw.cpp | 4 +- 3d-viewer/3d_frame.cpp | 2 +- common/basicframe.cpp | 60 ++- common/drawframe.cpp | 3 +- cvpcb/class_DisplayFootprintsFrame.cpp | 2 +- cvpcb/cvframe.cpp | 2 +- eeschema/dialogs/dialog_SVG_print.cpp | 6 +- eeschema/getpart.cpp | 16 +- eeschema/lib_pin.cpp | 2 +- eeschema/libeditframe.cpp | 2 +- eeschema/sch_base_frame.cpp | 2 +- eeschema/schframe.cpp | 2 +- eeschema/viewlib_frame.cpp | 12 +- eeschema/viewlib_frame.h | 318 +++++++------- gerbview/gerbview_frame.cpp | 2 +- include/sch_base_frame.h | 2 +- include/wxBasePcbFrame.h | 3 +- include/wxstruct.h | 60 +-- kicad/mainframe.cpp | 2 +- pcbnew/basepcbframe.cpp | 14 +- pcbnew/class_module.cpp | 2 +- pcbnew/class_track.cpp | 4 +- .../dialogs/dialog_footprint_wizard_list.cpp | 21 +- pcbnew/edtxtmod.cpp | 4 +- pcbnew/footprint_wizard_frame.cpp | 102 ++--- pcbnew/footprint_wizard_frame.h | 402 +++++++++--------- pcbnew/loadcmp.cpp | 5 +- pcbnew/modedit.cpp | 4 +- pcbnew/moduleframe.cpp | 2 +- pcbnew/modview_frame.cpp | 16 +- pcbnew/modview_frame.h | 361 ++++++++-------- pcbnew/pcbframe.cpp | 14 +- pcbnew/printout_controler.cpp | 2 +- 33 files changed, 741 insertions(+), 714 deletions(-) diff --git a/3d-viewer/3d_draw.cpp b/3d-viewer/3d_draw.cpp index be405b1869..26a544afc4 100644 --- a/3d-viewer/3d_draw.cpp +++ b/3d-viewer/3d_draw.cpp @@ -680,7 +680,7 @@ void MODULE::Draw3D( EDA_3D_CANVAS* glcanvas ) if( g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_MODULE] ) { double zpos; - if( m_Layer == LAYER_N_BACK ) + if( IsFlipped() ) zpos = g_Parm_3D_Visu.GetModulesZcoord3DIU( true ); else zpos = g_Parm_3D_Visu.GetModulesZcoord3DIU( false ); @@ -696,7 +696,7 @@ void MODULE::Draw3D( EDA_3D_CANVAS* glcanvas ) glRotatef( (double) m_Orient / 10, 0.0, 0.0, 1.0 ); } - if( m_Layer == LAYER_N_BACK ) + if( IsFlipped() ) { glRotatef( 180.0, 0.0, 1.0, 0.0 ); glRotatef( 180.0, 0.0, 0.0, 1.0 ); diff --git a/3d-viewer/3d_frame.cpp b/3d-viewer/3d_frame.cpp index 18e9f2ab5b..9dc6a95b48 100644 --- a/3d-viewer/3d_frame.cpp +++ b/3d-viewer/3d_frame.cpp @@ -57,7 +57,7 @@ END_EVENT_TABLE() EDA_3D_FRAME::EDA_3D_FRAME( PCB_BASE_FRAME* parent, const wxString& title, long style ) : - wxFrame( parent, DISPLAY3D_FRAME, title, wxPoint( -1, -1 ), wxSize( -1, -1 ), style ) + wxFrame( parent, DISPLAY3D_FRAME_TYPE, title, wxPoint( -1, -1 ), wxSize( -1, -1 ), style ) { m_FrameName = wxT( "Frame3D" ); m_Canvas = NULL; diff --git a/common/basicframe.cpp b/common/basicframe.cpp index d045a5cbb1..3d6488ad97 100644 --- a/common/basicframe.cpp +++ b/common/basicframe.cpp @@ -56,12 +56,11 @@ static const wxChar* entryAutoSaveInterval = wxT( "AutoSaveInterval" ); EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* father, - int idtype, + ID_DRAWFRAME_TYPE idtype, const wxString& title, - const wxPoint& pos, - const wxSize& size, + const wxPoint& pos, const wxSize& size, long style ) : - wxFrame( father, -1, title, pos, size, style ) + wxFrame( father, wxID_ANY, title, pos, size, style ) { wxSize minsize; @@ -257,24 +256,6 @@ void EDA_BASE_FRAME::PrintMsg( const wxString& text ) SetStatusText( text ); } - -void EDA_BASE_FRAME::DisplayActivity( int PerCent, const wxString& Text ) -{ - wxString Line; - - Line = Text; - - PerCent = (PerCent < 0) ? 0 : PerCent; - PerCent = (PerCent > 100) ? 100 : PerCent; - PerCent /= 2; // Bargraph is 0 .. 50 points from 0% to 100% - - if( PerCent ) - Line.Pad( PerCent, '*' ); - - SetStatusText( Line ); -} - - void EDA_BASE_FRAME::UpdateFileHistory( const wxString& FullFileName, wxFileHistory * aFileHistory ) { @@ -540,7 +521,7 @@ void EDA_BASE_FRAME::CopyVersionInfoToClipboard( wxCommandEvent& event ) #endif tmp << wxT( " USE_BOOST_POLYGON_LIBRARY\n" ); - + tmp << wxT( " KICAD_SCRIPTING=" ); #ifdef KICAD_SCRIPTING tmp << wxT( "ON\n" ); @@ -663,3 +644,36 @@ edits you made?" ), wxRemoveFile( autoSaveFileName.GetFullPath() ); } } + +/** + * Function SetModalMode + * Disable or enable all other windows, to emulate a dialog behavior + * Useful when the frame is used to show and selec items + * (see FOOTPRINT_VIEWER_FRAME and LIB_VIEW_FRAME) + * + * @param aModal = true to disable all other opened windows (i.e. + * this windows is in dialog mode + * = false to enable other windows + * This function is analog to MakeModal( aModal ), deprecated since wxWidgets 2.9.4 + */ +void EDA_BASE_FRAME::SetModalMode( bool aModal ) +{ + // Disable all other windows +#if wxCHECK_VERSION(2, 9, 4) + if ( IsTopLevel() ) + { + wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst(); + while (node) + { + wxWindow *win = node->GetData(); + if (win != this) + win->Enable(!aModal); + + node = node->GetNext(); + } + } +#else + // Deprecated since wxWidgets 2.9.4 + MakeModal( aModal ); +#endif +} diff --git a/common/drawframe.cpp b/common/drawframe.cpp index 619c5e3528..ace1f9f2a5 100644 --- a/common/drawframe.cpp +++ b/common/drawframe.cpp @@ -84,7 +84,8 @@ BEGIN_EVENT_TABLE( EDA_DRAW_FRAME, EDA_BASE_FRAME ) END_EVENT_TABLE() -EDA_DRAW_FRAME::EDA_DRAW_FRAME( wxWindow* father, int idtype, const wxString& title, +EDA_DRAW_FRAME::EDA_DRAW_FRAME( wxWindow* father, ID_DRAWFRAME_TYPE idtype, + const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : EDA_BASE_FRAME( father, idtype, title, pos, size, style ) { diff --git a/cvpcb/class_DisplayFootprintsFrame.cpp b/cvpcb/class_DisplayFootprintsFrame.cpp index 68b455f8f0..74304a07a8 100644 --- a/cvpcb/class_DisplayFootprintsFrame.cpp +++ b/cvpcb/class_DisplayFootprintsFrame.cpp @@ -76,7 +76,7 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( CVPCB_MAINFRAME* parent, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : - PCB_BASE_FRAME( parent, CVPCB_DISPLAY_FRAME, title, pos, size, style ) + PCB_BASE_FRAME( parent, CVPCB_DISPLAY_FRAME_TYPE, title, pos, size, style ) { m_FrameName = wxT( "CmpFrame" ); m_showAxis = true; // true to draw axis. diff --git a/cvpcb/cvframe.cpp b/cvpcb/cvframe.cpp index 1d818f45ad..08bb40d310 100644 --- a/cvpcb/cvframe.cpp +++ b/cvpcb/cvframe.cpp @@ -104,7 +104,7 @@ END_EVENT_TABLE() CVPCB_MAINFRAME::CVPCB_MAINFRAME( const wxString& title, long style ) : - EDA_BASE_FRAME( NULL, CVPCB_FRAME, title, wxDefaultPosition, wxDefaultSize, style ) + EDA_BASE_FRAME( NULL, CVPCB_FRAME_TYPE, title, wxDefaultPosition, wxDefaultSize, style ) { m_FrameName = wxT( "CvpcbFrame" ); diff --git a/eeschema/dialogs/dialog_SVG_print.cpp b/eeschema/dialogs/dialog_SVG_print.cpp index 07612f3f05..6409abc18a 100644 --- a/eeschema/dialogs/dialog_SVG_print.cpp +++ b/eeschema/dialogs/dialog_SVG_print.cpp @@ -121,7 +121,7 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref ) SCH_SCREEN* screen = (SCH_SCREEN*) m_Parent->GetScreen(); - if( aPrintAll && m_Parent->IsType( SCHEMATIC_FRAME ) ) + if( aPrintAll && m_Parent->IsType( SCHEMATIC_FRAME_TYPE ) ) { SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) m_Parent; SCH_SHEET_PATH* sheetpath; @@ -229,10 +229,10 @@ bool DIALOG_SVG_PRINT::DrawSVGPage( EDA_DRAW_FRAME* frame, screen->m_IsPrinting = true; - if( frame->IsType( SCHEMATIC_FRAME ) ) + if( frame->IsType( SCHEMATIC_FRAME_TYPE ) ) screen->Draw( panel, &dc, GR_COPY ); - if( frame->IsType( LIBEDITOR_FRAME ) ) + if( frame->IsType( LIBEDITOR_FRAME_TYPE ) ) ((LIB_EDIT_FRAME*)frame)->RedrawComponent( &dc, wxPoint(sheetSize.x/2, sheetSize.y/2) ); diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index 3e25dab8db..8c03bf488d 100644 --- a/eeschema/getpart.cpp +++ b/eeschema/getpart.cpp @@ -57,30 +57,22 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibBrowser( void ) /* Close the current Lib browser, if open, and open a new one, in "modal" mode */ if( m_ViewlibFrame ) { - m_ViewlibFrame->Destroy(); + delete m_ViewlibFrame; m_ViewlibFrame = NULL; } - if( m_LibeditFrame && m_LibeditFrame->m_ViewlibFrame ) - { - m_LibeditFrame->m_ViewlibFrame->Destroy(); - m_LibeditFrame->m_ViewlibFrame = NULL; - } - - m_ViewlibFrame = new LIB_VIEW_FRAME( this, NULL, &semaphore ); + m_ViewlibFrame = new LIB_VIEW_FRAME( this, NULL, &semaphore, + KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT ); // Show the library viewer frame until it is closed - // and disable the current frame, until the library viewer is closed - Enable(false); // Wait for viewer closing event: while( semaphore.TryWait() == wxSEMA_BUSY ) { wxYield(); wxMilliSleep( 50 ); } - Enable(true); cmpname = m_ViewlibFrame->GetSelectedComponent(); - m_ViewlibFrame->Destroy(); + delete m_ViewlibFrame; return cmpname; } diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index ff5c39c0be..c0d1d1150c 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -805,7 +805,7 @@ void LIB_PIN::drawGraphic( EDA_DRAW_PANEL* aPanel, if( aPanel && aPanel->GetParent() ) frame = (EDA_DRAW_FRAME*)aPanel->GetParent(); - if( frame && frame->IsType( SCHEMATIC_FRAME ) && + if( frame && frame->IsType( SCHEMATIC_FRAME_TYPE ) && ! ((SCH_EDIT_FRAME*)frame)->GetShowAllPins() ) return; diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index a8f4fe76ce..fa72de642b 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -191,7 +191,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent, const wxPoint& pos, const wxSize& size, long style ) : - SCH_BASE_FRAME( aParent, LIBEDITOR_FRAME, title, pos, size, style ) + SCH_BASE_FRAME( aParent, LIBEDITOR_FRAME_TYPE, title, pos, size, style ) { wxASSERT( aParent ); diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index 265ee86e8c..22da81c301 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -28,7 +28,7 @@ #include SCH_BASE_FRAME::SCH_BASE_FRAME( wxWindow* aParent, - id_drawframe aWindowType, + ID_DRAWFRAME_TYPE aWindowType, const wxString& aTitle, const wxPoint& aPosition, const wxSize& aSize, long aStyle ) : diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index 8267e620ca..429c3818c8 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -184,7 +184,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( wxWindow* father, const wxPoint& pos, const wxSize& size, long style ) : - SCH_BASE_FRAME( father, SCHEMATIC_FRAME, title, pos, size, style ) + SCH_BASE_FRAME( father, SCHEMATIC_FRAME_TYPE, title, pos, size, style ) { m_FrameName = wxT( "SchematicFrame" ); m_showAxis = false; // true to show axis diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index 274998f5da..081c0ef491 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -99,9 +99,10 @@ static wxAcceleratorEntry accels[] = #define EXTRA_BORDER_SIZE 2 -LIB_VIEW_FRAME::LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library, wxSemaphore* semaphore ) : - SCH_BASE_FRAME( father, VIEWER_FRAME, _( "Library Browser" ), - wxDefaultPosition, wxDefaultSize ) +LIB_VIEW_FRAME::LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library, + wxSemaphore* semaphore, long style ) : + SCH_BASE_FRAME( father, VIEWER_FRAME_TYPE, _( "Library Browser" ), + wxDefaultPosition, wxDefaultSize, style ) { wxAcceleratorTable table( ACCEL_TABLE_CNT, accels ); @@ -120,10 +121,12 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library, wxSemaph m_LibListWindow = NULL; m_CmpListWindow = NULL; m_Semaphore = semaphore; + if( m_Semaphore ) + SetModalMode( true ); m_exportToEeschemaCmpName.Empty(); SetScreen( new SCH_SCREEN() ); - GetScreen()->m_Center = true; // Center coordinate origins on screen. + GetScreen()->m_Center = true; // Axis origin centered on screen. LoadSettings(); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); @@ -269,6 +272,7 @@ void LIB_VIEW_FRAME::OnCloseWindow( wxCloseEvent& Event ) m_Semaphore->Post(); // This window will be destroyed by the calling function, // if needed + SetModalMode( false ); } else { diff --git a/eeschema/viewlib_frame.h b/eeschema/viewlib_frame.h index ff3630e06e..b4df1e96a0 100644 --- a/eeschema/viewlib_frame.h +++ b/eeschema/viewlib_frame.h @@ -1,158 +1,160 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2008-2011 Wayne Stambaugh - * Copyright (C) 2004-2011 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 - */ - -/** - * @file viewlib_frame.h - */ - -#ifndef LIBVIEWFRM_H_ -#define LIBVIEWFRM_H_ - - -#include - -#include -#include - -class wxSashLayoutWindow; -class wxListBox; -class wxSemaphore; -class CMP_LIBRARY; - - -/** - * Component library viewer main window. - */ -class LIB_VIEW_FRAME : public SCH_BASE_FRAME -{ -private: - wxComboBox* SelpartBox; - - // List of libraries (for selection ) - wxSashLayoutWindow* m_LibListWindow; - wxListBox* m_LibList; // The list of libs - wxSize m_LibListSize; // size of the window - - // List of components in the selected library - wxSashLayoutWindow* m_CmpListWindow; - wxListBox* m_CmpList; // The list of components - wxSize m_CmpListSize; // size of the window - - // Flags - wxSemaphore* m_Semaphore; // != NULL if the frame must emulate a modal dialog - wxString m_configPath; // subpath for configuration - -protected: - static wxString m_libraryName; - static wxString m_entryName; - static wxString m_exportToEeschemaCmpName; // When the viewer is used to select a component - // in schematic, the selected component is here - static int m_unit; - static int m_convert; - -public: - LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library = NULL, wxSemaphore* semaphore = NULL ); - - ~LIB_VIEW_FRAME(); - - void OnSize( wxSizeEvent& event ); - - /** - * Function OnSashDrag - * resizes the child windows when dragging a sash window border. - */ - - void OnSashDrag( wxSashEvent& event ); - - /** - * Function ReCreateListLib - * - * Creates or recreates the list of current loaded libraries. - * This list is sorted, with the library cache always at end of the list - */ - void ReCreateListLib(); - - void ReCreateListCmp(); - void Process_Special_Functions( wxCommandEvent& event ); - void DisplayLibInfos(); - void RedrawActiveWindow( wxDC* DC, bool EraseBg ); - void OnCloseWindow( wxCloseEvent& Event ); - void ReCreateHToolbar(); - void ReCreateVToolbar(); - void OnLeftClick( wxDC* DC, const wxPoint& MousePos ); - double BestZoom(); - void ClickOnLibList( wxCommandEvent& event ); - void ClickOnCmpList( wxCommandEvent& event ); - void OnSetRelativeOffset( wxCommandEvent& event ); - - void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); - - /** - * Function LoadSettings - * loads the library viewer frame specific configuration settings. - * - * Don't forget to call this base method from any derived classes or the - * settings will not get loaded. - */ - void LoadSettings(); - - /** - * Function SaveSettings - * save library viewer frame specific configuration settings. - * - * Don't forget to call this base method from any derived classes or the - * settings will not get saved. - */ - void SaveSettings(); - - wxString& GetEntryName( void ) const { return m_entryName; } - wxString& GetSelectedComponent( void ) const { return m_exportToEeschemaCmpName; } - - int GetUnit( void ) { return m_unit; } - int GetConvert( void ) { return m_convert; } - -private: - /** - * Function OnActivate - * is called when the frame frame is activate to reload the libraries and component lists - * that can be changed by the schematic editor or the library editor. - */ - virtual void OnActivate( wxActivateEvent& event ); - - void SelectCurrentLibrary(); - void SelectAndViewLibraryPart( int option ); - - /** - * Function ExportToSchematicLibraryPart - * exports the current component to schematic and close the library browser. - */ - void ExportToSchematicLibraryPart( wxCommandEvent& event ); - void ViewOneLibraryContent( CMP_LIBRARY* Lib, int Flag ); - bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ); - - DECLARE_EVENT_TABLE() -}; - -#endif // LIBVIEWFRM_H_ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com + * Copyright (C) 2008-2011 Wayne Stambaugh + * Copyright (C) 2004-2011 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 + */ + +/** + * @file viewlib_frame.h + */ + +#ifndef LIBVIEWFRM_H_ +#define LIBVIEWFRM_H_ + + +#include + +#include +#include + +class wxSashLayoutWindow; +class wxListBox; +class wxSemaphore; +class CMP_LIBRARY; + + +/** + * Component library viewer main window. + */ +class LIB_VIEW_FRAME : public SCH_BASE_FRAME +{ +private: + wxComboBox* SelpartBox; + + // List of libraries (for selection ) + wxSashLayoutWindow* m_LibListWindow; + wxListBox* m_LibList; // The list of libs + wxSize m_LibListSize; // size of the window + + // List of components in the selected library + wxSashLayoutWindow* m_CmpListWindow; + wxListBox* m_CmpList; // The list of components + wxSize m_CmpListSize; // size of the window + + // Flags + wxSemaphore* m_Semaphore; // != NULL if the frame must emulate a modal dialog + wxString m_configPath; // subpath for configuration + +protected: + static wxString m_libraryName; + static wxString m_entryName; + static wxString m_exportToEeschemaCmpName; // When the viewer is used to select a component + // in schematic, the selected component is here + static int m_unit; + static int m_convert; + +public: + LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library = NULL, + wxSemaphore* semaphore = NULL, + long style = KICAD_DEFAULT_DRAWFRAME_STYLE ); + + ~LIB_VIEW_FRAME(); + + void OnSize( wxSizeEvent& event ); + + /** + * Function OnSashDrag + * resizes the child windows when dragging a sash window border. + */ + + void OnSashDrag( wxSashEvent& event ); + + /** + * Function ReCreateListLib + * + * Creates or recreates the list of current loaded libraries. + * This list is sorted, with the library cache always at end of the list + */ + void ReCreateListLib(); + + void ReCreateListCmp(); + void Process_Special_Functions( wxCommandEvent& event ); + void DisplayLibInfos(); + void RedrawActiveWindow( wxDC* DC, bool EraseBg ); + void OnCloseWindow( wxCloseEvent& Event ); + void ReCreateHToolbar(); + void ReCreateVToolbar(); + void OnLeftClick( wxDC* DC, const wxPoint& MousePos ); + double BestZoom(); + void ClickOnLibList( wxCommandEvent& event ); + void ClickOnCmpList( wxCommandEvent& event ); + void OnSetRelativeOffset( wxCommandEvent& event ); + + void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); + + /** + * Function LoadSettings + * loads the library viewer frame specific configuration settings. + * + * Don't forget to call this base method from any derived classes or the + * settings will not get loaded. + */ + void LoadSettings(); + + /** + * Function SaveSettings + * save library viewer frame specific configuration settings. + * + * Don't forget to call this base method from any derived classes or the + * settings will not get saved. + */ + void SaveSettings(); + + wxString& GetEntryName( void ) const { return m_entryName; } + wxString& GetSelectedComponent( void ) const { return m_exportToEeschemaCmpName; } + + int GetUnit( void ) { return m_unit; } + int GetConvert( void ) { return m_convert; } + +private: + /** + * Function OnActivate + * is called when the frame frame is activate to reload the libraries and component lists + * that can be changed by the schematic editor or the library editor. + */ + virtual void OnActivate( wxActivateEvent& event ); + + void SelectCurrentLibrary(); + void SelectAndViewLibraryPart( int option ); + + /** + * Function ExportToSchematicLibraryPart + * exports the current component to schematic and close the library browser. + */ + void ExportToSchematicLibraryPart( wxCommandEvent& event ); + void ViewOneLibraryContent( CMP_LIBRARY* Lib, int Flag ); + bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ); + + DECLARE_EVENT_TABLE() +}; + +#endif // LIBVIEWFRM_H_ diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 24e206b7f3..4f21687baf 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -63,7 +63,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* father, const wxPoint& pos, const wxSize& size, long style ) : - EDA_DRAW_FRAME( father, GERBER_FRAME, title, pos, size, style ) + EDA_DRAW_FRAME( father, GERBER_FRAME_TYPE, title, pos, size, style ) { m_colorsSettings = &g_ColorsSettings; m_Layout = NULL; diff --git a/include/sch_base_frame.h b/include/sch_base_frame.h index 41efe6842e..9ae1f9c828 100644 --- a/include/sch_base_frame.h +++ b/include/sch_base_frame.h @@ -57,7 +57,7 @@ protected: public: SCH_BASE_FRAME( wxWindow* aParent, - id_drawframe aWindowType, + ID_DRAWFRAME_TYPE aWindowType, const wxString& aTitle, const wxPoint& aPosition, const wxSize& aSize, long aStyle = KICAD_DEFAULT_DRAWFRAME_STYLE ); diff --git a/include/wxBasePcbFrame.h b/include/wxBasePcbFrame.h index dbf11335fa..db86a8c9f0 100644 --- a/include/wxBasePcbFrame.h +++ b/include/wxBasePcbFrame.h @@ -96,7 +96,8 @@ protected: virtual void unitsChangeRefresh(); public: - PCB_BASE_FRAME( wxWindow* father, int idtype, const wxString& title, + PCB_BASE_FRAME( wxWindow* father, ID_DRAWFRAME_TYPE idtype, + const wxString& title, const wxPoint& pos, const wxSize& size, long style = KICAD_DEFAULT_DRAWFRAME_STYLE ); diff --git a/include/wxstruct.h b/include/wxstruct.h index 0af8992150..4c6d0e899f 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -82,20 +82,22 @@ enum id_librarytype { LIBRARY_TYPE_SYMBOL }; -enum id_drawframe { - NOT_INIT_FRAME = 0, - SCHEMATIC_FRAME, - LIBEDITOR_FRAME, - VIEWER_FRAME, - PCB_FRAME, - MODULE_EDITOR_FRAME, - MODULE_VIEWER_FRAME, - CVPCB_FRAME, - CVPCB_DISPLAY_FRAME, - GERBER_FRAME, - TEXT_EDITOR_FRAME, - DISPLAY3D_FRAME, - KICAD_MAIN_FRAME +enum ID_DRAWFRAME_TYPE +{ + NOT_INIT_FRAME_TYPE = 0, + SCHEMATIC_FRAME_TYPE, + LIBEDITOR_FRAME_TYPE, + VIEWER_FRAME_TYPE, + PCB_FRAME_TYPE, + MODULE_EDITOR_FRAME_TYPE, + MODULE_VIEWER_FRAME_TYPE, + FOOTPRINT_WIZARD_FRAME_TYPE, + CVPCB_FRAME_TYPE, + CVPCB_DISPLAY_FRAME_TYPE, + GERBER_FRAME_TYPE, + TEXT_EDITOR_FRAME_TYPE, + DISPLAY3D_FRAME_TYPE, + KICAD_MAIN_FRAME_TYPE }; @@ -111,7 +113,7 @@ extern const wxChar* traceAutoSave; class EDA_BASE_FRAME : public wxFrame { protected: - int m_Ident; // Id Type (pcb, schematic, library..) + ID_DRAWFRAME_TYPE m_Ident; // Id Type (pcb, schematic, library..) wxPoint m_FramePos; wxSize m_FrameSize; int m_MsgFrameHeight; @@ -158,7 +160,8 @@ protected: virtual bool doAutoSave(); public: - EDA_BASE_FRAME( wxWindow* father, int idtype, const wxString& title, + EDA_BASE_FRAME( wxWindow* father, ID_DRAWFRAME_TYPE idtype, + const wxString& title, const wxPoint& pos, const wxSize& size, long style = KICAD_DEFAULT_DRAWFRAME_STYLE ); @@ -181,7 +184,7 @@ public: bool IsActive() const { return m_FrameIsActive; } - bool IsType( int aType ) const { return m_Ident == aType; } + bool IsType( ID_DRAWFRAME_TYPE aType ) const { return m_Ident == aType; } void GetKicadHelp( wxCommandEvent& event ); @@ -306,11 +309,6 @@ public: */ void UpdateFileHistory( const wxString& FullFileName, wxFileHistory * aFileHistory = NULL ); - /* - * Display a bargraph (0 to 50 point length) for a PerCent value from 0 to 100 - */ - void DisplayActivity( int PerCent, const wxString& Text ); - /** * Function ReCreateMenuBar * Creates recreates the menu bar. @@ -354,6 +352,19 @@ public: * used to create the backup file name. */ void CheckForAutoSaveFile( const wxFileName& aFileName, const wxString& aBackupFileExtension ); + + /** + * Function SetModalMode + * Disable or enable all other windows, to emulate a dialog behavior + * Useful when the frame is used to show and selec items + * (see FOOTPRINT_VIEWER_FRAME and LIB_VIEW_FRAME) + * + * @param aModal = true to disable all other opened windows (i.e. + * this windows is in dialog mode + * = false to enable other windows + * This function is analog to MakeModal( aModal ), deprecated since wxWidgets 2.9.4 + */ + void SetModalMode( bool aModal ); }; @@ -439,7 +450,8 @@ protected: virtual void unitsChangeRefresh(); public: - EDA_DRAW_FRAME( wxWindow* father, int idtype, const wxString& title, + EDA_DRAW_FRAME( wxWindow* father, ID_DRAWFRAME_TYPE idtype, + const wxString& title, const wxPoint& pos, const wxSize& size, long style = KICAD_DEFAULT_DRAWFRAME_STYLE ); @@ -470,7 +482,7 @@ public: void SetShowBorderAndTitleBlock( bool aShow ) { m_showBorderAndTitleBlock = aShow; } EDA_DRAW_PANEL* GetCanvas() { return m_canvas; } - + virtual wxString GetScreenDesc(); /** diff --git a/kicad/mainframe.cpp b/kicad/mainframe.cpp index 472907f178..dcd3d2fb10 100644 --- a/kicad/mainframe.cpp +++ b/kicad/mainframe.cpp @@ -46,7 +46,7 @@ KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title, const wxPoint& pos, const wxSize& size ) : - EDA_BASE_FRAME( parent, KICAD_MAIN_FRAME, title, pos, size ) + EDA_BASE_FRAME( parent, KICAD_MAIN_FRAME_TYPE, title, pos, size ) { wxString msg; wxString line; diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index eda2eff44a..24d82174b3 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -76,12 +76,10 @@ BEGIN_EVENT_TABLE( PCB_BASE_FRAME, EDA_DRAW_FRAME ) END_EVENT_TABLE() -PCB_BASE_FRAME::PCB_BASE_FRAME( wxWindow* father, - int idtype, +PCB_BASE_FRAME::PCB_BASE_FRAME( wxWindow* father, ID_DRAWFRAME_TYPE idtype, const wxString& title, - const wxPoint& pos, - const wxSize& size, - long style) : + const wxPoint& pos, const wxSize& size, + long style) : EDA_DRAW_FRAME( father, idtype, title, pos, size, style ) { m_Pcb = NULL; @@ -853,16 +851,16 @@ FOOTPRINT_VIEWER_FRAME * PCB_BASE_FRAME::GetActiveViewerFrame() switch( m_Ident ) { - case PCB_FRAME: + case PCB_FRAME_TYPE: if( m_ModuleEditFrame ) return ((PCB_BASE_FRAME*)m_ModuleEditFrame)->m_ModuleViewerFrame; break; - case MODULE_EDITOR_FRAME: + case MODULE_EDITOR_FRAME_TYPE: return ((PCB_BASE_FRAME*)GetParent())->m_ModuleViewerFrame; break; - case MODULE_VIEWER_FRAME: + case MODULE_VIEWER_FRAME_TYPE: return (FOOTPRINT_VIEWER_FRAME *)this; break; diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index 2cb21e53b7..bfa7e81bd2 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -446,7 +446,7 @@ void MODULE::DisplayInfo( EDA_DRAW_FRAME* frame ) frame->EraseMsgBox(); - if( frame->IsType( PCB_FRAME ) ) + if( frame->IsType( PCB_FRAME_TYPE ) ) flag = true; frame->AppendMsgPanel( m_Reference->m_Text, m_Value->m_Text, DARKCYAN ); diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index 9d070df617..8266895241 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -970,7 +970,7 @@ void TRACK::DisplayInfo( EDA_DRAW_FRAME* frame ) DisplayInfoBase( frame ); // Display full track length (in Pcbnew) - if( frame->IsType( PCB_FRAME ) ) + if( frame->IsType( PCB_FRAME_TYPE ) ) { int trackLen = 0; int lenDie = 0; @@ -1058,7 +1058,7 @@ void TRACK::DisplayInfoBase( EDA_DRAW_FRAME* frame ) frame->AppendMsgPanel( _( "Type" ), msg, DARKCYAN ); // Display Net Name (in Pcbnew) - if( frame->IsType( PCB_FRAME ) ) + if( frame->IsType( PCB_FRAME_TYPE ) ) { NETINFO_ITEM* net = board->FindNet( GetNet() ); diff --git a/pcbnew/dialogs/dialog_footprint_wizard_list.cpp b/pcbnew/dialogs/dialog_footprint_wizard_list.cpp index d517e8c1c9..d6ccf56ba8 100644 --- a/pcbnew/dialogs/dialog_footprint_wizard_list.cpp +++ b/pcbnew/dialogs/dialog_footprint_wizard_list.cpp @@ -20,20 +20,20 @@ DIALOG_FOOTPRINT_WIZARD_LIST::DIALOG_FOOTPRINT_WIZARD_LIST( wxWindow* aParent ) { SetFocus(); int n_wizards = FOOTPRINT_WIZARDS::GetSize(); - + // Current wizard selection, empty or first m_FootprintWizard = NULL; - + if (n_wizards) m_FootprintWizard = FOOTPRINT_WIZARDS::GetWizard(0); - + // Choose selection mode and insert the needed rows - + m_footprintWizardsGrid->SetColSize( 0, 0 ); // hide the preview for now - + m_footprintWizardsGrid->SetSelectionMode(wxGrid::wxGridSelectRows); m_footprintWizardsGrid->InsertRows(0,n_wizards,true); - + // Put all wizards in the list for (int i=0;iGetName(); wxString description = wizard->GetDescription(); wxString image = wizard->GetImage(); - + m_footprintWizardsGrid->SetCellValue(i,1,name); m_footprintWizardsGrid->SetCellValue(i,2,description); - + } - + // Select the first row m_footprintWizardsGrid->ClearSelection(); m_footprintWizardsGrid->SelectRow(0,false); @@ -68,6 +68,5 @@ FOOTPRINT_WIZARD* DIALOG_FOOTPRINT_WIZARD_LIST::GetWizard() void DIALOG_FOOTPRINT_WIZARD_LIST::OnOpenButtonClick( wxCommandEvent& event ) { - this->MakeModal(false); - this->Close(true); + Close(true); } diff --git a/pcbnew/edtxtmod.cpp b/pcbnew/edtxtmod.cpp index 1522fd37ce..28e7e8a1af 100644 --- a/pcbnew/edtxtmod.cpp +++ b/pcbnew/edtxtmod.cpp @@ -108,7 +108,7 @@ void PCB_BASE_FRAME::RotateTextModule( TEXTE_MODULE* Text, wxDC* DC ) if( module && module->GetFlags() == 0 && Text->GetFlags() == 0 ) // prepare undo command { - if( this->m_Ident == PCB_FRAME ) + if( IsType( PCB_FRAME_TYPE ) ) SaveCopyInUndoList( module, UR_CHANGED ); } @@ -239,7 +239,7 @@ void PCB_BASE_FRAME::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC ) // Prepare undo command (a rotation can be made while moving) EXCHG( Text->m_Orient, TextInitialOrientation ); - if( m_Ident == PCB_FRAME ) + if( IsType( PCB_FRAME_TYPE ) ) SaveCopyInUndoList( Module, UR_CHANGED ); else SaveCopyInUndoList( Module, UR_MODEDIT ); diff --git a/pcbnew/footprint_wizard_frame.cpp b/pcbnew/footprint_wizard_frame.cpp index 4ebde0a870..88a935f60e 100644 --- a/pcbnew/footprint_wizard_frame.cpp +++ b/pcbnew/footprint_wizard_frame.cpp @@ -1,6 +1,6 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. - * + * * Copyright (C) 2012 Miguel Angel Ajo Pelayo * Copyright (C) 2012 Jean-Pierre Charras, jaen-pierre.charras * Copyright (C) 2008-2011 Wayne Stambaugh @@ -30,7 +30,6 @@ #include #include -#include #include #include #include <3d_viewer.h> @@ -38,6 +37,7 @@ #include #include +#include #include #include @@ -73,7 +73,7 @@ BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_FRAME, EDA_DRAW_FRAME ) EVT_TOOL( ID_FOOTPRINT_WIZARD_DONE, FOOTPRINT_WIZARD_FRAME::ExportSelectedFootprint ) - EVT_TOOL( ID_FOOTPRINT_WIZARD_SHOW_3D_VIEW, + EVT_TOOL( ID_FOOTPRINT_WIZARD_SHOW_3D_VIEW, FOOTPRINT_WIZARD_FRAME::Show3D_Frame ) /* listbox events */ @@ -105,11 +105,13 @@ static wxAcceleratorEntry accels[] = /* Function FOOTPRINT_WIZARD_FRAME * it's the constructor for the footprint wizard frame, it creates everything inside - * + * */ -FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* semaphore ) : - PCB_BASE_FRAME( parent, MODULE_VIEWER_FRAME, _( "Footprint Wizard" ), - wxDefaultPosition, wxDefaultSize ) +FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( FOOTPRINT_EDIT_FRAME* parent, + wxSemaphore* semaphore, long style ) : + PCB_BASE_FRAME( parent, FOOTPRINT_WIZARD_FRAME_TYPE, + _( "Footprint Wizard" ), + wxDefaultPosition, wxDefaultSize, style ) { wxAcceleratorTable table( ACCEL_TABLE_CNT, accels ); @@ -132,7 +134,7 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* s m_wizardName.Empty(); if( m_Semaphore ) - MakeModal(true); + SetModalMode(true); SetBoard( new BOARD() ); // Ensure all layers and items are visible: @@ -170,12 +172,12 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* s // Creates the component window display m_ParameterGridSize.y = size.y; win_pos.x = m_PageListSize.x; - m_ParameterGridWindow = new wxSashLayoutWindow( this, + m_ParameterGridWindow = new wxSashLayoutWindow( this, ID_FOOTPRINT_WIZARD_PARAMETERS_WINDOW, win_pos, wxDefaultSize, wxCLIP_CHILDREN | wxSW_3D, wxT( "ParameterList" ) ); - + m_ParameterGridWindow->SetOrientation( wxLAYOUT_VERTICAL ); m_ParameterGridWindow->SetSashVisible( wxSASH_RIGHT, true ); @@ -243,7 +245,7 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* s pane.MinSize( wxSize( m_ParameterGridSize.x, -1 ) ); m_auimgr.Update(); - + // Now Drawpanel is sized, we can use BestZoom to show the component (if any) #ifdef USE_WX_GRAPHICS_CONTEXT GetScreen()->SetZoom( BestZoom() ); @@ -251,9 +253,9 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* s Zoom_Automatique( false ); #endif - + Show( true ); - + this->SelectFootprintWizard(); } @@ -262,14 +264,12 @@ FOOTPRINT_WIZARD_FRAME::~FOOTPRINT_WIZARD_FRAME() { if( m_Draw3DFrame ) m_Draw3DFrame->Destroy(); - PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) GetParent(); - frame->m_ModuleViewerFrame = NULL; } /* Function OnCloseWindow * Handles the close event, saving settings an destroying or releasing a semaphore from caller - * + * */ void FOOTPRINT_WIZARD_FRAME::OnCloseWindow( wxCloseEvent& Event ) { @@ -285,7 +285,7 @@ void FOOTPRINT_WIZARD_FRAME::ExportSelectedFootprint( wxCommandEvent& aEvent ) if( m_Semaphore ) { m_Semaphore->Post(); - MakeModal(false); + SetModalMode(false); // This window will be destroyed by the calling function, // to avoid side effects } @@ -294,12 +294,12 @@ void FOOTPRINT_WIZARD_FRAME::ExportSelectedFootprint( wxCommandEvent& aEvent ) Destroy(); } - + } /* Function OnSashDrag - * handles the horizontal separator (sash) drag, updating the pagelist or parameter list + * handles the horizontal separator (sash) drag, updating the pagelist or parameter list */ void FOOTPRINT_WIZARD_FRAME::OnSashDrag( wxSashEvent& event ) { @@ -334,8 +334,8 @@ void FOOTPRINT_WIZARD_FRAME::OnSashDrag( wxSashEvent& event ) /* Function OnSize - * It handles a dialog resize event, asking for an update - * + * It handles a dialog resize event, asking for an update + * */ void FOOTPRINT_WIZARD_FRAME::OnSize( wxSizeEvent& SizeEv ) { @@ -346,8 +346,8 @@ void FOOTPRINT_WIZARD_FRAME::OnSize( wxSizeEvent& SizeEv ) } /* Function OnSetRelativeOffset - * Updates the cursor position and the status bar - * + * Updates the cursor position and the status bar + * */ void FOOTPRINT_WIZARD_FRAME::OnSetRelativeOffset( wxCommandEvent& event ) { @@ -357,13 +357,13 @@ void FOOTPRINT_WIZARD_FRAME::OnSetRelativeOffset( wxCommandEvent& event ) /* Function ReCreatePageList * It recreates the list of pages for a new loaded wizard - * + * */ void FOOTPRINT_WIZARD_FRAME::ReCreatePageList() { if( m_PageList == NULL ) return; - + if (m_FootprintWizard == NULL) return; @@ -374,9 +374,9 @@ void FOOTPRINT_WIZARD_FRAME::ReCreatePageList() wxString name = m_FootprintWizard->GetParameterPageName( i ); m_PageList->Append( name ); } - + m_PageList->SetSelection( 0, true ); - + ReCreateParameterList(); ReCreateHToolbar(); DisplayWizardInfos(); @@ -385,24 +385,24 @@ void FOOTPRINT_WIZARD_FRAME::ReCreatePageList() /* Function ReCreateParameterList * It creates the parameter grid for a certain wizard page of the current wizard - * + * */ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList() { if( m_ParameterGrid == NULL ) return; - + if (m_FootprintWizard == NULL ) return; - + int page = m_PageList->GetSelection(); - + if (page<0) return; m_ParameterGrid->ClearGrid(); - + // Columns m_ParameterGrid->AutoSizeColumns(); m_ParameterGrid->SetColLabelSize( 20 ); @@ -410,34 +410,34 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList() m_ParameterGrid->SetColLabelValue( 1, _("Value") ); m_ParameterGrid->SetColLabelValue( 2, _("Units") ); m_ParameterGrid->SetColLabelAlignment( wxALIGN_LEFT, wxALIGN_CENTRE ); - + // Rows m_ParameterGrid->AutoSizeRows(); m_ParameterGrid->EnableDragRowSize( true ); m_ParameterGrid->SetRowLabelSize( 1 ); m_ParameterGrid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); - + // Get the list of names, values, and types wxArrayString fpList = m_FootprintWizard->GetParameterNames(page); wxArrayString fvList = m_FootprintWizard->GetParameterValues(page); wxArrayString ptList = m_FootprintWizard->GetParameterTypes(page); - - // Dimension the wxGrid + + // Dimension the wxGrid m_ParameterGrid->CreateGrid(fpList.size(),3); - + for (unsigned int i=0; iSetCellValue( i, 0, name ); m_ParameterGrid->SetReadOnly( i, 0 ); - - if ( ptList[i]==wxT( "IU" ) ) + + if ( ptList[i]==wxT( "IU" ) ) { - // We are handling internal units, so convert them to the current + // We are handling internal units, so convert them to the current // system selected units and store into value. double dValue; value.ToDouble( &dValue ); @@ -445,10 +445,10 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList() dValue = To_User_Unit( g_UserUnit, dValue ); if ( g_UserUnit==INCHES ) // we convert inches into mils for more detail - { + { dValue = dValue*1000.0; units = wxT( "mils" ); - } + } else if ( g_UserUnit==MILLIMETRES ) { units = wxT( "mm" ); @@ -461,13 +461,13 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList() units = wxT( "" ); } - m_ParameterGrid->SetCellValue( i, 1 , value ); + m_ParameterGrid->SetCellValue( i, 1 , value ); m_ParameterGrid->SetCellValue( i, 2 , units ); m_ParameterGrid->SetReadOnly( i, 2 ); } - + m_ParameterGrid->AutoSizeColumns(); - + } @@ -476,8 +476,8 @@ void FOOTPRINT_WIZARD_FRAME::ClickOnPageList( wxCommandEvent& event ) int ii = m_PageList->GetSelection(); if( ii < 0 ) - return; - + return; + ReCreateParameterList(); m_canvas->Refresh(); DisplayWizardInfos(); @@ -510,7 +510,7 @@ void FOOTPRINT_WIZARD_FRAME::LoadSettings( ) if ( m_ParameterGridSize.x > m_FrameSize.x/2 ) m_ParameterGridSize.x = m_FrameSize.x/2; - + } @@ -544,7 +544,7 @@ void FOOTPRINT_WIZARD_FRAME::OnActivate( wxActivateEvent& event ) // If we are here, the library list has changed, rebuild it ReCreatePageList(); DisplayWizardInfos(); - + } } diff --git a/pcbnew/footprint_wizard_frame.h b/pcbnew/footprint_wizard_frame.h index de30807a77..6a71ee08bd 100644 --- a/pcbnew/footprint_wizard_frame.h +++ b/pcbnew/footprint_wizard_frame.h @@ -1,200 +1,202 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2012 Miguel Angel Ajo Pelayo, miguelangel@nbee.es - * Copyright (C) 2012 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2004-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 - */ - -/** - * @file footprint_wizard_frame.h - */ - -#ifndef FOOTPRINT_WIZARD_FRAME_H_ -#define FOOTPRINT_WIZARD_FRAME_H_ - - -#include -#include -class wxSashLayoutWindow; -class wxListBox; -class wxSemaphore; -class wxGrid; -class wxGridEvent; - - -/** - * Component library viewer main window. - */ -class FOOTPRINT_WIZARD_FRAME : public PCB_BASE_FRAME -{ -private: - - wxSashLayoutWindow* m_PageListWindow; //< List of libraries (for selection ) - wxListBox* m_PageList; //< The list of pages - wxSize m_PageListSize; //< size of the window - - - wxSashLayoutWindow* m_ParameterGridWindow; //< List of components in the selected library - wxGrid* m_ParameterGrid; //< The list of parameters - wxSize m_ParameterGridSize; //< size of the window - - // Flags - wxSemaphore* m_Semaphore; //< != NULL if the frame must emulate a modal dialog - wxString m_configPath; //< subpath for configuration - - FOOTPRINT_WIZARD* m_FootprintWizard; - -protected: - wxString m_wizardName; //< name of the current wizard - wxString m_wizardDescription; //< description of the wizard - wxString m_wizardStatus; //< current wizard status - -public: - FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* semaphore = NULL ); - - ~FOOTPRINT_WIZARD_FRAME(); - - MODULE* GetBuiltFootprint( void ); - -private: - - void OnSize( wxSizeEvent& event ); - /** - * Function ExportSelectedFootprint(); - * will let the caller exit from the wait loop, and get the built footprint - * - */ - void ExportSelectedFootprint( wxCommandEvent& aEvent ); - - /** - * Function OnSashDrag - * resizes the child windows when dragging a sash window border. - */ - - void OnSashDrag( wxSashEvent& event ); - - /** - * Function ReCreatePageList - * Creates or recreates the list of parameter pages for the current wizard. - * This list is sorted - */ - void ReCreatePageList(); - - /** - * Function ReCreateParameterList - * Creates the list of parameters for the current page - */ - void ReCreateParameterList(); - - /** - * Function SelectFootprintWizard - * Shows the list of footprint wizards available into the system - */ - void SelectFootprintWizard(); - - /** - * Function ReloadFootprint - * Reloads the current footprint - */ - void ReloadFootprint(); - - - void Process_Special_Functions( wxCommandEvent& event ); - - /** - * Function DisplayWizardInfos - * Shows all the details about the current wizard - */ - void DisplayWizardInfos(); - - - void RedrawActiveWindow( wxDC* DC, bool EraseBg ); - void OnCloseWindow( wxCloseEvent& Event ); - void ReCreateHToolbar(); - void ReCreateVToolbar(); - void OnLeftClick( wxDC* DC, const wxPoint& MousePos ); - void ClickOnPageList( wxCommandEvent& event ); - void OnSetRelativeOffset( wxCommandEvent& event ); - - void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); - - /** - * Function LoadSettings - * loads the library viewer frame specific configuration settings. - * - * Don't forget to call this base method from any derived classes or the - * settings will not get loaded. - */ - void LoadSettings(); - - /** - * Function SaveSettings - * save library viewer frame specific configuration settings. - * - * Don't forget to call this base method from any derived classes or the - * settings will not get saved. - */ - void SaveSettings(); - - - /** - * Function OnActivate - * is called when the frame frame is activate to reload the libraries and component lists - * that can be changed by the schematic editor or the library editor. - */ - virtual void OnActivate( wxActivateEvent& event ); - - void SelectCurrentWizard( wxCommandEvent& event ); - - void ParametersUpdated( wxGridEvent& event ); - - - - bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ); - - /** - * Function Show3D_Frame (virtual) - * displays 3D view of the footprint (module) being edited. - */ - void Show3D_Frame( wxCommandEvent& event ); - - /** - * Function Update3D_Frame - * must be called after a footprint selection - * Updates the 3D view and 3D frame title. - * @param aForceReloadFootprint = true to reload data (default) - * = false to update title only -(aftre creating the 3D viewer) - */ - void Update3D_Frame( bool aForceReloadFootprint = true ); - - /* - * Virtual functions, not used here, but needed by PCB_BASE_FRAME - * (virtual pure functions ) - */ - void OnLeftDClick(wxDC*, const wxPoint&) {} - void SaveCopyInUndoList(BOARD_ITEM*, UNDO_REDO_T, const wxPoint&) {} - void SaveCopyInUndoList(PICKED_ITEMS_LIST&, UNDO_REDO_T, const wxPoint&) {} - - - DECLARE_EVENT_TABLE() -}; - -#endif // FOOTPRINT_WIZARD_FRM_H_ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2012 Miguel Angel Ajo Pelayo, miguelangel@nbee.es + * Copyright (C) 2012 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com + * Copyright (C) 2004-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 + */ + +/** + * @file footprint_wizard_frame.h + */ + +#ifndef FOOTPRINT_WIZARD_FRAME_H_ +#define FOOTPRINT_WIZARD_FRAME_H_ + + +#include +#include +class wxSashLayoutWindow; +class wxListBox; +class wxSemaphore; +class wxGrid; +class wxGridEvent; + + +/** + * Component library viewer main window. + */ +class FOOTPRINT_WIZARD_FRAME : public PCB_BASE_FRAME +{ +private: + + wxSashLayoutWindow* m_PageListWindow; //< List of libraries (for selection ) + wxListBox* m_PageList; //< The list of pages + wxSize m_PageListSize; //< size of the window + + + wxSashLayoutWindow* m_ParameterGridWindow; //< List of components in the selected library + wxGrid* m_ParameterGrid; //< The list of parameters + wxSize m_ParameterGridSize; //< size of the window + + // Flags + wxSemaphore* m_Semaphore; //< != NULL if the frame must emulate a modal dialog + wxString m_configPath; //< subpath for configuration + + FOOTPRINT_WIZARD* m_FootprintWizard; + +protected: + wxString m_wizardName; //< name of the current wizard + wxString m_wizardDescription; //< description of the wizard + wxString m_wizardStatus; //< current wizard status + +public: + FOOTPRINT_WIZARD_FRAME( FOOTPRINT_EDIT_FRAME* parent, + wxSemaphore* semaphore = NULL, + long style = KICAD_DEFAULT_DRAWFRAME_STYLE ); + + ~FOOTPRINT_WIZARD_FRAME(); + + MODULE* GetBuiltFootprint( void ); + +private: + + void OnSize( wxSizeEvent& event ); + /** + * Function ExportSelectedFootprint(); + * will let the caller exit from the wait loop, and get the built footprint + * + */ + void ExportSelectedFootprint( wxCommandEvent& aEvent ); + + /** + * Function OnSashDrag + * resizes the child windows when dragging a sash window border. + */ + + void OnSashDrag( wxSashEvent& event ); + + /** + * Function ReCreatePageList + * Creates or recreates the list of parameter pages for the current wizard. + * This list is sorted + */ + void ReCreatePageList(); + + /** + * Function ReCreateParameterList + * Creates the list of parameters for the current page + */ + void ReCreateParameterList(); + + /** + * Function SelectFootprintWizard + * Shows the list of footprint wizards available into the system + */ + void SelectFootprintWizard(); + + /** + * Function ReloadFootprint + * Reloads the current footprint + */ + void ReloadFootprint(); + + + void Process_Special_Functions( wxCommandEvent& event ); + + /** + * Function DisplayWizardInfos + * Shows all the details about the current wizard + */ + void DisplayWizardInfos(); + + + void RedrawActiveWindow( wxDC* DC, bool EraseBg ); + void OnCloseWindow( wxCloseEvent& Event ); + void ReCreateHToolbar(); + void ReCreateVToolbar(); + void OnLeftClick( wxDC* DC, const wxPoint& MousePos ); + void ClickOnPageList( wxCommandEvent& event ); + void OnSetRelativeOffset( wxCommandEvent& event ); + + void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); + + /** + * Function LoadSettings + * loads the library viewer frame specific configuration settings. + * + * Don't forget to call this base method from any derived classes or the + * settings will not get loaded. + */ + void LoadSettings(); + + /** + * Function SaveSettings + * save library viewer frame specific configuration settings. + * + * Don't forget to call this base method from any derived classes or the + * settings will not get saved. + */ + void SaveSettings(); + + + /** + * Function OnActivate + * is called when the frame frame is activate to reload the libraries and component lists + * that can be changed by the schematic editor or the library editor. + */ + virtual void OnActivate( wxActivateEvent& event ); + + void SelectCurrentWizard( wxCommandEvent& event ); + + void ParametersUpdated( wxGridEvent& event ); + + + + bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ); + + /** + * Function Show3D_Frame (virtual) + * displays 3D view of the footprint (module) being edited. + */ + void Show3D_Frame( wxCommandEvent& event ); + + /** + * Function Update3D_Frame + * must be called after a footprint selection + * Updates the 3D view and 3D frame title. + * @param aForceReloadFootprint = true to reload data (default) + * = false to update title only -(aftre creating the 3D viewer) + */ + void Update3D_Frame( bool aForceReloadFootprint = true ); + + /* + * Virtual functions, not used here, but needed by PCB_BASE_FRAME + * (virtual pure functions ) + */ + void OnLeftDClick(wxDC*, const wxPoint&) {} + void SaveCopyInUndoList(BOARD_ITEM*, UNDO_REDO_T, const wxPoint&) {} + void SaveCopyInUndoList(PICKED_ITEMS_LIST&, UNDO_REDO_T, const wxPoint&) {} + + + DECLARE_EVENT_TABLE() +}; + +#endif // FOOTPRINT_WIZARD_FRM_H_ diff --git a/pcbnew/loadcmp.cpp b/pcbnew/loadcmp.cpp index 5c261d2b11..b366ac83a4 100644 --- a/pcbnew/loadcmp.cpp +++ b/pcbnew/loadcmp.cpp @@ -116,7 +116,7 @@ wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser( void ) { wxSemaphore semaphore( 0, 1 ); - // Close the current Lib browser, if open, and open a new one, in "modal" mode: + // Close the current Lib browser, if opened, and open a new one, in "modal" mode: FOOTPRINT_VIEWER_FRAME * viewer = GetActiveViewerFrame(); if( viewer ) { @@ -127,7 +127,8 @@ wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser( void ) m_ModuleEditFrame->m_ModuleViewerFrame = NULL; } - m_ModuleViewerFrame = new FOOTPRINT_VIEWER_FRAME( this, &semaphore ); + m_ModuleViewerFrame = new FOOTPRINT_VIEWER_FRAME( this, &semaphore, + KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT ); // Show the library viewer frame until it is closed while( semaphore.TryWait() == wxSEMA_BUSY ) // Wait for viewer closing event diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index 3a30a91c62..b264cc90a8 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -296,9 +296,9 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) SetCurItem( NULL ); GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) ); - wxSemaphore semaphore( 0, 1 ); - FOOTPRINT_WIZARD_FRAME *wizard = new FOOTPRINT_WIZARD_FRAME( this, &semaphore ); + FOOTPRINT_WIZARD_FRAME *wizard = new FOOTPRINT_WIZARD_FRAME( this, &semaphore, + KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT ); wizard->Show( true ); wizard->Zoom_Automatique( false ); diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index d86733f7d1..b91216035d 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -148,7 +148,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( PCB_EDIT_FRAME* aParent, const wxPoint& pos, const wxSize& size, long style ) : - PCB_BASE_FRAME( aParent, MODULE_EDITOR_FRAME, wxEmptyString, pos, size, style ) + PCB_BASE_FRAME( aParent, MODULE_EDITOR_FRAME_TYPE, wxEmptyString, pos, size, style ) { m_FrameName = wxT( "ModEditFrame" ); m_showBorderAndTitleBlock = false; // true to show the frame references diff --git a/pcbnew/modview_frame.cpp b/pcbnew/modview_frame.cpp index 8c47ea7487..66a88e2361 100644 --- a/pcbnew/modview_frame.cpp +++ b/pcbnew/modview_frame.cpp @@ -1,9 +1,9 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2012 Jean-Pierre Charras, jaen-pierre.charras + * Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2008-2011 Wayne Stambaugh - * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-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 @@ -29,7 +29,6 @@ #include #include -#include #include #include #include <3d_viewer.h> @@ -109,9 +108,10 @@ static wxAcceleratorEntry accels[] = #define EXTRA_BORDER_SIZE 2 -FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( wxWindow* parent, wxSemaphore* semaphore ) : - PCB_BASE_FRAME( parent, MODULE_VIEWER_FRAME, _( "Footprint Library Browser" ), - wxDefaultPosition, wxDefaultSize ) +FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* parent, + wxSemaphore* semaphore, long style ) : + PCB_BASE_FRAME( parent, MODULE_VIEWER_FRAME_TYPE, _( "Footprint Library Browser" ), + wxDefaultPosition, wxDefaultSize, style ) { wxAcceleratorTable table( ACCEL_TABLE_CNT, accels ); @@ -133,7 +133,7 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( wxWindow* parent, wxSemaphore* s m_selectedFootprintName.Empty(); if( m_Semaphore ) - MakeModal(true); + SetModalMode(true); SetBoard( new BOARD() ); // Ensure all layers and items are visible: @@ -276,7 +276,7 @@ void FOOTPRINT_VIEWER_FRAME::OnCloseWindow( wxCloseEvent& Event ) if( m_Semaphore ) { m_Semaphore->Post(); - MakeModal(false); + SetModalMode(false); // This window will be destroyed by the calling function, // to avoid side effects } diff --git a/pcbnew/modview_frame.h b/pcbnew/modview_frame.h index 5ef1bc3462..bf49ddf2ad 100644 --- a/pcbnew/modview_frame.h +++ b/pcbnew/modview_frame.h @@ -1,180 +1,181 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2012 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2004-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 - */ - -/** - * @file modview_frame.h - */ - -#ifndef MODVIEWFRM_H_ -#define MODVIEWFRM_H_ - - -#include - -class wxSashLayoutWindow; -class wxListBox; -class wxSemaphore; - - -/** - * Component library viewer main window. - */ -class FOOTPRINT_VIEWER_FRAME : public PCB_BASE_FRAME -{ -private: - // List of libraries (for selection ) - wxSashLayoutWindow* m_LibListWindow; - wxListBox* m_LibList; // The list of libs names - wxSize m_LibListSize; // size of the window - - // List of components in the selected library - wxSashLayoutWindow* m_FootprintListWindow; - wxListBox* m_FootprintList; // The list of footprint names - wxSize m_FootprintListSize; // size of the window - - // Flags - wxSemaphore* m_Semaphore; // != NULL if the frame must emulate a modal dialog - wxString m_configPath; // subpath for configuration - -protected: - static wxString m_libraryName; // Current selected libary - static wxString m_footprintName; // Current selected footprint - static wxString m_selectedFootprintName; // When the viewer is used to select a footprint - // the selected footprint is here - -public: - FOOTPRINT_VIEWER_FRAME( wxWindow* parent, wxSemaphore* semaphore = NULL ); - - ~FOOTPRINT_VIEWER_FRAME(); - - wxString& GetSelectedFootprint( void ) const { return m_selectedFootprintName; } - -private: - - void OnSize( wxSizeEvent& event ); - - /** - * Function OnSashDrag - * resizes the child windows when dragging a sash window border. - */ - - void OnSashDrag( wxSashEvent& event ); - - /** - * Function ReCreateLibraryList - * - * Creates or recreates the list of current loaded libraries. - * This list is sorted, with the library cache always at end of the list - */ - void ReCreateLibraryList(); - - void ReCreateFootprintList(); - void Process_Special_Functions( wxCommandEvent& event ); - void DisplayLibInfos(); - void RedrawActiveWindow( wxDC* DC, bool EraseBg ); - void OnCloseWindow( wxCloseEvent& Event ); - void ReCreateHToolbar(); - void ReCreateVToolbar(); - void OnLeftClick( wxDC* DC, const wxPoint& MousePos ); - void ClickOnLibList( wxCommandEvent& event ); - void ClickOnFootprintList( wxCommandEvent& event ); - void OnSetRelativeOffset( wxCommandEvent& event ); - - void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); - - /** - * Function LoadSettings - * loads the library viewer frame specific configuration settings. - * - * Don't forget to call this base method from any derived classes or the - * settings will not get loaded. - */ - void LoadSettings(); - - /** - * Function SaveSettings - * save library viewer frame specific configuration settings. - * - * Don't forget to call this base method from any derived classes or the - * settings will not get saved. - */ - void SaveSettings(); - - wxString& GetFootprintName( void ) const { return m_footprintName; } - - /** - * Function OnActivate - * is called when the frame frame is activate to reload the libraries and component lists - * that can be changed by the schematic editor or the library editor. - */ - virtual void OnActivate( wxActivateEvent& event ); - - void SelectCurrentLibrary( wxCommandEvent& event ); - - void SelectCurrentFootprint( wxCommandEvent& event ); - - /** - * Function ExportSelectedFootprint - * exports the current footprint name and close the library browser. - */ - void ExportSelectedFootprint( wxCommandEvent& event ); - - /** - * Function SelectAndViewFootprint - * Select and load the next or the previous footprint - * if no current footprint, Rebuild the list of footprints availlable in a given footprint library - * @param aMode = NEXT_PART or PREVIOUS_PART - */ - void SelectAndViewFootprint( int aMode ); - - bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ); - - /** - * Function Show3D_Frame (virtual) - * displays 3D view of the footprint (module) being edited. - */ - void Show3D_Frame( wxCommandEvent& event ); - - /** - * Function Update3D_Frame - * must be called after a footprint selection - * Updates the 3D view and 3D frame title. - * @param aForceReloadFootprint = true to reload data (default) - * = false to update title only -(aftre creating the 3D viewer) - */ - void Update3D_Frame( bool aForceReloadFootprint = true ); - - /* - * Virtual functions, not used here, but needed by PCB_BASE_FRAME - * (virtual pure functions ) - */ - void OnLeftDClick(wxDC*, const wxPoint&) {} - void SaveCopyInUndoList(BOARD_ITEM*, UNDO_REDO_T, const wxPoint&) {} - void SaveCopyInUndoList(PICKED_ITEMS_LIST&, UNDO_REDO_T, const wxPoint&) {} - - - DECLARE_EVENT_TABLE() -}; - -#endif // MODVIEWFRM_H_ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2012 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com + * Copyright (C) 2004-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 + */ + +/** + * @file modview_frame.h + */ + +#ifndef MODVIEWFRM_H_ +#define MODVIEWFRM_H_ + + +#include + +class wxSashLayoutWindow; +class wxListBox; +class wxSemaphore; + + +/** + * Component library viewer main window. + */ +class FOOTPRINT_VIEWER_FRAME : public PCB_BASE_FRAME +{ +private: + // List of libraries (for selection ) + wxSashLayoutWindow* m_LibListWindow; + wxListBox* m_LibList; // The list of libs names + wxSize m_LibListSize; // size of the window + + // List of components in the selected library + wxSashLayoutWindow* m_FootprintListWindow; + wxListBox* m_FootprintList; // The list of footprint names + wxSize m_FootprintListSize; // size of the window + + // Flags + wxSemaphore* m_Semaphore; // != NULL if the frame must emulate a modal dialog + wxString m_configPath; // subpath for configuration + +protected: + static wxString m_libraryName; // Current selected libary + static wxString m_footprintName; // Current selected footprint + static wxString m_selectedFootprintName; // When the viewer is used to select a footprint + // the selected footprint is here + +public: + FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* parent, wxSemaphore* semaphore = NULL, + long style = KICAD_DEFAULT_DRAWFRAME_STYLE ); + + ~FOOTPRINT_VIEWER_FRAME(); + + wxString& GetSelectedFootprint( void ) const { return m_selectedFootprintName; } + +private: + + void OnSize( wxSizeEvent& event ); + + /** + * Function OnSashDrag + * resizes the child windows when dragging a sash window border. + */ + + void OnSashDrag( wxSashEvent& event ); + + /** + * Function ReCreateLibraryList + * + * Creates or recreates the list of current loaded libraries. + * This list is sorted, with the library cache always at end of the list + */ + void ReCreateLibraryList(); + + void ReCreateFootprintList(); + void Process_Special_Functions( wxCommandEvent& event ); + void DisplayLibInfos(); + void RedrawActiveWindow( wxDC* DC, bool EraseBg ); + void OnCloseWindow( wxCloseEvent& Event ); + void ReCreateHToolbar(); + void ReCreateVToolbar(); + void OnLeftClick( wxDC* DC, const wxPoint& MousePos ); + void ClickOnLibList( wxCommandEvent& event ); + void ClickOnFootprintList( wxCommandEvent& event ); + void OnSetRelativeOffset( wxCommandEvent& event ); + + void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); + + /** + * Function LoadSettings + * loads the library viewer frame specific configuration settings. + * + * Don't forget to call this base method from any derived classes or the + * settings will not get loaded. + */ + void LoadSettings(); + + /** + * Function SaveSettings + * save library viewer frame specific configuration settings. + * + * Don't forget to call this base method from any derived classes or the + * settings will not get saved. + */ + void SaveSettings(); + + wxString& GetFootprintName( void ) const { return m_footprintName; } + + /** + * Function OnActivate + * is called when the frame frame is activate to reload the libraries and component lists + * that can be changed by the schematic editor or the library editor. + */ + virtual void OnActivate( wxActivateEvent& event ); + + void SelectCurrentLibrary( wxCommandEvent& event ); + + void SelectCurrentFootprint( wxCommandEvent& event ); + + /** + * Function ExportSelectedFootprint + * exports the current footprint name and close the library browser. + */ + void ExportSelectedFootprint( wxCommandEvent& event ); + + /** + * Function SelectAndViewFootprint + * Select and load the next or the previous footprint + * if no current footprint, Rebuild the list of footprints availlable in a given footprint library + * @param aMode = NEXT_PART or PREVIOUS_PART + */ + void SelectAndViewFootprint( int aMode ); + + bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ); + + /** + * Function Show3D_Frame (virtual) + * displays 3D view of the footprint (module) being edited. + */ + void Show3D_Frame( wxCommandEvent& event ); + + /** + * Function Update3D_Frame + * must be called after a footprint selection + * Updates the 3D view and 3D frame title. + * @param aForceReloadFootprint = true to reload data (default) + * = false to update title only -(aftre creating the 3D viewer) + */ + void Update3D_Frame( bool aForceReloadFootprint = true ); + + /* + * Virtual functions, not used here, but needed by PCB_BASE_FRAME + * (virtual pure functions ) + */ + void OnLeftDClick(wxDC*, const wxPoint&) {} + void SaveCopyInUndoList(BOARD_ITEM*, UNDO_REDO_T, const wxPoint&) {} + void SaveCopyInUndoList(PICKED_ITEMS_LIST&, UNDO_REDO_T, const wxPoint&) {} + + + DECLARE_EVENT_TABLE() +}; + +#endif // MODVIEWFRM_H_ diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index ad52213cbd..f35fe01e82 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -174,7 +174,7 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) EVT_TOOL( ID_TOOLBARH_PCB_MODE_MODULE, PCB_EDIT_FRAME::OnSelectAutoPlaceMode ) EVT_TOOL( ID_TOOLBARH_PCB_MODE_TRACKS, PCB_EDIT_FRAME::OnSelectAutoPlaceMode ) EVT_TOOL( ID_TOOLBARH_PCB_FREEROUTE_ACCESS, PCB_EDIT_FRAME::Access_to_External_Tool ) -#ifdef KICAD_SCRIPTING_WXPYTHON +#ifdef KICAD_SCRIPTING_WXPYTHON EVT_TOOL( ID_TOOLBARH_PCB_SCRIPTING_CONSOLE, PCB_EDIT_FRAME::ScriptingConsoleEnableDisable ) #endif // Option toolbar @@ -268,7 +268,7 @@ END_EVENT_TABLE() PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : - PCB_BASE_FRAME( parent, PCB_FRAME, title, pos, size, style ) + PCB_BASE_FRAME( parent, PCB_FRAME_TYPE, title, pos, size, style ) { m_FrameName = wxT( "PcbFrame" ); m_showBorderAndTitleBlock = true; // true to display sheet references @@ -285,7 +285,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, m_RecordingMacros = -1; m_microWaveToolBar = NULL; m_autoPlaceModeId = 0; -#ifdef KICAD_SCRIPTING_WXPYTHON +#ifdef KICAD_SCRIPTING_WXPYTHON m_pythonPanel = NULL; #endif for ( int i = 0; i < 10; i++ ) @@ -404,7 +404,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, m_auimgr.AddPane( m_messagePanel, wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(10) ); - + #ifdef KICAD_SCRIPTING_WXPYTHON // Add the scripting panel EDA_PANEINFO pythonAuiInfo; @@ -413,7 +413,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, pythonAuiInfo.MinSize( wxSize( 200, 100 ) ); pythonAuiInfo.BestSize( wxSize( GetClientSize().x/2, 200 ) ); pythonAuiInfo.Hide(); - + m_pythonPanel = CreatePythonShellWindow( this ); m_auimgr.AddPane( m_pythonPanel, pythonAuiInfo.Name( wxT( "PythonPanel" ) ).Bottom().Layer(9) ); @@ -804,9 +804,9 @@ void PCB_EDIT_FRAME::ScriptingConsoleEnableDisable( wxCommandEvent& aEvent ) m_auimgr.GetPane( m_pythonPanel ).Hide(); m_pythonPanelHidden = true; } - + m_auimgr.Update(); - + } #endif diff --git a/pcbnew/printout_controler.cpp b/pcbnew/printout_controler.cpp index 09024dbe17..f2b796dbfc 100644 --- a/pcbnew/printout_controler.cpp +++ b/pcbnew/printout_controler.cpp @@ -180,7 +180,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage() // In module editor, the module is located at 0,0 but for printing // it is moved to pageSizeIU.x/2, pageSizeIU.y/2. // So the equivalent board must be moved: - if( m_Parent->IsType( MODULE_EDITOR_FRAME ) ) + if( m_Parent->IsType( MODULE_EDITOR_FRAME_TYPE ) ) { bbbox.Move( wxPoint( pageSizeIU.x/2, pageSizeIU.y/2 ) ); }