Commit 6f10d168 authored by jean-pierre charras's avatar jean-pierre charras

Kicad manager: code cleaning. Fix a very minor bug.

parent fa8cbd98
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#ifndef __INFO3D_VISU_H__ #ifndef __INFO3D_VISU_H__
#define __INFO3D_VISU_H__ #define __INFO3D_VISU_H__
//#include <wxBasePcbFrame.h>
#include <layers_id_colors_and_visibility.h> // Layers id definitions #include <layers_id_colors_and_visibility.h> // Layers id definitions
#include <wx/glcanvas.h> #include <wx/glcanvas.h>
......
...@@ -35,58 +35,31 @@ ...@@ -35,58 +35,31 @@
#include <menus_helpers.h> #include <menus_helpers.h>
RIGHT_KM_FRAME::RIGHT_KM_FRAME( KICAD_MANAGER_FRAME* parent ) : LAUNCHER_PANEL::LAUNCHER_PANEL( wxWindow* parent ) :
wxSashLayoutWindow( parent, wxID_ANY ) wxPanel( parent, wxID_ANY )
{ {
m_Parent = parent;
m_MessagesBox = NULL;
m_bitmapButtons_maxHeigth = 0; m_bitmapButtons_maxHeigth = 0;
m_ButtonSeparation = 10; // control of command buttons position m_buttonSeparation = 10; // control of command buttons position
m_ButtonsListPosition.x = m_ButtonSeparation; m_buttonsListPosition.x = m_buttonSeparation;
m_ButtonsListPosition.y = m_ButtonSeparation; m_buttonsListPosition.y = m_buttonSeparation;
m_ButtonLastPosition = m_ButtonsListPosition; m_buttonLastPosition = m_buttonsListPosition;
// Add bitmap buttons to launch KiCad utilities: // Add bitmap buttons to launch KiCad utilities:
m_ButtPanel = new wxPanel( this, wxID_ANY );
CreateCommandToolbar(); CreateCommandToolbar();
m_ButtonsPanelHeight = m_ButtonsListPosition.y + m_bitmapButtons_maxHeigth + m_ButtonSeparation;
// Add the wxTextCtrl showing all messages from KiCad:
m_MessagesBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString,
wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE | wxSUNKEN_BORDER | wxTE_READONLY );
} }
int LAUNCHER_PANEL::GetPanelHeight() const
void RIGHT_KM_FRAME::OnSize( wxSizeEvent& event )
{ {
#define EXTRA_MARGE 4 int height = m_buttonsListPosition.y + m_bitmapButtons_maxHeigth
wxSize wsize; + m_buttonSeparation;
wsize.x = GetClientSize().x; return height;
// Fix size of buttons area
wsize.y = m_ButtonsPanelHeight;
m_ButtPanel->SetSize( wsize );
// Fix position and size of the message area, below the buttons area
wsize.y = GetClientSize().y - m_ButtonsPanelHeight;
m_MessagesBox->SetSize( wsize );
m_MessagesBox->SetPosition( wxPoint( 0, m_ButtonsPanelHeight ) );
event.Skip();
} }
BEGIN_EVENT_TABLE( RIGHT_KM_FRAME, wxSashLayoutWindow )
EVT_SIZE( RIGHT_KM_FRAME::OnSize )
END_EVENT_TABLE()
/** /**
* Function CreateCommandToolbar * Function CreateCommandToolbar
* create the buttons to call Eeschema CvPcb, Pcbnew and GerbView * create the buttons to call Eeschema CvPcb, Pcbnew and GerbView
*/ */
void RIGHT_KM_FRAME::CreateCommandToolbar( void ) void LAUNCHER_PANEL::CreateCommandToolbar( void )
{ {
wxBitmapButton* btn; wxBitmapButton* btn;
...@@ -121,9 +94,9 @@ Creates a component (for Eeschema) or a footprint (for Pcbnew) that shows a B&W ...@@ -121,9 +94,9 @@ Creates a component (for Eeschema) or a footprint (for Pcbnew) that shows a B&W
* @param aId = the button id * @param aId = the button id
* @param aBitmap = the wxBitmap used to create the button * @param aBitmap = the wxBitmap used to create the button
*/ */
wxBitmapButton* RIGHT_KM_FRAME::AddBitmapButton( wxWindowID aId, const wxBitmap& aBitmap ) wxBitmapButton* LAUNCHER_PANEL::AddBitmapButton( wxWindowID aId, const wxBitmap& aBitmap )
{ {
wxPoint buttPos = m_ButtonLastPosition; wxPoint buttPos = m_buttonLastPosition;
wxSize buttSize; wxSize buttSize;
int btn_margin = 10; // extra margin around the bitmap. int btn_margin = 10; // extra margin around the bitmap.
...@@ -133,8 +106,8 @@ wxBitmapButton* RIGHT_KM_FRAME::AddBitmapButton( wxWindowID aId, const wxBitmap& ...@@ -133,8 +106,8 @@ wxBitmapButton* RIGHT_KM_FRAME::AddBitmapButton( wxWindowID aId, const wxBitmap&
if( m_bitmapButtons_maxHeigth < buttSize.y ) if( m_bitmapButtons_maxHeigth < buttSize.y )
m_bitmapButtons_maxHeigth = buttSize.y; m_bitmapButtons_maxHeigth = buttSize.y;
wxBitmapButton* btn = new wxBitmapButton( m_ButtPanel, aId, aBitmap, buttPos, buttSize ); wxBitmapButton* btn = new wxBitmapButton( this, aId, aBitmap, buttPos, buttSize );
m_ButtonLastPosition.x += buttSize.x + m_ButtonSeparation; m_buttonLastPosition.x += buttSize.x + m_buttonSeparation;
return btn; return btn;
} }
...@@ -77,9 +77,7 @@ void EDA_APP::MacOpenFile( const wxString &fileName ) ...@@ -77,9 +77,7 @@ void EDA_APP::MacOpenFile( const wxString &fileName )
frame->m_LeftWin->ReCreateTreePrj(); frame->m_LeftWin->ReCreateTreePrj();
frame->PrintMsg( _( "Working dir: " ) + frame->m_ProjectFileName.GetPath() + frame->PrintPrjInfo();
_( "\nProject: " ) + frame->m_ProjectFileName.GetFullName() +
wxT( "\n" ) );
} }
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
extern const wxString g_KicadPrjFilenameExtension; extern const wxString g_KicadPrjFilenameExtension;
class RIGHT_KM_FRAME; class LAUNCHER_PANEL;
class TREEPROJECTFILES; class TREEPROJECTFILES;
class TREE_PROJECT_FRAME; class TREE_PROJECT_FRAME;
...@@ -123,14 +123,15 @@ class KICAD_MANAGER_FRAME : public EDA_BASE_FRAME ...@@ -123,14 +123,15 @@ class KICAD_MANAGER_FRAME : public EDA_BASE_FRAME
{ {
public: public:
TREE_PROJECT_FRAME* m_LeftWin; TREE_PROJECT_FRAME* m_LeftWin;
RIGHT_KM_FRAME* m_RightWin; LAUNCHER_PANEL* m_Launcher;
wxTextCtrl* m_MessagesBox;
wxAuiToolBar* m_VToolBar; // Vertical toolbar (not used) wxAuiToolBar* m_VToolBar; // Vertical toolbar (not used)
wxString m_BoardFileName; wxString m_BoardFileName;
wxString m_SchematicRootFileName; wxString m_SchematicRootFileName;
wxFileName m_ProjectFileName; wxFileName m_ProjectFileName;
private: private:
int m_LeftWin_Width; int m_leftWinWidth;
public: KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title, public: KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title,
const wxPoint& pos, const wxSize& size ); const wxPoint& pos, const wxSize& size );
...@@ -139,7 +140,6 @@ public: KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title, ...@@ -139,7 +140,6 @@ public: KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title,
void OnCloseWindow( wxCloseEvent& Event ); void OnCloseWindow( wxCloseEvent& Event );
void OnSize( wxSizeEvent& event ); void OnSize( wxSizeEvent& event );
void OnSashDrag( wxSashEvent& event );
/** /**
* Function OnLoadProject * Function OnLoadProject
...@@ -182,7 +182,18 @@ public: KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title, ...@@ -182,7 +182,18 @@ public: KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title,
*/ */
void PrintMsg( const wxString& aText ); void PrintMsg( const wxString& aText );
/**
* a minor helper function:
* Prints the Current Working Dir name and the projet name on the text panel.
*/
void PrintPrjInfo();
/**
* a minor helper function:
* Erase the text panel.
*/
void ClearMsg(); void ClearMsg();
void SetLanguage( wxCommandEvent& event ); void SetLanguage( wxCommandEvent& event );
void OnRefresh( wxCommandEvent& event ); void OnRefresh( wxCommandEvent& event );
void OnSelectDefaultPdfBrowser( wxCommandEvent& event ); void OnSelectDefaultPdfBrowser( wxCommandEvent& event );
...@@ -247,27 +258,23 @@ public: KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title, ...@@ -247,27 +258,23 @@ public: KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title,
}; };
/** class RIGHT_KM_FRAME /** class LAUNCHER_PANEL
*/ */
class RIGHT_KM_FRAME : public wxSashLayoutWindow class LAUNCHER_PANEL : public wxPanel
{ {
public:
wxTextCtrl* m_MessagesBox;
private: private:
KICAD_MANAGER_FRAME* m_Parent; // a wxTextCtrl to displays messages frm KiCad int m_buttonSeparation; // button distance in pixels
int m_ButtonsPanelHeight; wxPoint m_buttonsListPosition; /* position of the left bottom corner
wxPanel* m_ButtPanel;
int m_ButtonSeparation; // button distance in pixels
wxPoint m_ButtonsListPosition; /* position of the left bottom corner
* of the first bitmap button * of the first bitmap button
*/ */
wxPoint m_ButtonLastPosition; // position of the last button in the window wxPoint m_buttonLastPosition; // position of the last button in the window
int m_bitmapButtons_maxHeigth; // height of bigger bitmap buttons int m_bitmapButtons_maxHeigth; // height of bigger bitmap buttons
// Used to calculate the height of the panel. // Used to calculate the height of the panel.
public: RIGHT_KM_FRAME( KICAD_MANAGER_FRAME* parent ); public: LAUNCHER_PANEL( wxWindow* parent );
~RIGHT_KM_FRAME() { }; ~LAUNCHER_PANEL() { };
void OnSize( wxSizeEvent& event );
int GetPanelHeight() const;
private: private:
...@@ -278,8 +285,6 @@ private: ...@@ -278,8 +285,6 @@ private:
void CreateCommandToolbar( void ); void CreateCommandToolbar( void );
wxBitmapButton* AddBitmapButton( wxWindowID aId, const wxBitmap& aBitmap ); wxBitmapButton* AddBitmapButton( wxWindowID aId, const wxBitmap& aBitmap );
DECLARE_EVENT_TABLE()
}; };
#endif #endif
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <appl_wxstruct.h> #include <appl_wxstruct.h>
#include <confirm.h> #include <confirm.h>
#include <gestfich.h> #include <gestfich.h>
#include <macros.h>
#include <kicad.h> #include <kicad.h>
#include <tree_project_frame.h> #include <tree_project_frame.h>
...@@ -41,30 +42,14 @@ ...@@ -41,30 +42,14 @@
static const wxString TreeFrameWidthEntry( wxT( "LeftWinWidth" ) ); static const wxString TreeFrameWidthEntry( wxT( "LeftWinWidth" ) );
#define KICAD_MANAGER_FRAME_NAME wxT( "KicadFrame" )
KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent,
const wxString& title, const wxString& title,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size ) : const wxSize& size ) :
EDA_BASE_FRAME( parent, KICAD_MAIN_FRAME_TYPE, title, pos, size, EDA_BASE_FRAME( parent, KICAD_MAIN_FRAME_TYPE, title, pos, size,
KICAD_DEFAULT_DRAWFRAME_STYLE, KICAD_MANAGER_FRAME_NAME ) KICAD_DEFAULT_DRAWFRAME_STYLE, wxT( "KicadFrame" ) )
{ {
wxString msg; m_leftWinWidth = 60;
wxString line;
wxSize clientsize;
m_FrameName = KICAD_MANAGER_FRAME_NAME;
m_VToolBar = NULL; // No Vertical tooolbar used here
m_LeftWin = NULL; // A shashwindow that contains the project tree
m_RightWin = NULL; /* A shashwindow that contains the buttons
* and the window display text
*/
m_LeftWin_Width = std::max( 60, GetSize().x/3 );
LoadSettings();
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
// Create the status line (bottom of the frame // Create the status line (bottom of the frame
static const int dims[3] = { -1, -1, 100 }; static const int dims[3] = { -1, -1, 100 };
...@@ -77,43 +62,49 @@ KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, ...@@ -77,43 +62,49 @@ KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent,
icon.CopyFromBitmap( KiBitmap( icon_kicad_xpm ) ); icon.CopyFromBitmap( KiBitmap( icon_kicad_xpm ) );
SetIcon( icon ); SetIcon( icon );
clientsize = GetClientSize(); // Give the last sise and pos to main window
LoadSettings();
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
// Left window: is the box which display tree project // Left window: is the box which display tree project
m_LeftWin = new TREE_PROJECT_FRAME( this ); m_LeftWin = new TREE_PROJECT_FRAME( this );
// Bottom Window: box to display messages // Right top Window: buttons to launch applications
m_RightWin = new RIGHT_KM_FRAME( this ); m_Launcher = new LAUNCHER_PANEL( this );
// Add the wxTextCtrl showing all messages from KiCad:
msg = wxGetCwd(); m_MessagesBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString,
line.Printf( _( "Ready\nWorking dir: %s\n" ), msg.GetData() ); wxDefaultPosition, wxDefaultSize,
PrintMsg( line ); wxTE_MULTILINE | wxSUNKEN_BORDER | wxTE_READONLY );
RecreateBaseHToolbar(); RecreateBaseHToolbar();
ReCreateMenuBar(); ReCreateMenuBar();
m_auimgr.SetManagedWindow( this ); m_auimgr.SetManagedWindow( this );
EDA_PANEINFO horiz; EDA_PANEINFO horiztb;
horiz.HorizontalToolbarPane(); horiztb.HorizontalToolbarPane();
EDA_PANEINFO info; EDA_PANEINFO info;
info.InfoToolbarPane(); info.InfoToolbarPane();
if( m_mainToolBar )
m_auimgr.AddPane( m_mainToolBar, m_auimgr.AddPane( m_mainToolBar,
wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top().Layer( 1 ) ); wxAuiPaneInfo( horiztb ).Name( wxT( "m_mainToolBar" ) ).Top() );
if( m_RightWin )
m_auimgr.AddPane( m_RightWin,
wxAuiPaneInfo().Name( wxT( "m_RightWin" ) ).CentrePane().Layer( 1 ) );
if( m_LeftWin )
m_auimgr.AddPane( m_LeftWin, m_auimgr.AddPane( m_LeftWin,
wxAuiPaneInfo(info).Name( wxT( "m_LeftWin" ) ).Left(). wxAuiPaneInfo(info).Name( wxT( "m_LeftWin" ) ).Left().
BestSize( m_LeftWin_Width, clientsize.y ). BestSize( m_leftWinWidth, -1 ).
Layer( 1 ) ); Layer( 1 ) );
m_auimgr.AddPane( m_Launcher, wxTOP );
m_auimgr.GetPane( m_Launcher).CaptionVisible( false ).Row(1)
.BestSize( -1, m_Launcher->GetPanelHeight() ).PaneBorder( false ).Resizable( false );
m_auimgr.AddPane( m_MessagesBox,
wxAuiPaneInfo().Name( wxT( "m_MessagesBox" ) ).CentrePane().Layer( 2 ) );
m_auimgr.GetPane( m_LeftWin ).MinSize( wxSize( 80, -1) );
m_auimgr.GetPane( m_LeftWin ).BestSize(wxSize(m_leftWinWidth, -1) );
m_auimgr.Update(); m_auimgr.Update();
} }
...@@ -126,13 +117,7 @@ KICAD_MANAGER_FRAME::~KICAD_MANAGER_FRAME() ...@@ -126,13 +117,7 @@ KICAD_MANAGER_FRAME::~KICAD_MANAGER_FRAME()
void KICAD_MANAGER_FRAME::PrintMsg( const wxString& aText ) void KICAD_MANAGER_FRAME::PrintMsg( const wxString& aText )
{ {
m_RightWin->m_MessagesBox->AppendText( aText ); m_MessagesBox->AppendText( aText );
}
void KICAD_MANAGER_FRAME::OnSashDrag( wxSashEvent& event )
{
event.Skip();
} }
...@@ -324,28 +309,42 @@ void KICAD_MANAGER_FRAME::OnRefresh( wxCommandEvent& event ) ...@@ -324,28 +309,42 @@ void KICAD_MANAGER_FRAME::OnRefresh( wxCommandEvent& event )
void KICAD_MANAGER_FRAME::ClearMsg() void KICAD_MANAGER_FRAME::ClearMsg()
{ {
m_RightWin->m_MessagesBox->Clear(); m_MessagesBox->Clear();
} }
void KICAD_MANAGER_FRAME::LoadSettings() void KICAD_MANAGER_FRAME::LoadSettings()
{ {
wxASSERT( wxGetApp().GetSettings() != NULL );
wxConfig* cfg = wxGetApp().GetSettings(); wxConfig* cfg = wxGetApp().GetSettings();
if( cfg )
{
EDA_BASE_FRAME::LoadSettings(); EDA_BASE_FRAME::LoadSettings();
cfg->Read( TreeFrameWidthEntry, &m_LeftWin_Width ); cfg->Read( TreeFrameWidthEntry, &m_leftWinWidth );
}
} }
void KICAD_MANAGER_FRAME::SaveSettings() void KICAD_MANAGER_FRAME::SaveSettings()
{ {
wxASSERT( wxGetApp().GetSettings() != NULL );
wxConfig* cfg = wxGetApp().GetSettings(); wxConfig* cfg = wxGetApp().GetSettings();
if( cfg )
{
EDA_BASE_FRAME::SaveSettings(); EDA_BASE_FRAME::SaveSettings();
cfg->Write( TreeFrameWidthEntry, m_LeftWin->GetSize().x ); cfg->Write( TreeFrameWidthEntry, m_LeftWin->GetSize().x );
}
}
/**
* a minor helper function:
* Prints the Current Working Dir name and the projet name on the text panel.
*/
void KICAD_MANAGER_FRAME::PrintPrjInfo()
{
wxString msg;
msg.Printf( _( "Working dir: %s\nProject: %s\n" ),
GetChars( wxGetCwd() ),
GetChars( m_ProjectFileName.GetFullPath() ) );
PrintMsg( msg );
} }
...@@ -39,9 +39,6 @@ BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME ) ...@@ -39,9 +39,6 @@ BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME )
EVT_SIZE( KICAD_MANAGER_FRAME::OnSize ) EVT_SIZE( KICAD_MANAGER_FRAME::OnSize )
EVT_CLOSE( KICAD_MANAGER_FRAME::OnCloseWindow ) EVT_CLOSE( KICAD_MANAGER_FRAME::OnCloseWindow )
/* Sash drag events */
EVT_SASH_DRAGGED( ID_LEFT_FRAME, KICAD_MANAGER_FRAME::OnSashDrag )
/* Toolbar events */ /* Toolbar events */
EVT_TOOL( ID_NEW_PROJECT, KICAD_MANAGER_FRAME::OnLoadProject ) EVT_TOOL( ID_NEW_PROJECT, KICAD_MANAGER_FRAME::OnLoadProject )
EVT_TOOL( ID_NEW_PROJECT_FROM_TEMPLATE, KICAD_MANAGER_FRAME::OnLoadProject ) EVT_TOOL( ID_NEW_PROJECT_FROM_TEMPLATE, KICAD_MANAGER_FRAME::OnLoadProject )
......
...@@ -281,11 +281,7 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event ) ...@@ -281,11 +281,7 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event )
wxPostEvent( this, cmd); wxPostEvent( this, cmd);
#endif #endif
wxString msg; PrintPrjInfo();
msg.Format( _( "Working dir: <%s>\nProject: <%s>\n" ),
GetChars( m_ProjectFileName.GetPath() ),
GetChars( m_ProjectFileName.GetFullName() ) );
PrintMsg( msg );
} }
......
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