diff --git a/3d-viewer/info3d_visu.h b/3d-viewer/info3d_visu.h index 5bc1b8f57f..de9d755eed 100644 --- a/3d-viewer/info3d_visu.h +++ b/3d-viewer/info3d_visu.h @@ -30,7 +30,6 @@ #ifndef __INFO3D_VISU_H__ #define __INFO3D_VISU_H__ -//#include #include // Layers id definitions #include diff --git a/kicad/commandframe.cpp b/kicad/commandframe.cpp index 01c92365d0..0ad97f7eac 100644 --- a/kicad/commandframe.cpp +++ b/kicad/commandframe.cpp @@ -35,58 +35,31 @@ #include -RIGHT_KM_FRAME::RIGHT_KM_FRAME( KICAD_MANAGER_FRAME* parent ) : - wxSashLayoutWindow( parent, wxID_ANY ) +LAUNCHER_PANEL::LAUNCHER_PANEL( wxWindow* parent ) : + wxPanel( parent, wxID_ANY ) { - m_Parent = parent; - m_MessagesBox = NULL; m_bitmapButtons_maxHeigth = 0; - m_ButtonSeparation = 10; // control of command buttons position - m_ButtonsListPosition.x = m_ButtonSeparation; - m_ButtonsListPosition.y = m_ButtonSeparation; - m_ButtonLastPosition = m_ButtonsListPosition; + m_buttonSeparation = 10; // control of command buttons position + m_buttonsListPosition.x = m_buttonSeparation; + m_buttonsListPosition.y = m_buttonSeparation; + m_buttonLastPosition = m_buttonsListPosition; // Add bitmap buttons to launch KiCad utilities: - m_ButtPanel = new wxPanel( this, wxID_ANY ); 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 ); } - -void RIGHT_KM_FRAME::OnSize( wxSizeEvent& event ) +int LAUNCHER_PANEL::GetPanelHeight() const { - #define EXTRA_MARGE 4 - wxSize wsize; - wsize.x = GetClientSize().x; - - // 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(); + int height = m_buttonsListPosition.y + m_bitmapButtons_maxHeigth + + m_buttonSeparation; + return height; } - -BEGIN_EVENT_TABLE( RIGHT_KM_FRAME, wxSashLayoutWindow ) -EVT_SIZE( RIGHT_KM_FRAME::OnSize ) -END_EVENT_TABLE() - - /** * Function CreateCommandToolbar * create the buttons to call Eeschema CvPcb, Pcbnew and GerbView */ -void RIGHT_KM_FRAME::CreateCommandToolbar( void ) +void LAUNCHER_PANEL::CreateCommandToolbar( void ) { wxBitmapButton* btn; @@ -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 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; int btn_margin = 10; // extra margin around the bitmap. @@ -133,8 +106,8 @@ wxBitmapButton* RIGHT_KM_FRAME::AddBitmapButton( wxWindowID aId, const wxBitmap& if( m_bitmapButtons_maxHeigth < buttSize.y ) m_bitmapButtons_maxHeigth = buttSize.y; - wxBitmapButton* btn = new wxBitmapButton( m_ButtPanel, aId, aBitmap, buttPos, buttSize ); - m_ButtonLastPosition.x += buttSize.x + m_ButtonSeparation; + wxBitmapButton* btn = new wxBitmapButton( this, aId, aBitmap, buttPos, buttSize ); + m_buttonLastPosition.x += buttSize.x + m_buttonSeparation; return btn; } diff --git a/kicad/kicad.cpp b/kicad/kicad.cpp index 7b4e29dda2..672308ab29 100644 --- a/kicad/kicad.cpp +++ b/kicad/kicad.cpp @@ -77,9 +77,7 @@ void EDA_APP::MacOpenFile( const wxString &fileName ) frame->m_LeftWin->ReCreateTreePrj(); - frame->PrintMsg( _( "Working dir: " ) + frame->m_ProjectFileName.GetPath() + - _( "\nProject: " ) + frame->m_ProjectFileName.GetFullName() + - wxT( "\n" ) ); + frame->PrintPrjInfo(); } diff --git a/kicad/kicad.h b/kicad/kicad.h index 0bfd0dce97..73ffbe8ebe 100644 --- a/kicad/kicad.h +++ b/kicad/kicad.h @@ -49,7 +49,7 @@ extern const wxString g_KicadPrjFilenameExtension; -class RIGHT_KM_FRAME; +class LAUNCHER_PANEL; class TREEPROJECTFILES; class TREE_PROJECT_FRAME; @@ -123,14 +123,15 @@ class KICAD_MANAGER_FRAME : public EDA_BASE_FRAME { public: TREE_PROJECT_FRAME* m_LeftWin; - RIGHT_KM_FRAME* m_RightWin; + LAUNCHER_PANEL* m_Launcher; + wxTextCtrl* m_MessagesBox; wxAuiToolBar* m_VToolBar; // Vertical toolbar (not used) wxString m_BoardFileName; wxString m_SchematicRootFileName; wxFileName m_ProjectFileName; private: - int m_LeftWin_Width; + int m_leftWinWidth; public: KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title, const wxPoint& pos, const wxSize& size ); @@ -139,7 +140,6 @@ public: KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title, void OnCloseWindow( wxCloseEvent& Event ); void OnSize( wxSizeEvent& event ); - void OnSashDrag( wxSashEvent& event ); /** * Function OnLoadProject @@ -182,7 +182,18 @@ public: KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title, */ 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 SetLanguage( wxCommandEvent& event ); void OnRefresh( wxCommandEvent& event ); void OnSelectDefaultPdfBrowser( wxCommandEvent& event ); @@ -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: - KICAD_MANAGER_FRAME* m_Parent; // a wxTextCtrl to displays messages frm KiCad - int m_ButtonsPanelHeight; - wxPanel* m_ButtPanel; - int m_ButtonSeparation; // button distance in pixels - wxPoint m_ButtonsListPosition; /* position of the left bottom corner + int m_buttonSeparation; // button distance in pixels + wxPoint m_buttonsListPosition; /* position of the left bottom corner * 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 // Used to calculate the height of the panel. -public: RIGHT_KM_FRAME( KICAD_MANAGER_FRAME* parent ); - ~RIGHT_KM_FRAME() { }; - void OnSize( wxSizeEvent& event ); +public: LAUNCHER_PANEL( wxWindow* parent ); + ~LAUNCHER_PANEL() { }; + + int GetPanelHeight() const; private: @@ -278,8 +285,6 @@ private: void CreateCommandToolbar( void ); wxBitmapButton* AddBitmapButton( wxWindowID aId, const wxBitmap& aBitmap ); - - DECLARE_EVENT_TABLE() }; #endif diff --git a/kicad/mainframe.cpp b/kicad/mainframe.cpp index 1150b039f0..677b4b5e9a 100644 --- a/kicad/mainframe.cpp +++ b/kicad/mainframe.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -41,30 +42,14 @@ static const wxString TreeFrameWidthEntry( wxT( "LeftWinWidth" ) ); -#define KICAD_MANAGER_FRAME_NAME wxT( "KicadFrame" ) - KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title, const wxPoint& pos, const wxSize& 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; - 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 ); + m_leftWinWidth = 60; // Create the status line (bottom of the frame static const int dims[3] = { -1, -1, 100 }; @@ -77,42 +62,48 @@ KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, icon.CopyFromBitmap( KiBitmap( icon_kicad_xpm ) ); 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 m_LeftWin = new TREE_PROJECT_FRAME( this ); - // Bottom Window: box to display messages - m_RightWin = new RIGHT_KM_FRAME( this ); - - msg = wxGetCwd(); - line.Printf( _( "Ready\nWorking dir: %s\n" ), msg.GetData() ); - PrintMsg( line ); + // Right top Window: buttons to launch applications + m_Launcher = new LAUNCHER_PANEL( this ); + // Add the wxTextCtrl showing all messages from KiCad: + m_MessagesBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString, + wxDefaultPosition, wxDefaultSize, + wxTE_MULTILINE | wxSUNKEN_BORDER | wxTE_READONLY ); RecreateBaseHToolbar(); ReCreateMenuBar(); m_auimgr.SetManagedWindow( this ); - EDA_PANEINFO horiz; - horiz.HorizontalToolbarPane(); + EDA_PANEINFO horiztb; + horiztb.HorizontalToolbarPane(); EDA_PANEINFO info; info.InfoToolbarPane(); - if( m_mainToolBar ) - m_auimgr.AddPane( m_mainToolBar, - wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top().Layer( 1 ) ); + m_auimgr.AddPane( m_mainToolBar, + wxAuiPaneInfo( horiztb ).Name( wxT( "m_mainToolBar" ) ).Top() ); - if( m_RightWin ) - m_auimgr.AddPane( m_RightWin, - wxAuiPaneInfo().Name( wxT( "m_RightWin" ) ).CentrePane().Layer( 1 ) ); + m_auimgr.AddPane( m_LeftWin, + wxAuiPaneInfo(info).Name( wxT( "m_LeftWin" ) ).Left(). + BestSize( m_leftWinWidth, -1 ). + Layer( 1 ) ); - if( m_LeftWin ) - m_auimgr.AddPane( m_LeftWin, - wxAuiPaneInfo(info).Name( wxT( "m_LeftWin" ) ).Left(). - BestSize( m_LeftWin_Width, clientsize.y ). - 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(); } @@ -126,13 +117,7 @@ KICAD_MANAGER_FRAME::~KICAD_MANAGER_FRAME() void KICAD_MANAGER_FRAME::PrintMsg( const wxString& aText ) { - m_RightWin->m_MessagesBox->AppendText( aText ); -} - - -void KICAD_MANAGER_FRAME::OnSashDrag( wxSashEvent& event ) -{ - event.Skip(); + m_MessagesBox->AppendText( aText ); } @@ -324,28 +309,42 @@ void KICAD_MANAGER_FRAME::OnRefresh( wxCommandEvent& event ) void KICAD_MANAGER_FRAME::ClearMsg() { - m_RightWin->m_MessagesBox->Clear(); + m_MessagesBox->Clear(); } void KICAD_MANAGER_FRAME::LoadSettings() { - wxASSERT( wxGetApp().GetSettings() != NULL ); - wxConfig* cfg = wxGetApp().GetSettings(); - EDA_BASE_FRAME::LoadSettings(); - cfg->Read( TreeFrameWidthEntry, &m_LeftWin_Width ); + if( cfg ) + { + EDA_BASE_FRAME::LoadSettings(); + cfg->Read( TreeFrameWidthEntry, &m_leftWinWidth ); + } } void KICAD_MANAGER_FRAME::SaveSettings() { - wxASSERT( wxGetApp().GetSettings() != NULL ); - wxConfig* cfg = wxGetApp().GetSettings(); - EDA_BASE_FRAME::SaveSettings(); - - cfg->Write( TreeFrameWidthEntry, m_LeftWin->GetSize().x ); + if( cfg ) + { + EDA_BASE_FRAME::SaveSettings(); + 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 ); } diff --git a/kicad/menubar.cpp b/kicad/menubar.cpp index baebaa02d4..90af49c3ff 100644 --- a/kicad/menubar.cpp +++ b/kicad/menubar.cpp @@ -39,9 +39,6 @@ BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME ) EVT_SIZE( KICAD_MANAGER_FRAME::OnSize ) EVT_CLOSE( KICAD_MANAGER_FRAME::OnCloseWindow ) - /* Sash drag events */ - EVT_SASH_DRAGGED( ID_LEFT_FRAME, KICAD_MANAGER_FRAME::OnSashDrag ) - /* Toolbar events */ EVT_TOOL( ID_NEW_PROJECT, KICAD_MANAGER_FRAME::OnLoadProject ) EVT_TOOL( ID_NEW_PROJECT_FROM_TEMPLATE, KICAD_MANAGER_FRAME::OnLoadProject ) diff --git a/kicad/prjconfig.cpp b/kicad/prjconfig.cpp index c33e59f76d..8d19791e24 100644 --- a/kicad/prjconfig.cpp +++ b/kicad/prjconfig.cpp @@ -281,11 +281,7 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event ) wxPostEvent( this, cmd); #endif - wxString msg; - msg.Format( _( "Working dir: <%s>\nProject: <%s>\n" ), - GetChars( m_ProjectFileName.GetPath() ), - GetChars( m_ProjectFileName.GetFullName() ) ); - PrintMsg( msg ); + PrintPrjInfo(); }